4. Finding and Using Built-in Strategies
qteasy provides many built-in trading strategies. Look them up by ID, read their docs, and use them directly in an Operator.
4.1. Find and Retrieve Built-in Strategies
qt.built_in_list(): Return all built-in strategy IDs (or filter with a fuzzy string).qt.built_ins(stg_id): Return a mapping of strategy classes or instances by ID; omitstg_idfor all.qt.built_in_doc(stg_id): Return the strategy docstring (description, parameters, etc.).qt.get_strategy_by_id(stg_id): Get a usable strategy instance by ID foradd_strategy.
import qteasy as qt
# 列出所有内置策略 ID
ids = qt.built_in_list()
print(ids[:10])
# 获取单个策略文档
print(qt.built_in_doc('dma'))
# 获取策略实例并加入 Operator
stg = qt.get_strategy_by_id('macd')
op = qt.Operator(strategies=stg, signal_type='PT', run_freq='d')
# 或直接传 ID
op = qt.Operator(strategies='macd', signal_type='PT', run_freq='d')
4.2. Use Built-in Strategies in an Operator
Pass a strategy ID string (e.g.,
'dma','macd') or a strategy class/instance.Use
set_parameter('stg_id', pars=...)for tunable parameters; optionally setrun_freqandrun_timingfor grouping.
4.3. Full Built-in Strategy List (with Brief Descriptions)
Below is the list of built-in strategy IDs in qteasy. For details, parameter names and meanings, and signal types, call qt.built_in_doc('id').
Strategy ID |
Category / Description |
|---|---|
crossline |
Moving-average crossover |
macd, macdext |
MACD-related |
dma, trix |
Dual/multiple moving averages |
cdl, bband, s-bband, sarext |
Candlestick, Bollinger, SAR, etc. |
ssma, sdema, sema, sht, skama, smama, st3, stema, strima, swma |
Smoothing (SCR prefix) |
dsma, ddema, dema, dkama, dmama, dt3, dtema, dtrima, dwma |
Smoothing (DCR prefix) |
slsma, sldema, slema, slht, slkama, slmama, slt3, sltema, sltrima, slwma |
Smoothing (SLP prefix) |
adx, apo, aroon, aroonosc, cci, cmo, mfi, di, dm, mom, ppo, rsi, stoch, stochf, stochrsi, ultosc, willr |
Technical indicators |
ad, adosc, obv |
Volume-based |
signal_none, sellrate, buyrate |
Signal control / ratio |
long, short, zero |
Fixed timing positions |
all, select_none, random |
Stock selection (all / none / random) |
finance, ndaylast, ndayavg, ndayrate, ndaychg, ndayvol |
Selection factor |
The authoritative ID list is qt.built_in_list(); parameters and usage are in qt.built_in_doc('id').