Codebase audit identified 23 findings across 4 dimensions (production safety, code health, deployment readiness, test quality). This commit fixes all of them. Broker execution layer (was entirely stubbed): - Real IBKR TWS client via ibapi crate (950+ lines, feature-gated) - ICMarkets ctrader-openapi now always-on (removed feature flag) - Real broker routing with health monitoring and exponential backoff reconnect - Validated against live IB Gateway Docker (6/6 connectivity tests pass) Deployment blockers: - Fixed 6 broken Dockerfiles (removed COPY foxhunt-deploy) - Created foxhunt K8s namespace, secret templates, migration job - Added liveness probes to all 7 K8s services - IB Gateway manifest (ghcr.io/gnzsnz/ib-gateway:stable) - IBKR credentials in Scaleway Secret Manager via Terragrunt - Fixed port collisions and mismatches across services Production safety (9 critical + 6 high/medium fixes): - Asset-class-specific VaR volatility (not flat 2%) - Real parametric VaR with z-score 95th percentile - Kyle's lambda regression (100-bar rolling window) - Per-feature running statistics from historical data - VWAP-based slippage reference, regime duration tracking - Real Databento JSON parsing for OHLCV/Trade/Quote Code health: - Removed #![allow(dead_code)] from ml, data, config - Fixed log:: → tracing:: in 4 production files - Removed dead workspace deps (ratatui, crossterm) Verified: cargo check --workspace (0 errors), trading_engine 330 tests pass. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Backtesting Service
Overview
The backtesting_service offers an independent and isolated environment for rigorously testing and validating trading strategies against historical market data. It provides a robust platform for simulating trading performance, analyzing strategy efficacy, and generating comprehensive performance reports before live deployment.
Features
- Independent Backtesting Service: Operates autonomously, allowing for parallel and isolated strategy evaluations.
- gRPC API for Backtest Execution: Exposes a clear API for submitting and managing backtesting jobs.
- Strategy Testing and Validation: Enables comprehensive testing of various trading strategies under different market conditions.
- Performance Reporting: Generates detailed reports including metrics like P&L, Sharpe ratio, drawdown, and win rate.
- Data Replay Engine: Accurately replays historical market data, simulating real-world order book dynamics and trade execution.
- Results Persistence: Stores backtesting results and reports for historical analysis and comparison.
gRPC API
The backtesting_service exposes a gRPC API for initiating and retrieving backtest results. Key endpoints include:
RunBacktest- Submit backtest configuration and strategyGetBacktestResults- Retrieve results for completed backtestsListAvailableStrategies- List registered strategiesGetBacktestReport- Get detailed performance report
Running the service
To run the backtesting_service binary:
cargo run --bin backtesting_service
Data Requirements
The service requires historical market data in Parquet format:
- Data should be stored in the configured data directory
- Supports tick data, order book snapshots, and OHLCV candles
- Data must include instrument, timestamp, and price/quantity fields
Testing
To run the tests for the backtesting_service crate:
cargo test --package backtesting_service
Documentation
Comprehensive API documentation is available at docs.rs/backtesting_service.