在win10下python3.7.0 下安装成功vnpy2.0.3版本,之后运行样例程序 run_ga.py, 代码如下:
`from vnpy.app.cta_strategy.backtesting import BacktestingEngine, OptimizationSetting
from vnpy.app.cta_strategy.strategies.atr_rsi_strategy import (
AtrRsiStrategy,
)
from datetime import datetime
if name == "main":
engine = BacktestingEngine()
engine.set_parameters(
vt_symbol="IF88.CFFEX",
interval="1m",
start=datetime(2019, 1, 1),
end=datetime(2019, 4, 30),
rate=0.3 / 10000,
slippage=0.2,
size=300,
pricetick=0.2,
capital=1_000_000,
)
engine.add_strategy(AtrRsiStrategy, {})
setting = OptimizationSetting()
setting.set_target("sharpe_ratio")
setting.add_parameter("atr_length", 3, 39, 1)
setting.add_parameter("atr_ma_length", 10, 30, 1)
engine.run_ga_optimization(setting)`
运行结果显示
开始加载历史数据
2019-05-29 09:10:54.979882 历史数据加载完成,数据量:0
2019-05-29 09:10:54.979882 策略初始化完成
2019-05-29 09:10:54.979882 开始回放历史数据
2019-05-29 09:10:54.979882 历史数据回放结束
2019-05-29 09:10:54.980882 开始计算逐日盯市盈亏
2019-05-29 09:10:54.980882 成交记录为空,无法计算
2019-05-29 09:10:54.980882 开始计算策略统计指标
已经通过 run.py 打开图形化界面设置了数据库参数,mongodb, VnTrader_1Min_Db,localhost, 27017