[Vnpy Quantitative Investment from Scratch] Seventeen. Portfolio Strategy Segmented Backtesting

[Vnpy Quantitative Investment from Scratch] Seventeen. Portfolio Strategy Segmented Backtesting

overview

According to the most basic conclusion of portfolio theory, diversified investment can obtain lower risk than single assets, so the portfolio strategy basically needs to use a large number of contracts for testing, especially for varieties with low correlation. At the same time, most of the combined strategies are medium and long-term strategies, that is, the backtesting period needs to be verified for a longer period. These two reasons cause us to often need to load multiple contract varieties for up to 10 years for backtesting when testing the combined strategy. If you need to use non-main continuous or index contracts, you need to load more contracts to simulate real scenarios.
The more data loaded, the higher the memory requirement for the test machine. Since the default mechanism of vnpy is to load all the data into the memory and then play it back, the memory usage is basically proportional to the backtest duration and the number of contracts.

Combination Strategy Backtesting Mechanism

Let's first observe the way we called the backtest engine before. The official sample file basically uses the following format to call.

    engine.set_parameters(
        vt_symbols=vt_symbols,
        interval=Interval.MINUTE,
        start=start,

Guess you like

Origin blog.csdn.net/u011687355/article/details/130880180