11. Turtle Trading Strategy (Simplified Tutorial)

Reference source: docs/_joinquant_migration_source/Example_11_Turtle Trading Method.ipynb First Markdown cell.

11.1. Strategy and Ideas

  • Use breakout signals from the Donchian Channel as a basis for opening positions;

  • Buy when the price breaks through the upper band, and sell when it breaks below the lower band.

  • Combined with shorter cycle channel control exit (simplified turtle rules).

11.2. QtEasy implementation

  • Strategy class: Example11Turtle;

  • Signal type: PT;

  • The default script uses a single-standard teaching version, which facilitates the verification of the link and parameter optimization process.

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. Executable script

  • examples/strategy_example_11.py