vn.py量化社区
By Traders, For Traders.
Member
avatar
加入于:
帖子: 15
声望: 0

如题,用的vnpy master 》exemple 里backtesting的跑。

报错,请问时哪里有问题啊

KeyError Traceback (most recent call last)

<ipython-input-5-4b99ee50d5a7> in <module>
4 setting.add_parameter("kk_dev", 0.5, 5, 0.1)
5
----> 6 engine.run_ga_optimization(setting)

E:\vnpy_master\examples\cta_backtesting\vnpy\app\cta_strategy\backtesting.py in run_ga_optimization(self, optimization_setting, population_size, ngen_size, output)
706 ngen,
707 stats,
--> 708 halloffame=hof
709 )
710

c:\vnstudio\lib\site-packages\deap\algorithms.py in eaMuPlusLambda(population, toolbox, mu, lambda_, cxpb, mutpb, ngen, stats, halloffame, verbose)
300 invalid_ind = [ind for ind in population if not ind.fitness.valid]
301 fitnesses = toolbox.map(toolbox.evaluate, invalid_ind)
--> 302 for ind, fit in zip(invalid_ind, fitnesses):
303 ind.fitness.values = fit
304

E:\vnpy_master\examples\cta_backtesting\vnpy\app\cta_strategy\backtesting.py in ga_optimize(parameter_values)
1253 def ga_optimize(parameter_values: list):
1254 """"""
-> 1255 return _ga_optimize(tuple(parameter_values))
1256
1257

E:\vnpy_master\examples\cta_backtesting\vnpy\app\cta_strategy\backtesting.py in _ga_optimize(parameter_values)
1246 ga_end,
1247 ga_mode,
-> 1248 ga_inverse
1249 )
1250 return (result[1],)

E:\vnpy_master\examples\cta_backtesting\vnpy\app\cta_strategy\backtesting.py in optimize(target_name, strategy_class, setting, vt_symbol, interval, start, rate, slippage, size, pricetick, capital, end, mode, inverse)
1219 engine.add_strategy(strategy_class, setting)
1220 engine.load_data()
-> 1221 engine.run_backtesting()
1222 engine.calculate_result()
1223 statistics = engine.calculate_statistics(output=False)

E:\vnpy_master\examples\cta_backtesting\vnpy\app\cta_strategy\backtesting.py in run_backtesting(self)
291 # Use the rest of history data for running backtesting
292 for data in self.history_data[ix:]:
--> 293 func(data)
294
295 self.output("历史数据回放结束")

E:\vnpy_master\examples\cta_backtesting\vnpy\app\cta_strategy\backtesting.py in new_bar(self, bar)
740
741 self.cross_limit_order()
--> 742 self.cross_stop_order()
743 self.strategy.on_bar(bar)
744

E:\vnpy_master\examples\cta_backtesting\vnpy\app\cta_strategy\backtesting.py in cross_stop_order(self)
907 stop_order.status = StopOrderStatus.TRIGGERED
908
--> 909 self.active_stop_orders.pop(stop_order.stop_orderid)
910
911 # Push update to strategy.

KeyError: 'STOP.3104'

Administrator
avatar
加入于:
帖子: 3011
声望: 135

请升级到2.0.9版本,这里之前有个bug已经修复掉了

© 2015-2019 上海韦纳软件科技有限公司
备案服务号:沪ICP备18006526号-3