QAStrategy 模块文档
概述
模块架构
核心组件
策略类型
1. CTA策略 (qactabase.py)
from QUANTAXIS.QAStrategy.qactabase import QACTABase
class MyTrendStrategy(QACTABase):
def __init__(self):
super().__init__()
self.period = 20
def on_bar(self, bar):
# 计算技术指标
ma = self.data.ma(self.period)
# 交易信号
if bar.close > ma.iloc[-1]:
self.buy(bar.code, 100, bar.close)
elif bar.close < ma.iloc[-1]:
self.sell(bar.code, 100, bar.close)
def on_trade(self, trade):
print(f"交易执行: {trade}")2. 套利策略 (qahedgebase.py)
3. 因子策略 (qafactorbase.py)
策略生命周期
1. 初始化阶段
2. 数据处理阶段
3. 风险管理
回测框架
1. 回测配置
2. 回测执行
实盘交易
1. 实盘配置
2. 实盘执行
多策略管理
策略同步 (syncoms.py)
性能评估
1. 收益指标
2. 风险指标
最佳实践
相关模块
Last updated
Was this helpful?