15. 大小盤輪動投資策略(教學等價版)
參考來源:docs/_joinquant_migration_source/Example_15_大小盤輪動投資策略.ipynb。 說明:該 notebook 的首個 Markdown cell 爲空,本文按策略名稱與後續代碼意圖給出教學實現。
15.1. 策略思路
選取大盤/中小盤代理指數;
比較近 N 日相對強弱;
將組合權重集中到強勢標的,實現大小盤輪動。
15.2. qteasy 實現
策略類:
Example15LargeSmallRotation;信號類型:
PT;默認指數池:
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. 可執行腳本
examples/strategy_example_15.py