11. 海龜交易法策略(教學簡化版)
參考來源:docs/_joinquant_migration_source/Example_11_海龜交易法.ipynb 第一個 Markdown cell。
11.1. 策略思路
使用唐奇安通道的突破信號作爲開倉依據;
價格突破上軌做多,跌破下軌做空;
結合較短週期通道控制退出(簡化版海龜規則)。
11.2. qteasy 實現
策略類:
Example11Turtle;信號類型:
PT;默認腳本使用單標的教學版,便於驗證鏈路和參數優化流程。
from examples.strategies.example_strategies import Example11Turtle
import qteasy as qt
stg = Example11Turtle()
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='E',
asset_pool=['000001.SZ'],
benchmark_asset='000001.SZ',
invest_start='20190101',
invest_end='20211231',
invest_cash_amounts=[1000000],
trade_batch_size=100,
sell_batch_size=1,
allow_sell_short=True,
trade_log=True,
)
11.3. 可執行腳本
examples/strategy_example_11.py