Strategy catalogue
Three layers, each with one job.
| Layer | Where | Holds |
|---|---|---|
| Write-up | docs/docs/research/strategies/<strategy_code>.md (copy _template.md) | Idea, exact rules, parameters, costs, results of the base case and every variant, verdict |
| Registry | st_master (strategies/models.py), read API GET /api/strategies | One row per strategy and per variant: scorecard, metrics, out-of-sample metrics, score, status, link to the write-up |
| Raw results | bt_run / bt_trade for TBS, else reports/strategies/<strategy_code>/ (daily P&L CSV or Parquet) | Trades and curves; linked by run_ref |
st_master catalogue columns (migration e1c7a94b2d35)
| Column | Meaning |
|---|---|
parent_id, variant_label | A variant is a child row of its base strategy (parent_id null = base). Each variant keeps its own param_hash |
scorecard | tbs, intraday, swing, longterm or arbitrage - which ranking table it belongs to (check constraint) |
metrics, oos_metrics | JSONB scorecard numbers for the tested range and for the out-of-sample part |
score, rank_note | Rank value inside the scorecard and why |
doc_path, run_ref | The write-up and the raw result |
tested_from, tested_to | Tested range |
revision, revision_note | Revision number of the strategy definition (starts at 1) and what changed in it |
status stays the lifecycle: candidate, paper, live, retired. Scalping is horizon = scalp (new st_group row, run
python -m strategies.seed_strategy_classification).
Revisions (migration a4f7c2e81b09)
A result only means something for the rules it was run with, so every change of rules or parameters is a new revision.
st_master always holds the current revision; every earlier one is kept in st_revision (strategy_id, revision, note,
canonical_json, param_values, metrics, doc_path; unique per strategy and revision).
from strategies import catalogue
catalogue.register(code, name, symbol, timeframe, hypothesis, "arbitrage", params, metrics=..., score=...) # revision 1, or refresh the
# results if the params are the same
catalogue.new_revision(code, "what changed", params=new_params, metrics=...) # archives the current one, revision + 1
catalogue.revisions(code) # history, oldest first, current last
Register with other parameters under an existing code raises an error; use new_revision. The strategy's write-up repeats the
history in a Revision history table.
API
GET /api/strategies?scorecard=swing&status=candidate&base_only=true- ranked by score, best first.GET /api/strategies/{code}- the strategy with its variants.GET /api/strategies/{code}/revisions- every revision (archived ones and the current one).
Both read only; rows are written by the backtest scripts. Developer rank or higher.