Data Storage & Logging

Every bar, every signal, every position update — logged permanently.
Transparent. Reproducible. Audit-ready.

Daily Price Data Format

All historical and live price bars are stored as flat JSON objects.
One file per symbol or per period — simple, compact, easy to query.

{
  "open": 171.09,
  "high": 172.42,
  "low": 170.52,
  "close": 171.84,
  "volume": 45143500.0,
  "adj_high": 171.7461879825,
  "adj_low": 169.8552878365,
  "adj_close": 171.1641,
  "adj_open": 170.4230658923,
  "adj_volume": 45143488.0,
  "split_factor": 1.0,
  "dividend": 0.0,
  "symbol": "AAPL",
  "exchange": "XNAS",
  "date": "2023-05-24T00:00:00+0000"
}

Trade & Position Log Format

Real-time simulation / live trading logs are line-based and timestamped.
Every entry, exit, stop update and PnL calculation is recorded.

Date: 2025-12-10 | Close: 687.57 | In Long: True
Stop Loss: 676.85 | Implied Stop: 652.53
Unrealized PnL: 0 | Shares: 69 | Counter: 1
Entered long position!
------------------------------
Date: 2025-12-17 | Close: 671.4 | In Long: False
Stop Loss Hit: 676.85
Realized PnL: 2172.38 | Counter: 0
Exited long position!
------------------------------
Date: 2026-02-05 | Close: 677.62 | In Long: False
Stop Loss Hit: 684.54
Realized PnL: 4257.94 | Counter: 0
Exited long position!
------------------------------
Total PNL: 4257.94
Why this logging style?

Designed for clarity, reproducibility and easy debugging.

  • Line-per-event format → readable in console & log files
  • Every important state change is captured (entry, stop, exit, PnL)
  • Final summary line makes performance instantly visible
  • Compatible with file tailing, grep, or simple parsing scripts
Fields in position logs explained
Field Example Meaning
Date 2025-12-10 Bar / decision date
Close 687.57 Closing price of the bar
In Long / In Short True / False Current position direction
Stop Loss 676.85 Current fixed stop level
Implied Stop 652.53 Dynamic trailing stop (10-day low/high)
Unrealized PnL 0 Current open profit/loss
Shares 69 Current position size
Counter 1 Internal state counter (position active)
Entered / Exited long / short position Trade action taken
Realized PnL -2172.38 Closed trade profit/loss
How data is used
  • Re-run simulations with exact same inputs → perfect reproducibility
  • Calculate metrics (win rate, profit factor, drawdown) post-run
  • Visualize equity curve, trade distribution, stop behavior
  • Debug strategy logic by replaying logs
  • Export to CSV/JSON for external analysis (pandas, backtrader, etc.)

Data Flow & Storage

Daily OHLCV
→ stored as
JSON lines / files
Position Engine
→ generates
Trade / PnL Logs
Audit + Analysis + Replay

Every decision traceable. Every result verifiable.