d1638959d372564ca73c9a87fab8936dbd4d3367
Single-file fix to `compute_epoch_financials`: remove the `if n_returns_f >= bars_per_year` short-rollout fallback that left v2 semantics in place for sub-year rollouts. For Foxhunt's volume bars, `bars_per_day ≈ 34_496` → `bars_per_year ≈ 8.69M`, while a training epoch produces `n_returns ≈ 4.10M`. The guard fired on every production epoch, so the v3 CAGR fix was a no-op. Diagnosis chain: - v3 commit (2937da889) merged the n_returns >= bars_per_year guard - Smoke v4 (commit62b5a50e8, workflow train-frv8x) epoch 1 showed Return=+2.963e2% — bit-identical to v1's pre-fix output - Hypothesis 1 (cache poisoning): ruled out — ensure-binary log shows "Cache MISS: compiling binaries for 62b5a50e8" and ml crate was recompiled fresh - Hypothesis 2 (different commit): ruled out — workflow params confirm commit-sha =62b5a50e8= current HEAD - Hypothesis 3 (bars_per_year mismatch): confirmed — v4 log emits "Bars per day (from data): 34496" which makes bars_per_year > n_returns and triggers the v2 fallback inside the v3 branch Fix: unconditional CAGR. The log-space clamp [-23, +20] bounds the display in all edge cases (tests with tiny n_returns extrapolate aggressively; the clamp caps at exp(20) - 1 ≈ +4.85e8%). Expected v5 epoch 1 Return: ~+1.770e3% (was +2.963e2% under v4). The new value is the *actual annualized* projection: 1377% over a 0.47-year rollout. Overfit cycles cap at +4.85e8% (was +e19%). Tests: - cargo test -p ml --lib financials → 7/7 - Sign-only assertions in test cases (all > 0.0) — no regressions Files changed: - crates/ml/src/trainers/dqn/financials.rs: 1 conditional removed, comment block updated with v3 → v3.1 history - docs/dqn-wire-up-audit.md: diagnosis + fix entry for 2026-05-11 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…
…
…
…
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%