You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-`sanitize_numeric(value)`: Guards against NaN/Infinity forJSON serialization
343
+
344
+
Key constants:
345
+
-`INF_CAP = 999999.99` — shared ceiling for infinite values across the codebase
341
346
342
347
### PnL Calculator (`pnl.py`)
343
348
344
349
Calculates profit/loss metrics:
345
350
346
-
-`calculate_pnl(trades)`: Returns DataFrame with cumulative PnL
351
+
-`calculate_pnl(trades)`: Returns DataFrame with cumulative PnL (uses `Decimal` accumulation to avoid float drift)
347
352
-`calculate_global_pnl_summary(trades)`: Aggregate statistics with currency separation -- top-level totals use real-money currencies (USD/USDC) only; play-money (MANA) reported separately under `by_currency`; also includes `by_source` breakdown
-`calculate_market_pnl(trades)`: Breakdown by market
@@ -356,6 +361,11 @@ Metrics calculated:
356
361
- Total invested/returned
357
362
- Per-currency and per-source breakdowns
358
363
364
+
**Numeric precision notes:**
365
+
- Cumulative PnL is computed using `decimal.Decimal` accumulation, then stored back as`float`.
366
+
- Infinite values (e.g. profit factor with zero losses) are capped at `INF_CAP` (999999.99), defined in`trade_loader.py`and shared across the codebase.
367
+
-DB monetary columns use `Numeric(18,8)` to reduce rounding in storage.
368
+
359
369
### Filters (`filters.py` + `trade_filter.py`)
360
370
361
371
Advanced filtering capabilities:
@@ -404,12 +414,14 @@ Four chart types with different use cases:
404
414
405
415
### MCP Server (`prediction_mcp/`)
406
416
407
-
Model Context Protocol server providing 18 tools across 7 modules:
417
+
Model Context Protocol server implementing all three MCP primitives:
0 commit comments