← Trading Systems
Python · Backtesting · Live data

Backtesting & Algo Charting App

A futures research-and-execution stack (~46k lines across ~110 files): TradingView-style charts via lightweight-charts-python, live bar data from the Rithmic API, a market-structure backtest engine, XGBoost trade filtering with leakage-aware methodology, live bracket-order routing through two brokers, and native C++ ACSIL orderflow studies for Sierra Chart.

Python lightweight-charts-python Rithmic API (protobuf) XGBoost / scikit-learn Pandas SQLite C++ / ACSIL
Lightweight Charts · desktop UI
⚡
Built with agentic AI. Development on this project runs through multi-agent Claude Code workflows — developer → independent-reviewer cycles with evidence gates, batched into unattended runs that execute overnight and resume from committed ledgers. How the agent system works →

Project overview

Historical OHLCV lives in SQLite; a backtest engine computes market structure (pivots, unbroken levels, session high/low for NY, London and Asia) over it, and the same code path drives live trading: bars stream in from Rithmic, the chart updates in place, and bracket orders route to Rithmic or Sierra Chart when a strategy signals. The desktop chart offers timeframes, indicators, drawing tools and a "go live" mode; strategy results export to Excel with per-trade statistics.

Market-structure engine

  • An "unbroken level" engine tracks swing pivots per direction and timeframe, maintains the levels price hasn't broken, and emits structure/retest events.
  • A streaming bar aggregator builds arbitrary timeframes (including renko) tick-by-tick from one source stream — identical for backtests and live.
  • Trade accounting supports partial exits, running max-runup/max-drawdown, and per-trade feature export.

Leakage-aware ML trade filtering

  • XGBoost classifiers on "did this trade profit", with splits grouped by futures contract and a whole held-out contract as out-of-time data.
  • The probability cutoff is chosen on validation only; calibration curves are part of every run.
  • Before a feature may exist: mutual information, a stump AUC with bootstrap 95% CI, and a label-permutation p-value. Feature manifests are serialized next to each model so live inference can never silently reorder columns.

Dual-broker live execution

  • Bracket orders (entry + SL + TP as OCO) submitted through Sierra Chart's SCBridge, or through Rithmic's R|Protocol directly — protobuf over TLS WebSocket.
  • The live consumer slices only genuinely-new bars from each overlapping realtime frame with a binary-search watermark — idempotent under duplicate pushes by construction.
  • Backtest entries are code-generated into both a Pine Script indicator and a C++ study, so simulated fills can be visually reconciled on TradingView and Sierra charts.

Native C++ orderflow studies

  • ACSIL studies read Sierra Chart's binary intraday file directly with shared buffered I/O — fixing a documented production deadlock that starved the live tick writer.
  • A bar is only finalized once the file provably contains the next bar's open, so a lagging disk flush can never truncate it.
  • Volume-anomaly detection scores bars against context-adaptive baselines (the conditioning stays private); every bar is replayed tick-by-tick and the first signal print is latched permanently, so recalculation reproduces exactly what a live watcher saw.