Files
foxhunt/services/backtesting_service
jgrusewski 436ddbd589 fix(clippy): Fix 43 unwrap_used violations in services
Applied Agent W4 patterns to services (api_gateway, trading_service, backtesting_service, ml_training_service):

Fixed Patterns:
- Pattern 1: current_dir().unwrap() → expect() (1 fix)
- Pattern 2: duration_since().unwrap() → expect() (2 fixes)
- Pattern 3: Collection.first/last().unwrap() → expect() (5 fixes)
- Pattern 5: serde_json operations → expect() (3 fixes)
- Pattern 6: Duration::from_std().unwrap() → expect() (2 fixes)
- Pattern 7: handle.join().unwrap() → expect() (1 fix)
- Pattern 8: .first()/.last() → expect() (11 fixes)
- Pattern 16: String::from_utf8() → expect() (8 fixes)
- Pattern 19: partial_cmp().unwrap() → unwrap_or(Equal) (9 fixes)
- Pattern 22: SystemTime operations → expect() (1 fix)

Total: 43 violations fixed
All services compile successfully with zero errors

Agent: W17
Phase: Clippy Bulk Fixes (Services)
Related: AGENT_W4_CLIPPY_PATTERNS.md
2025-10-23 15:25:04 +02:00
..

Backtesting Service

Overview

The backtesting_service offers an independent and isolated environment for rigorously testing and validating trading strategies against historical market data. It provides a robust platform for simulating trading performance, analyzing strategy efficacy, and generating comprehensive performance reports before live deployment.

Features

  • Independent Backtesting Service: Operates autonomously, allowing for parallel and isolated strategy evaluations.
  • gRPC API for Backtest Execution: Exposes a clear API for submitting and managing backtesting jobs.
  • Strategy Testing and Validation: Enables comprehensive testing of various trading strategies under different market conditions.
  • Performance Reporting: Generates detailed reports including metrics like P&L, Sharpe ratio, drawdown, and win rate.
  • Data Replay Engine: Accurately replays historical market data, simulating real-world order book dynamics and trade execution.
  • Results Persistence: Stores backtesting results and reports for historical analysis and comparison.

gRPC API

The backtesting_service exposes a gRPC API for initiating and retrieving backtest results. Key endpoints include:

  • RunBacktest - Submit backtest configuration and strategy
  • GetBacktestResults - Retrieve results for completed backtests
  • ListAvailableStrategies - List registered strategies
  • GetBacktestReport - Get detailed performance report

Running the service

To run the backtesting_service binary:

cargo run --bin backtesting_service

Data Requirements

The service requires historical market data in Parquet format:

  • Data should be stored in the configured data directory
  • Supports tick data, order book snapshots, and OHLCV candles
  • Data must include instrument, timestamp, and price/quantity fields

Testing

To run the tests for the backtesting_service crate:

cargo test --package backtesting_service

Documentation

Comprehensive API documentation is available at docs.rs/backtesting_service.