Skip to content

Commit

Permalink
negative returns cannot be annualized properly
Browse files Browse the repository at this point in the history
  • Loading branch information
Cuizi7 committed Oct 29, 2018
1 parent 2412d9e commit 2da93ac
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions rqalpha/model/portfolio.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ def annualized_returns(self):
"""
[float] 累计年化收益率
"""
if self.unit_net_value <= 0:
return -1
current_date = Environment.get_instance().trading_dt.date()
natural_start_date = Environment.get_instance().config.base.natural_start_date
return self.unit_net_value ** (DAYS_CNT.DAYS_A_YEAR / float((current_date - natural_start_date).days + 1)) - 1
Expand Down

0 comments on commit 2da93ac

Please sign in to comment.