Commit Graph

2 Commits

Author SHA1 Message Date
rob 205305fe0e Fix math blocks and add backtest cancellation
- Fix all math block handlers (floor, ceil, min, max, round, sqrt, abs,
  power, modulo, log, ln, trig, mean, median, std_dev, random, clamp,
  factorial) to check inside 'inputs' wrapper for parameters
- Add math, random, statistics modules to strategy execution context
- Add backtest cancellation feature with cancel button in UI
- Fix balances_generators.js to unwrap dynamic_value structures

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-03-16 05:04:03 -03:00
rob 6821f821e1 Implement execution loop, paper persistence, and CI pipeline
Strategy Execution Loop:
- Add tick() method to StrategyInstance for price-driven execution
- Add update() method to Strategies for iterating active instances
- Enable execution loop in received_cdata() to process candle updates
- Add PaperStrategyInstance.tick() with broker price updates

Paper Trading Persistence:
- Add Position.to_dict()/from_dict() for serialization
- Add PaperBroker state persistence (save_state/load_state)
- Add _ensure_persistence_cache() with DB schema migration
- Auto-load/save broker state in PaperStrategyInstance

Runtime Fixes (from Codex review):
- Fix get_user_info() signature mismatch in start_strategy
- Fix live/paper mode handling for stop operations
- Normalize fill event payload (filled_qty/filled_price keys)
- Remove double broker update path (delegate to tick)
- Prevent runtime events from polluting strategy list in UI

CI Pipeline:
- Add GitHub Actions workflow (.github/workflows/test.yml)
- Python 3.12 with TA-Lib dependency
- Syntax checks and 5 critical test suites

Tests: 85 passed
- test_strategy_execution.py (16 tests)
- test_execution_loop.py (17 tests)
- test_paper_persistence.py (19 tests)
- test_backtest_determinism.py (13 tests)
- test_brokers.py (18 tests)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-28 19:48:50 -04:00