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 alphaswarm-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.alphaswarm.core.registry.resolvecan't find the alias and the run errors out withKeyError: Cannot resolve class reference: '<MyName>'. - 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 the paper-metadata gate. Promoting a bot/strategy to a
paper session requires a valid
model_urn+pipeline_urnpair resolvable inentity_aspects(model statusProductionorStaging) — see Concept: paper metadata gate. Risk limits for a bot live inBotSpec.risk_layer, not in the strategy YAML.