feat: add portfolio summary to simulation page

Shows real-time portfolio metrics:
- Cash Balance
- Position (quantity and value)
- Entry Price / Current Price
- Unrealized P&L
- Total Value
- P&L (absolute and percentage)

Updates as simulation runs and trades are executed.
This commit is contained in:
shokollm
2026-04-12 07:15:11 +00:00
parent 3013326ded
commit bba773251a
7 changed files with 201 additions and 3 deletions

View File

@@ -60,6 +60,9 @@ def run_simulation_sync(
for k in engine.klines
]
simulation.trade_log = engine.trade_log
# Save portfolio data
if hasattr(engine, 'current_balance') and engine.current_balance is not None:
simulation.signals = [serialize_signal(s) for s in engine.signals]
db.commit()
finally:
db.close()