db9936b9ff4cae99707a6cc6835a1cc6c0d09b61
Two-part fix for a class of bugs causing un-normalised features to silently flow into training. (1) data_source mismatch between precompute writer and trainer reader. precompute_features.rs:214,633 hardcoded "ohlcv" train_baseline_rl.rs:582 hardcoded "ohlcv" config/training/dqn-production.toml: data_source = "mbp10" Production runs the trainer with the production profile (data_source = mbp10), but the actual cache lookup hardcoded "ohlcv". Smoke worked by accident (smoke profile is also "ohlcv"). Any future profile with a different data_source silently mismatches → cache MISS → DBN fallback path. Both call sites now hardcode "mbp10" (the canonical production data source per CLAUDE.md). precompute_features adds a `--data-source` CLI override for the rare case a smoke flow needs to regenerate the local "ohlcv" fxcache; default is "mbp10". (2) DBN-fallback path didn't normalise features. precompute_features.rs:629 applies NormStats::normalize_batch on the canonical fxcache write path. The fallback in train_baseline_rl.rs (cache-miss → load DBN files → extract features → upload to GPU) did NOT normalise. Any cache miss (data_source drift, schema-hash mismatch, missing file) silently uploaded RAW features. Raw close prices (~$5180 ES futures) flowed into next_states[:, 0]; the aux next-bar head's label_scale EMA latched onto raw-price magnitude (~5443 vs expected ~1.0 z-score); the shared trunk learned to predict next-bar prices; the policy effectively traded with future-price knowledge → train-h5gxb epoch-0 Sharpe = 141 with 0.32% max-drawdown over 214k bars (impossibly good = oracle leak). DBN fallback now applies the same z-score normalisation unconditionally as defence-in-depth, so a future cache-miss cannot reintroduce raw values into training. Audit entry updated.
Foxhunt
Production HFT trading system in Rust.
Architecture
The workspace contains 32 crates organized as follows:
Core Libraries (16)
| Crate | Purpose |
|---|---|
trading_engine |
Order processing, FIX 4.4, IB TWS, SIMD, RDTSC timing |
risk |
VaR, Kelly, circuit breakers, kill switches, compliance |
risk-data |
Risk data types and shared structures |
trading-data |
Trading data types |
ml |
DQN Rainbow, PPO, TFT, Mamba2, ensemble inference |
ml-data |
ML data types and feature definitions |
data |
Market data ingestion and storage |
backtesting |
Replay engine, strategy tester |
adaptive-strategy |
Ensemble execution, microstructure analysis |
common |
Shared types, resilience, error handling |
storage |
S3 and local model storage |
model_loader |
Model serialization and loading |
market-data |
Market data feed handlers |
database |
PostgreSQL access layer (SQLx) |
config |
Configuration management |
tli |
CLI commands and tooling |
Services (8)
| Service | Purpose |
|---|---|
backtesting_service |
gRPC backtesting service |
broker_gateway_service |
FIX routing, broker connectivity |
trading_service |
Core trading operations |
ml_training_service |
Model training orchestration |
data_acquisition_service |
Market data acquisition |
trading_agent_service |
Autonomous trading agents |
api_gateway |
gRPC API gateway with auth |
web-gateway |
Axum REST + WebSocket gateway |
Frontend
web-dashboard/ -- React 19 + TypeScript + Vite + TradingView charts.
Building
# Check compilation (no PostgreSQL required)
SQLX_OFFLINE=true cargo check --workspace
# Run tests for a specific crate
SQLX_OFFLINE=true cargo test -p <crate> --lib
# Clippy
SQLX_OFFLINE=true cargo clippy --workspace
ML Models
Four production model architectures on Candle v0.9.1 with CUDA:
- DQN Rainbow -- Deep Q-Network with prioritized replay, dueling heads, noisy nets
- PPO -- Proximal Policy Optimization with GAE and LSTM policies
- TFT -- Temporal Fusion Transformer for multi-horizon forecasting
- Mamba2 -- State space model for sequence prediction
Each model has a standalone trainer and a UnifiedTrainable adapter for the hyperopt pipeline.
Infrastructure
- Git: Gitea at
git.fxhnt.ai(Tailscale-only), Scaleway DEV1-S - Observability: OpenTelemetry OTLP (env
OTEL_EXPORTER_OTLP_ENDPOINT) - Database: PostgreSQL with SQLx offline mode for CI
License
Proprietary. All rights reserved.
Description
Languages
Rust
88.2%
Cuda
7.7%
Python
1.3%
Shell
1.1%
PLpgSQL
0.8%
Other
0.8%