1d889d2de994af63c91751f6888d2f1c3ecf463d
After A1 (commit045850e8f) the controller fires every event. Without smoothing, target lots would oscillate as alpha probabilities jitter event-to-event, generating hyperactive spread-bleed from back-and-forth trades. Ships per spec §4.2 and §3.7: Wiener-α adaptive EMA on max-conviction- across-horizons. Formula: α_raw = diff_var / (diff_var + sample_var + ε) α_active = max(α_raw, 0.4) per pearl_wiener_alpha_floor_for_nonstationary ema = α_active × new + (1 − α_active) × prev First-observation bootstrap: prev_ema == 0 → replace directly per pearl_first_observation_bootstrap. Three new device slots (per-backtest): - conviction_ema_d: smoothed conviction (used for final-aggregate rescale) - conviction_diff_var_ema_d: second-order EMA, drives adaptive α - conviction_sample_var_ema_d: second-order EMA, drives adaptive α Architectural choice: rescale at the final aggregate (final_size *= conv_ema / raw_max_conv), not at per-horizon sig_mag. Per-horizon sizing keeps raw |alpha-0.5|*2 so horizons with no signal (alpha=0.5) contribute zero — the spec §4.2 "smoothed conviction" is a unified gain over the aggregate, not a substitute for per-horizon signal strength. At bootstrap the scale is exactly 1.0 (raw_max_conv == conv_ema) so the very first decision is bit-identical to the pre-A2 kernel. Direction recovery (sign of alpha-0.5) remains per-horizon — genuine reversals respond at event rate. Threaded through both decision_policy_default and decision_policy_program kernels' signatures and launches in sim/mod.rs. Full multi-horizon conviction *aggregation* (spec §4.4) remains Phase B; A2 ships ONLY the smoothing operator on the existing scalar conviction. Pure on-device: no memcpy_htod / dtoh / dtov / synchronize in hot path. Single test-only DtoH accessor (read_conviction_ema) for unit-test inspection of the smoothed value. Tests: - conviction_ema_smooths_micro_oscillations — sentinel→bootstrap→bounded EMA across 10 alternating high/low all-bullish alpha drives; direction stable. - conviction_ema_does_not_lag_reversals — sign flip in alpha → target side flips next event. - All 22 stop_controller + 5 decision_floor_coldstart + 3 threshold_and_cost + parallel_sim + ring3_replay + trainer_parity + 6 fuzz tests pass. - 2 lob_sim_fixtures tests (fix_decision_alpha_buy_close, fix_decision_program_h4_only) were already failing on baseline045850e8fpre-A2; not a regression from this commit. 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%