[Backend] Backtest Engine - Historical Data Replay #7

Closed
opened 2026-04-06 00:29:33 +02:00 by shoko · 0 comments
Owner

Overview

Implement the backtest engine for historical strategy testing.

Dependencies

  • Requires Chat Interface + CrewAI (issue #6) to be completed first

Tasks

  • Create backtest engine service
  • Fetch historical klines from AVE Cloud API
  • Implement condition matching logic
  • Create signal generation logic
  • Implement portfolio simulation
  • Calculate metrics: total_return, win_rate, max_drawdown, sharpe_ratio
  • Create backtest API endpoints
  • Add async/background backtest execution
  • Store results in backtests table

API Endpoints

  • POST /api/bots/{id}/backtest - Start backtest
  • GET /api/bots/{id}/backtest/{run_id} - Get status/results
  • GET /api/bots/{id}/backtests - List all backtests
  • POST /api/bots/{id}/backtest/{run_id}/stop - Stop backtest

Algorithm

  1. Parse strategy_config for conditions + actions
  2. Fetch historical klines from AVE Cloud
  3. For each time point, check conditions
  4. If met, generate signal and simulate portfolio
  5. Calculate final metrics and store results

Metrics to Calculate

  • total_return %
  • win_rate %
  • total_trades
  • max_drawdown %
  • sharpe_ratio
## Overview Implement the backtest engine for historical strategy testing. ## Dependencies - Requires **Chat Interface + CrewAI** (issue #6) to be completed first ## Tasks - [ ] Create backtest engine service - [ ] Fetch historical klines from AVE Cloud API - [ ] Implement condition matching logic - [ ] Create signal generation logic - [ ] Implement portfolio simulation - [ ] Calculate metrics: total_return, win_rate, max_drawdown, sharpe_ratio - [ ] Create backtest API endpoints - [ ] Add async/background backtest execution - [ ] Store results in backtests table ## API Endpoints - POST /api/bots/{id}/backtest - Start backtest - GET /api/bots/{id}/backtest/{run_id} - Get status/results - GET /api/bots/{id}/backtests - List all backtests - POST /api/bots/{id}/backtest/{run_id}/stop - Stop backtest ## Algorithm 1. Parse strategy_config for conditions + actions 2. Fetch historical klines from AVE Cloud 3. For each time point, check conditions 4. If met, generate signal and simulate portfolio 5. Calculate final metrics and store results ## Metrics to Calculate - total_return % - win_rate % - total_trades - max_drawdown % - sharpe_ratio
shoko added this to the Phase 1 - Core MVP milestone 2026-04-06 00:29:33 +02:00
shoko added the backendenhancementAI/ML labels 2026-04-06 00:29:33 +02:00
shoko closed this issue 2026-04-08 13:21:57 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: shoko/randebu#7