vnpy / vnpy_ctabacktester

VeighNa框架的CTA回测模块
https://www.vnpy.com
MIT License
56 stars 63 forks source link

backtester statistics error: divide by zero #15

Closed synote closed 2 years ago

synote commented 2 years ago

The backtester gives the runtime error:

RuntimeWarning: divide by zero encountered in double_scalars
  return_drawdown_ratio: float = -total_return / max_ddpercent

This is due to the max_ddpercent may be 0 in some kind of trading.

We can just assign return_drawdown_ratio=0 if the max_ddpercent is 0. This can avoid runtime waning.

noranhe commented 2 years ago

已修复 https://github.com/vnpy/vnpy_ctastrategy/pull/18