Skip to content

Commit

Permalink
Fix zero length equity curve issue
Browse files Browse the repository at this point in the history
  • Loading branch information
miohtama committed Oct 6, 2024
1 parent edbb5d8 commit 9b3983e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions tradeexecutor/analysis/trade_analyser.py
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,7 @@ def calculate_summary_statistics(

daily_returns = calculate_daily_returns(state, freq="D")
equity_curve = calculate_equity_curve(state)

original_returns = calculate_returns(equity_curve)
compounding_returns = calculate_compounding_realised_trading_profitability(state)

Expand Down
4 changes: 2 additions & 2 deletions tradeexecutor/visual/equity_curve.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ def calculate_returns(equity_curve: pd.Series) -> pd.Series:

if len(equity_curve) == 0:
series = pd.Series([], index=pd.to_datetime([]), dtype='float64')

series = equity_curve.pct_change().fillna(0.0)
else:
series = equity_curve.pct_change().fillna(0.0)

series.attrs = equity_curve.attrs.copy()
series.attrs["curve"] = CurveType.returns
Expand Down

0 comments on commit 9b3983e

Please sign in to comment.