[Backend] Simulate Engine - Real-time Signal Detection #19

Merged
shoko merged 1 commits from fix/issue-8 into main 2026-04-08 14:57:29 +02:00
Owner

Summary

Implement simulate engine for real-time signal detection via REST polling as described in issue #8.

Changes Made

Modified files:

  • src/backend/app/services/simulate/engine.py - Full SimulateEngine implementation:

    • REST polling for current prices using AveCloudClient
    • Condition matching for real-time data (price_drop, price_rise, volume_spike, price_level)
    • Configurable check interval (default 60s for free tier)
    • Signal logging with user-initiated start/stop
    • Background execution without blocking
  • src/backend/app/api/simulate.py - Simulation API endpoints:

    • POST /api/bots/{id}/simulate - Start simulation (async, background execution)
    • GET /api/bots/{id}/simulate/{run_id} - Get simulation status/signals
    • GET /api/bots/{id}/simulations - List all simulations for bot
    • POST /api/bots/{id}/simulate/{run_id}/stop - Stop running simulation
    • JWT authentication and ownership validation on all endpoints
    • Free tier enforces 60s minimum check interval
  • src/backend/app/db/schemas.py - Added check_interval field to SimulationCreate

Features Implemented

  1. Real-time REST Polling - Fetches current token prices from AVE Cloud API
  2. Condition Matching - Supports price_drop, price_rise, volume_spike, price_level conditions
  3. Configurable Interval - Default 60s for free tier, pro tier can use shorter intervals
  4. Signal Generation - Logs signals when conditions are met
  5. Async/Background Execution - Simulations run in background without blocking
  6. Auto-execute Flag - Future support for automatic signal execution
  7. Simulation Signal History - Signals stored in database via Signal model

User Notice

Free tier users get REST polling every 60s. Pro tier users can use shorter intervals.

Dependencies

  • Depends on issue #7 (Backtest Engine) which was merged in PR #18

Fixes #8

## Summary Implement simulate engine for real-time signal detection via REST polling as described in issue #8. ### Changes Made **Modified files:** - `src/backend/app/services/simulate/engine.py` - Full SimulateEngine implementation: - REST polling for current prices using AveCloudClient - Condition matching for real-time data (price_drop, price_rise, volume_spike, price_level) - Configurable check interval (default 60s for free tier) - Signal logging with user-initiated start/stop - Background execution without blocking - `src/backend/app/api/simulate.py` - Simulation API endpoints: - POST /api/bots/{id}/simulate - Start simulation (async, background execution) - GET /api/bots/{id}/simulate/{run_id} - Get simulation status/signals - GET /api/bots/{id}/simulations - List all simulations for bot - POST /api/bots/{id}/simulate/{run_id}/stop - Stop running simulation - JWT authentication and ownership validation on all endpoints - Free tier enforces 60s minimum check interval - `src/backend/app/db/schemas.py` - Added `check_interval` field to SimulationCreate ### Features Implemented 1. **Real-time REST Polling** - Fetches current token prices from AVE Cloud API 2. **Condition Matching** - Supports price_drop, price_rise, volume_spike, price_level conditions 3. **Configurable Interval** - Default 60s for free tier, pro tier can use shorter intervals 4. **Signal Generation** - Logs signals when conditions are met 5. **Async/Background Execution** - Simulations run in background without blocking 6. **Auto-execute Flag** - Future support for automatic signal execution 7. **Simulation Signal History** - Signals stored in database via Signal model ### User Notice Free tier users get REST polling every 60s. Pro tier users can use shorter intervals. ### Dependencies - Depends on issue #7 (Backtest Engine) which was merged in PR #18 ## Related Issue Fixes #8
shoko added 1 commit 2026-04-08 13:26:34 +02:00
Implement simulate engine for real-time signal detection via REST polling.

Changes:
- SimulateEngine service with configurable check interval (default 60s for free tier)
- REST polling for current prices using AveCloudClient
- Condition matching for real-time data (price_drop, price_rise, volume_spike, price_level)
- Signal logging with user-initiated start/stop
- Simulation API endpoints:
  - POST /api/bots/{id}/simulate - Start simulation
  - GET /api/bots/{id}/simulate/{run_id} - Get status/signals
  - GET /api/bots/{id}/simulations - List all simulations
  - POST /api/bots/{id}/simulate/{run_id}/stop - Stop simulation
- Updated SimulationCreate schema with check_interval field
- Free tier limited to 60s minimum check interval
- Signals stored in database for simulation signal history

Depends on issue #7 (Backtest Engine) which was merged in PR #18
han approved these changes 2026-04-08 14:56:42 +02:00
han left a comment
First-time contributor

lgtm

lgtm
shoko merged commit a59a1ccd97 into main 2026-04-08 14:57:29 +02:00
Sign in to join this conversation.
No Reviewers
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: shoko/randebu#19