15. Large-Cap/Small-Cap Rotation Investment Strategy (Equivalent to Educational Version)

Reference source: docs/_joinquant_migration_source/Example_15_Small-Cap Rotation Investment Strategy.ipynb. Note: The first Markdown cell of this notebook is empty. This article provides the teaching implementation according to the strategy name and the intent of the subsequent code.

15.1. Strategy and Ideas

  • Select large-cap/small-cap proxy indices;

  • Compare the relative strength over the past N days;

  • By concentrating portfolio weights on strong stocks, a rotation between large and small caps can be achieved.

15.2. QtEasy implementation

  • Strategy class: Example 15 Large Small Rotation;

  • Signal type: PT;

  • Default index pool: 000300.SH, 000905.SH, 000852.SH.

from examples.strategies.example_strategies import Example15LargeSmallRotation
import qteasy as qt

stg = Example15LargeSmallRotation()
op = qt.Operator(stg, signal_type='PT')
op.op_type = 'stepwise'
op.set_blender('1.0*s0')
res = qt.run(
    op,
    mode=1,
    asset_type='IDX',
    asset_pool=['000300.SH', '000905.SH', '000852.SH'],
    benchmark_asset='000300.SH',
    invest_start='20190101',
    invest_end='20211231',
    invest_cash_amounts=[1000000],
    trade_batch_size=0.01,
    sell_batch_size=0.01,
    trade_log=True,
)

15.3. Executable script

  • examples/strategy_example_15.py