Skip to content

Commit 7ce55f3

Browse files
committed
feat: Add trading summary generation
- Add trade statistics calculation - Add profit tracking - Add basic performance metrics
1 parent 46761bd commit 7ce55f3

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

traid/trading/simulator.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,3 +147,28 @@ def get_position_pnl(self, symbol: str) -> Decimal:
147147
position_cost = self.positions.get(symbol, Decimal("0")) * avg_price
148148
return current_value - position_cost
149149

150+
def get_trading_summary(self) -> Dict:
151+
"""Generate summary of trading activity."""
152+
total_trades = len(self.trades_history)
153+
if total_trades == 0:
154+
return {
155+
"total_trades": 0,
156+
"profitable_trades": 0,
157+
"total_profit_loss": Decimal("0")
158+
}
159+
160+
profitable_trades = 0
161+
total_pnl = Decimal("0")
162+
163+
for trade in self.trades_history:
164+
if trade["side"] == "sell":
165+
profit = trade["revenue"] - trade["price"] * trade["volume"]
166+
if profit > 0:
167+
profitable_trades += 1
168+
total_pnl += profit
169+
170+
return {
171+
"total_trades": total_trades,
172+
"profitable_trades": profitable_trades,
173+
"total_profit_loss": total_pnl
174+
}

0 commit comments

Comments
 (0)