a5ee49e8ab3b6d7c06c7f01f2ffeadd57c84fb5d
The plan asks for a separate `hold_cost_scale_compute_kernel.cu` to
host the two-sided multiplicative ramp 1.05/0.95 controller for
`HOLD_COST_SCALE_INDEX = 513`. Reality: the controller is already
implemented inside Phase 1.3's `sp20_controllers_compute_kernel.cu`
lines 175-194 (block 6 of the 6-controller fused kernel) and tested
end-to-end at `sp20_controllers_compute_test::hold_cost_scale_two_
sided_ramp` covering all 5 cases (ramp up, ramp down, deadband, upper-
clamp, lower-clamp).
Splitting it back into a separate kernel would:
1. Break the in-thread `tgt` reuse optimization documented in the
fused kernel header (sp20_controllers_compute_kernel.cu:73-78);
forces 1 extra ISV read per step.
2. Add separate launch + cubin + Rust launcher boilerplate for
~20 LoC of kernel logic.
3. Force the production caller (gpu_experience_collector.rs:6549)
to make TWO controller-kernel launches per step.
Per `feedback_no_partial_refactor` ("when a contract changes, every
consumer migrates atomically") + `feedback_no_quickfixes`, the
correct response is errata, not a partial-refactor split.
This commit also documents 4 additional Phase 3 plan-vs-reality gaps
that emerged during implementation review (Gaps 8-11):
- Gap 8: Task 3.3's target_hold_pct controller is already wired in
Phase 1.3 + has a unit test; Task 3.3 commit will add a behavioral
integration test, NO production code changes.
- Gap 9: hold_baseline_buffer layout is `[N_envs, 30]` row-major
(per-env), NOT a single global ring as the spec phrasing implied
— the kernel is per-env-parallel and per-trade attribution
requires per-env stride.
- Gap 10: `PS_ENTRY_BAR` does NOT exist; `PS_HOLD_TIME` (slot 10) +
`segment_hold_time` (already in scope at trade close) suffice.
No new state slot needed — keeps PS_STRIDE = 43 contract stable.
- Gap 11: Task 3.4 plan refers to `GpuBatchPtrs` but that struct
is in `crates/ml-dqn/src/gpu_replay_buffer.rs`. The collector
struct is `GpuExperienceBatch`. Both need the new `aux_conf`
field + the ring-buffer scatter/gather column in between.
Plan-level errata only; no code touched in this commit. Implementation
of the actual Phase 3 work continues in Tasks 3.2 / 3.3 / 3.4.
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%