Recipe: add a strategy
The 5-minute happy path:
- Subclass
IStrategy(orFrameworkAlgorithm) under alphaswarm/strategies/. - Decorate with
@register("MyName", kind="alpha")from alphaswarm/core/registry.py. - Ship a YAML at
configs/strategies/<my-name>.yamlusing theclass/module_path/kwargsfactory pattern. - Smoke-test:
docker exec alphaswarm-api python -m alphaswarm.cli.cli backtest \
--config configs/strategies/<my-name>.yaml \
--start 2024-01-01 --end 2024-06-30
If the smoke run lands a backtest_runs row with a non-NULL
sharpe, you are done.
Pitfalls
- Forgetting
@register. YAML loaders fail silently; the run errors out asStrategyRegistryMissError. - Putting strategy logic in a route or task. Don't. Routes thin
wrap Celery tasks; Celery tasks thin wrap pure functions under
alphaswarm/strategies/. See AGENTS Don'ts. - Skipping risk overlays. Every strategy ships with a
risk:block in YAML. Without it, the paper-metadata gate refuses to promote the strategy.