moomoo SG Help Center-How to handle exceptions in strategy running
English
Back
Log in to access Online Inquiry
Back to the Top

How to handle exceptions in strategy running

When running a strategy, exceptions may happen to the Conditions Cards and/or Operations Cards, resulting in request failures or data access errors. This article will explain how these exceptions are handled so that you can choose from different methods depending on scenarios.

Before that, it is recommended that you first understand the operating framework under normal circumstances by referring to "Running Order of Conditions Cards & Operations Cards".

 

1. Exceptions in "Start" Card

"Start" Card runs once when the entire strategy is about to begin. If global variables fail to be assigned values (for example: a = 1/0, but 0 cannot be used as the denominator) or cannot access market data, the entire strategy will not be initialized and thus cannot begin.

 

2. Exceptions in Conditions Cards and/or Operations Cards

In the parameter setting interface of "Live Trading" or "Backtesting", you can choose from the following three exception handling methods:

2.1 Skip the erroneous card

Exit the erroneous card and advance to the next card on the path.

In this method, exceptions in Operations Cards are handled in a way slightly different from that in Conditions Cards.

Operations Cards: When the strategy runs to the Operation Card "Close Position to Take Profit" in path 2, and an exception occurs, the strategy will skip the Operation and continue running from "Initialized Position Cost for Each Price Level".

Any images provided are not current and any securities shown are for illustrative purposes only and are not recommendations. 

Conditions Cards: When running to the Condition Card "Take-Profit Conditions Met?" on path 2, and an exception happens, the strategy will skip that Condition and re-start from the first Condition Card or Operation Card on the next path (path 3).

Any images provided are not current and any securities shown are for illustrative purposes only and are not recommendations. 

2.2 Skip the erroneous path

Exit the erroneous path and advance to the next one starting from the "Start" card.

If an exception occurs when the strategy runs to the Condition Card "Take-Profit Conditions Met?" on path 2, it will skip the Condition and continue to run from the first Condition Card or Operation Card on the next path (path 3).

Any images provided are not current and any securities shown are for illustrative purposes only and are not recommendations. 

Any images provided are not current and any securities shown are for illustrative purposes only and are not recommendations. 

2.3 Skip the erroneous strategy cycle

Skip the rest of the current strategy cycle and continue with the next iteration when triggered.

When running to the Condition Card "Take-Profit Conditions Met?" on path 2, and an exception happens, the strategy will skip that Condition as well as all unexecuted Conditions Cards or Operations Cards, and re-start from the first Condition Card or Operation Card on path 1 if it is triggered again for another round.

Any images provided are not current and any securities shown are for illustrative purposes only and are not recommendations. 

Any images provided are not current and any securities shown are for illustrative purposes only and are not recommendations. 

 

3. Special Note

Value Assignment Card

When the strategy runs to "Value Assignment Card" and value assignment fails due to an exception, the global variable will remain the value before the assignment instead of being cleared (for example: when a = high price of a candlestick, but the high price cannot be accessed, a will maintain the original value).

Risk Disclosure This presentation is for informational and educational use only and is not a recommendation or endorsement of any particular investment or investment strategy. Investment information provided in this content is general in nature, strictly for illustrative purposes, and may not be appropriate for all investors. It is provided without respect to individual investors’ financial sophistication, financial situation, investment objectives, investing time horizon, or risk tolerance. You should consider the appropriateness of this information having regard to your relevant personal circumstances before making any investment decisions. Past investment performance does not indicate or guarantee future success. Returns will vary, and all investments carry risks, including loss of principal. Moomoo makes no representation or warranty as to its adequacy, completeness, accuracy or timeliness for any particular purpose of the above content.