pybroker-strategy-creator
Installation
SKILL.md
PyBroker Strategy Creator
Overview
Create practical PyBroker strategy code from user intent while preserving backtest hygiene: no lookahead leakage, explicit sizing, clear risk controls, and locally valid PyBroker API usage.
Workflow
- Extract the strategy spec: universe, data source, date range, timeframe, long/short permissions, entry and exit rules, sizing, stops, ranking, rebalancing cadence, model training needs, and desired output file/notebook.
- Ask only for missing blockers. If details are absent but noncritical, make conservative assumptions and state them in the final answer or code comments.
- Read
references/wiki-index.mdto choose the smallest relevant wiki page. For nontrivial strategy work, also readreferences/pybroker-patterns.md. - Build a complete runnable strategy surface:
- create a
StrategyConfigwhen cash, fees, position limits, delays, exits, or returned signals/stops matter - define indicators with
highest,lowest,returns, orindicator - define model sources with
pybroker.modelonly when training or loading predictions is part of the request - write execution functions that use completed-bar arrays such as
ctx.close[-1], guard lookbacks withctx.barsorwarmup, and set at most one order side per symbol per bar - add executions with
Strategy.add_execution - run
backtestfor a single train/test pass orwalkforwardfor model/walk-forward evaluation
- create a
- Validate the produced code as far as the environment allows. At minimum, run syntax checks for created Python files. Run tests or a small local-data backtest when the repo and data make that practical.