5ebebc564ae67f9c587518c77f18782b71a66681
Plan 3 Task 6b. Portfolio-state tail-append: - PS_REGIME_SHIFT_BAR = 40 (hold_time of first detected regime shift, 0 if none) - PS_STRIDE 40 → 41 - All 6 hardcoded-stride sites migrated in lockstep Detector (experience_kernels.cu): - Adaptive threshold = clamp(0.25 × |clamp(sharpe, -2, 2)|, 0.05, 0.5) - Fires first bar where |regime_now - PS_PLAN_ENTRY_REGIME| > threshold - First-shift-only (short-circuits on non-zero PS_REGIME_SHIFT_BAR) - Uses new ISV_SHARPE_EMA_IDX = 22 macro in state_layout.cuh Consumer (segment_complete block): - bars_late_frac = clamp(bars_late / hold_time, 0, 1) - penalty = shaping × conviction × bars_late_frac × |reward| - All multiplicands except |reward| in [0,1]; max penalty = |reward| - reward -= penalty; rc[5] -= penalty (cancels with B.2/C.4/D.4a at other (i,t) slots; ISV[68] REWARD_BONUS_EMA shows net) - Consumer resets PS_REGIME_SHIFT_BAR after use **Iteration history.** First pass multiplied by ISV[Q_DIR_ABS_REF] (~5–50, an absolute Q-magnitude) AND |reward| — produced penalties 5–50× the reward, destabilising training (smoke: Return swings ±300–900%, Sharpe oscillating wildly). Root cause: Q_DIR_ABS_REF is an absolute magnitude, not a [0,1] coefficient; B.1 uses it as a DENOMINATOR to normalize q_range, not as a multiplier on an already-unbounded signal. Fix: drop q_scale, keep |reward| as the only unbounded factor. Smoke now passes cleanly with fold-2 best Sharpe 117.92 (up from T6a's 100.10). No new ISV slot. 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%