Create a complete dual-mode strategy file from a template.
Arguments
Parse $ARGUMENTS as: template symbol exchange interval
$0 = template (e.g. ema-crossover, rsi, supertrend, donchian, macd, opening-range, atr-breakout, bb-squeeze, ml-logistic, ml-xgb, pairs-trading, regime-trend, event-driven)
$1 = symbol (e.g. SBIN, RELIANCE, NIFTY). Default: template's catalog default
$2 = exchange (e.g. NSE, NSE_INDEX, NFO). Default: template's catalog default
$3 = interval (e.g. 1m, 5m, 15m, D). Default: template's default
If no arguments, ask the user which template they want. See algo-expert/rules/strategy-catalog.md.
Required prompts before generation
After parsing arguments, ASK the user (do not assume defaults silently):
Indicator library: (1) openalgo [default] (2) talib
- Default openalgo. talib's user must confirm explicitly.
- Specialty indicators (Supertrend, Donchian, Ichimoku, HMA, KAMA) always use openalgo regardless.
Execution type - default depends on template (see strategy-catalog.md):
(1) end-of-candle (eoc) - signal at bar close, MARKET on next bar (default for most)
(2) real-time limit (limit) - tick-driven LIMIT placement (default for atr-breakout)
(3) stop-trigger (stop) - broker-side SL/SL-M (default for opening-range)
Tell the user the recommended default for their template and let them override.
Instructions
- Read
algo-expert/rules/unified-strategy-pattern.md, mode-toggle.md, and execution-types.md.
- Read the matching template at
algo-expert/rules/assets/<template>/strategy.py as the starting point.
- Create
strategies/<template>_<symbol>/ directory if not present.
- Copy the template into
strategies/<template>_<symbol>/strategy.py and:
- Replace
SYMBOL, EXCHANGE, INTERVAL constants with user values
- Set
INDICATOR_LIB to user's choice ("openalgo" or "talib")
- Set
EXECUTION_TYPE to user's choice ("eoc", "limit", "stop")
- Update
STRATEGY_NAME to <template>_<symbol> (default; can be overridden by env)
- Adjust
PRODUCT to match the asset class (NSE equity → MIS or CNC; NFO → NRML)
- Adjust
QUANTITY to a reasonable starting value (1 for equity, lot size for futures)
- For ML templates (
ml-logistic, ml-xgb), also copy train.py and remind the user to run it BEFORE running the strategy:python strategies/ml_logistic_RELIANCE/train.py
- The file must be host-compatible per
self-hosted-strategies.md:
- Reads HOST_SERVER first, then OPENALGO_HOST fallback
- Reads OPENALGO_STRATEGY_EXCHANGE for exchange
- SIGTERM/SIGINT handlers installed
- stdout-only logging
- dispatcher reads env
MODE if no --mode CLI arg
- Print:
- File location
- Next steps:
- Backtest:
python strategies/<name>/strategy.py --mode backtest
- Live:
python strategies/<name>/strategy.py --mode live
- Upload to /python:
/algo-host <name> to validate and generate upload guide
Available templates
| Template |
Default symbol |
Default exchange |
Default interval |
Default execution |
ema-crossover |
SBIN |
NSE |
5m |
eoc |
rsi |
RELIANCE |
NSE |
15m |
eoc |
supertrend |
NIFTY |
NSE_INDEX |
5m |
eoc |
donchian |
NIFTY |
NSE_INDEX |
D |
eoc |
macd |
INFY |
NSE |
D |
eoc |
opening-range |
SBIN |
NSE |
5m |
stop |
atr-breakout |
RELIANCE |
NSE |
5m |
limit |
bb-squeeze |
TCS |
NSE |
15m |
eoc |
ml-logistic |
RELIANCE |
NSE |
15m |
eoc |
ml-xgb |
RELIANCE |
NSE |
15m |
eoc |
pairs-trading |
SBIN/PNB |
NSE |
D |
eoc (two-leg) |
regime-trend |
RELIANCE |
NSE |
D |
eoc (ADX+VIX+volume gates) |
event-driven |
RELIANCE |
NSE |
D |
scheduled-time |
For options templates (short-straddle, iron-condor), use /algo-options instead.
Costs
The file's COSTS = cost_lookup(PRODUCT, EXCHANGE) auto-resolves:
- MIS + NSE → 0.0225% + Rs 20 + 5 bps slippage
- CNC + NSE → 0.111% + Rs 20 + 3 bps slippage
- NRML + NFO → 0.018% + Rs 20 + 2 bps slippage (futures)
- NRML + NFO with options → 0.098% + Rs 20 + 10 bps slippage
If the user wants different broker rates, point them to algo-expert/rules/transaction-costs.md to override the constants.
Risk defaults
The template comes with reasonable RISK values (see strategy-catalog.md). Tell the user these are starting points, not optimal - tune via backtest before live.
Avoid
- Do not use icons/emojis in code, logger output, or skill text
- Do not generate files in arbitrary paths - always under
strategies/<name>/
- Do not auto-flip
MODE=live without the user explicitly running it
1---2name: algo-strategy3description: Generate a single-file dual-mode trading strategy. Asks for indicator library and execution type. The same file runs `--mode backtest` (VectorBT) and `--mode live` (OpenAlgo). Upload-ready for OpenAlgo /python self-hosted.4---56Create a complete dual-mode strategy file from a template.78## Arguments910Parse `$ARGUMENTS` as: template symbol exchange interval1112- `$0` = template (e.g. `ema-crossover`, `rsi`, `supertrend`, `donchian`, `macd`, `opening-range`, `atr-breakout`, `bb-squeeze`, `ml-logistic`, `ml-xgb`, `pairs-trading`, `regime-trend`, `event-driven`)13- `$1` = symbol (e.g. SBIN, RELIANCE, NIFTY). Default: template's catalog default14- `$2` = exchange (e.g. NSE, NSE_INDEX, NFO). Default: template's catalog default15- `$3` = interval (e.g. 1m, 5m, 15m, D). Default: template's default1617If no arguments, ask the user which template they want. See `algo-expert/rules/strategy-catalog.md`.1819## Required prompts before generation2021After parsing arguments, ASK the user (do not assume defaults silently):22231. **Indicator library**: `(1) openalgo [default] (2) talib`24 - Default openalgo. talib's user must confirm explicitly.25 - Specialty indicators (Supertrend, Donchian, Ichimoku, HMA, KAMA) always use openalgo regardless.26272. **Execution type** - default depends on template (see strategy-catalog.md):28 - `(1) end-of-candle (eoc)` - signal at bar close, MARKET on next bar (default for most)29 - `(2) real-time limit (limit)` - tick-driven LIMIT placement (default for atr-breakout)30 - `(3) stop-trigger (stop)` - broker-side SL/SL-M (default for opening-range)3132 Tell the user the recommended default for their template and let them override.3334## Instructions35361. Read `algo-expert/rules/unified-strategy-pattern.md`, `mode-toggle.md`, and `execution-types.md`.372. Read the matching template at `algo-expert/rules/assets/<template>/strategy.py` as the starting point.383. Create `strategies/<template>_<symbol>/` directory if not present.394. Copy the template into `strategies/<template>_<symbol>/strategy.py` and:40 - Replace `SYMBOL`, `EXCHANGE`, `INTERVAL` constants with user values41 - Set `INDICATOR_LIB` to user's choice (`"openalgo"` or `"talib"`)42 - Set `EXECUTION_TYPE` to user's choice (`"eoc"`, `"limit"`, `"stop"`)43 - Update `STRATEGY_NAME` to `<template>_<symbol>` (default; can be overridden by env)44 - Adjust `PRODUCT` to match the asset class (NSE equity → MIS or CNC; NFO → NRML)45 - Adjust `QUANTITY` to a reasonable starting value (1 for equity, lot size for futures)465. For ML templates (`ml-logistic`, `ml-xgb`), also copy `train.py` and remind the user to run it BEFORE running the strategy:47 ```48 python strategies/ml_logistic_RELIANCE/train.py49 ```506. The file must be host-compatible per `self-hosted-strategies.md`:51 - Reads HOST_SERVER first, then OPENALGO_HOST fallback52 - Reads OPENALGO_STRATEGY_EXCHANGE for exchange53 - SIGTERM/SIGINT handlers installed54 - stdout-only logging55 - dispatcher reads env `MODE` if no `--mode` CLI arg567. Print:57 - File location58 - Next steps:59 - Backtest: `python strategies/<name>/strategy.py --mode backtest`60 - Live: `python strategies/<name>/strategy.py --mode live`61 - Upload to /python: `/algo-host <name>` to validate and generate upload guide6263## Available templates6465| Template | Default symbol | Default exchange | Default interval | Default execution |66|---|---|---|---|---|67| `ema-crossover` | SBIN | NSE | 5m | eoc |68| `rsi` | RELIANCE | NSE | 15m | eoc |69| `supertrend` | NIFTY | NSE_INDEX | 5m | eoc |70| `donchian` | NIFTY | NSE_INDEX | D | eoc |71| `macd` | INFY | NSE | D | eoc |72| `opening-range` | SBIN | NSE | 5m | stop |73| `atr-breakout` | RELIANCE | NSE | 5m | limit |74| `bb-squeeze` | TCS | NSE | 15m | eoc |75| `ml-logistic` | RELIANCE | NSE | 15m | eoc |76| `ml-xgb` | RELIANCE | NSE | 15m | eoc |77| `pairs-trading` | SBIN/PNB | NSE | D | eoc (two-leg) |78| `regime-trend` | RELIANCE | NSE | D | eoc (ADX+VIX+volume gates) |79| `event-driven` | RELIANCE | NSE | D | scheduled-time |8081For options templates (`short-straddle`, `iron-condor`), use `/algo-options` instead.8283## Costs8485The file's `COSTS = cost_lookup(PRODUCT, EXCHANGE)` auto-resolves:86- MIS + NSE → 0.0225% + Rs 20 + 5 bps slippage87- CNC + NSE → 0.111% + Rs 20 + 3 bps slippage88- NRML + NFO → 0.018% + Rs 20 + 2 bps slippage (futures)89- NRML + NFO with options → 0.098% + Rs 20 + 10 bps slippage9091If the user wants different broker rates, point them to `algo-expert/rules/transaction-costs.md` to override the constants.9293## Risk defaults9495The template comes with reasonable RISK values (see `strategy-catalog.md`). Tell the user these are starting points, not optimal - tune via backtest before live.9697## Avoid9899- Do not use icons/emojis in code, logger output, or skill text100- Do not generate files in arbitrary paths - always under `strategies/<name>/`101- Do not auto-flip `MODE=live` without the user explicitly running it