Skip to content

Commit

Permalink
Moar marked down fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
miohtama committed Jan 30, 2025
1 parent 7571205 commit f6742e4
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tradeexecutor/analysis/trade_analyser.py
Original file line number Diff line number Diff line change
Expand Up @@ -913,6 +913,10 @@ def calculate_summary_statistics_for_positions(
# it was closed to zero without any sells
if not position.is_marked_down():
assert realised_profit_usd is not None, f"Realised profit calculation failed for: {position}. Marked down: {position.is_marked_down()}"
else:
# Handle marked down position
if realised_profit_usd is None:
realised_profit_usd = 0

realised_profit_percent = position.get_realised_profit_percent()

Expand Down

0 comments on commit f6742e4

Please sign in to comment.