[Mod] add default value for pre_close price if zero

This commit is contained in:
vn.py 2019-10-19 00:04:52 +08:00
parent 01fed04246
commit b117e84167

View File

@ -1099,7 +1099,12 @@ class DailyResult:
inverse: bool
):
""""""
self.pre_close = pre_close
# If no pre_close provided on the first day,
# use value 1 to avoid zero division error
if pre_close:
self.pre_close = pre_close
else:
self.pre_close = 1
# Holding pnl is the pnl from holding position at day start
self.start_pos = start_pos