Account Info
Log Out
English
Back
No matches yet
Operations too frequent. Please try again later.
Please check network settings and try again Refresh Refresh
Loading
History record delete
    Quotes All >
      News All >
        Log in to access Online Inquiry

        How to handle exceptions in strategy running

        When running a strategy, exceptions may happen to the Conditions and/or Operations, 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 "How to understand the strategy running framework of moomoo's quant trading feature".


        1. Exceptions in [Start]

        [Start] 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 and/or Operations

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

        2.1 Skip the current Condition or Operation and continue from the next one

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

        Operations: When the strategy runs to the Operation [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].

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

        2.2 Skip the current path and continue from the next one

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

        2.3 Skip the current round and continue from the next one

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


        3. Special Note

        Value Assignment

        When the strategy runs to [Value Assignment] 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).

        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.