Files
foxhunt/crates/backtesting
jgrusewski 448b61d095 refactor: collapse 9-level to 7-level ExposureLevel — eliminate degenerate Flat variants
The 4-branch DQN (direction x magnitude) had 3 degenerate variants
(Short25, Flat, Long25) that all mapped to 0.0 target exposure when
direction=Flat, causing 82% Flat collapse. Collapse these into a
single Flat variant, giving 7 levels (ShortSmall/Half/Full, Flat,
LongSmall/Half/Full) and 63 total factored actions (7x3x3).

- ExposureLevel enum: 9 variants -> 7 (add direction/magnitude/from_dir_mag)
- FactoredAction: 81 -> 63 total actions, from_index/to_index updated
- DQN epsilon-greedy: use from_dir_mag() instead of dir*3+mag indexing
- DQN config: num_actions default 9 -> 7
- PPO action space: 45 -> 63 actions, action masking updated
- Signal adapter CUDA kernel: 5-bin -> 7-bin exposure aggregation
- All tests updated for new variant names and index ranges

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 11:54:09 +02:00
..

backtesting

Strategy backtesting engine for simulating trading strategies against historical market data.

Key Types

  • Backtester — main backtesting engine
  • BacktestConfig — simulation configuration (time range, instruments, slippage, commissions)
  • BacktestResults — performance metrics (Sharpe, max drawdown, alpha, beta, Sortino)

Features

  • Historical data replay from Parquet files (ticks, order book snapshots, candles)
  • Configurable slippage models (fixed, percentage, volume-based)
  • Commission modeling (fixed, percentage, per-contract)
  • Pluggable strategy interface

Usage

use backtesting::{Backtester, BacktestConfig};
let config = BacktestConfig { /* ... */ };
let results = backtester.run(&strategy)?;