6061a190b821b24a204c4b6da0dfcb4cd887def4
Replaces the symmetric target stretch (v1, removed) with an asymmetric
per-sample reward bias applied to `reward` BEFORE the `+ gamma*z_j` term
in the Bellman projection. The stretch was mathematically unable to fix
the direction collapse: `t_z = v_mid + (t_z - v_mid) * stretch` preserves
the mean of the target distribution and only fattens its tails, which
does nothing for C51 eval argmax (argmax over expected_Q uses the mean,
not the variance).
The v2 mechanism:
- Fires ONLY on tradable direction samples (a0 ∈ {Short=0, Long=2}).
- Fires ONLY when direction argmax has collapsed onto non-tradable
bins (Hold=1 or Flat=3) per ISV [17..20] Q-mean EMAs.
- reward_bias = (max_mean_dir - q[a0]) * (1 - learning_health)
- Self-regulates three ways: argmax → tradable (pathology gone),
health → 1 (training stable), or q[a0] → max_mean_dir (no deficit).
Signal wiring (all pre-existing):
- ISV [17..20]: q_s / q_h / q_l / q_f per-bin EMAs
- ISV [12]: learning_health
- Populated by `q_dir_bin_means_reduce` + `isv_signal_update` wiring
landed in commits fa8d54661 / 810b3c570.
Empirical status (local RTX 3050 Ti, 3 smoke runs):
- "Pathology argmax" regime (run v2#1, argmax=Flat q=3.08):
EVAL_DIR_DIST Short=1.000 Hold=0 Long=0 Flat=0 — Hold+Flat=0 ✓
- "Tight-cluster" regime (run v2#2, argmax=Long q_l=-0.149 tied with
others near -0.15): mechanism does NOT fire, and eval collapses
to Flat=0.592 Hold=0.280 anyway — Hold+Flat=0.872 ✗.
The tight-cluster regime is a real hyper-variance symptom previously
observed on HEAD fa8d54661 (Hold+Flat ∈ {0.000, 0.847, 0.452}). The
direction-bin Q-means cluster tightly within the |Q|-scale so neither
argmax-in-aggregate nor spread_deficit reliably flags the pathology,
even though per-state eval strict-argmax still collapses onto Flat.
Follow-up (Task 2.Y-ext v3): drop the `argmax ∈ {Hold, Flat}` gate and
always lift tradable bins by `max(0, max_pathology_q - q[a0] + α *
q_dir_abs_ref) * (1 - health)` with an architectural margin α (e.g.
0.25) so the mechanism fires whenever tradable bins aren't clearly
leading the pathology bins. v3 must preserve v2's self-regulation
(mechanism fades when tradable clearly wins AND when health = 1).
Per feedback_adaptive_not_tuned.md: the mechanism remains signal-driven
(ISV Q-means + health) with no hard-coded numeric knobs; its amplitude
scales with the observed Q-values.
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%