Shows what happened at each candle:
- BUY/SELL/HOLD actions
- Price at that time
- Reason for action
- Entry price for positions
Trade log is stored in DB and displayed in frontend.
The simulation engine completes in seconds, but the background task wasn't
saving klines to DB. Now we fetch klines first synchronously so the user
can see the price chart immediately after starting a simulation.
Also marks any stuck 'running' simulations as 'stopped'.
Unit tests (13 passing):
- Kline fetching and processing
- Price drop condition triggers buy
- Stop loss and take profit risk management
- Multiple positions (buy again after sell)
- Max candles limit
- Stop interruption handling
Frontend:
- SignalChart now shows price movement even before signals
- Shows candle count even with no signals
- Chart displays buy/sell markers when signals exist
- Canvas-based chart with gradient fill
Backend:
- Simulation stores klines for chart display
- Returns klines in API response
- Simplified simulation run (no periodic saving)
- Fetch historical klines once from AVE API (10 CU per request)
- Process each candle as a time step
- Limit to 500 candles max per simulation
- No continuous polling - processes all data in seconds
- Frontend now selects kline interval (1m, 5m, 15m, 1h)
- Much more efficient API usage
- Status was only updated if engine was in memory (race condition)
- Now always sets status to 'stopped' in DB
- Returns 'stopped' instead of 'stopping'
- Cleaned up 3 stale running simulations in DB
Frontend:
- Load simulations now prioritizes running simulation over most recent
- Clear signals before loading new simulation
Backend:
- When starting new simulation, stop any existing running simulation first
- Previously would return existing running simulation (confusing UX)
- No duration limit - runs forever until user stops
- Only 1 running simulation per bot (returns existing if already running)
- Always paper trade (no auto-execute option)
- Removed Pro upgrade banner
- Removed duration and auto-execute config options
- Simplified API to only require token, chain, check_interval
Frontend:
- Added duration selector (1min, 5min, 10min, 30min)
- Added check interval selector (10s, 30s, 60s)
Backend:
- Signals are now saved to database every 30 seconds during simulation
- Can stop simulation early to see partial signals
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