一键导入
algo-strategy
// 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.
// 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.
| name | algo-strategy |
| description | 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. |
| argument-hint | [template] [symbol] [exchange] [interval] |
| allowed-tools | Read, Write, Edit, Bash, Glob, Grep |
Create a complete dual-mode strategy file from a template.
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 defaultIf no arguments, ask the user which template they want. See algo-expert/rules/strategy-catalog.md.
After parsing arguments, ASK the user (do not assume defaults silently):
Indicator library: (1) openalgo [default] (2) talib
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.
algo-expert/rules/unified-strategy-pattern.md, mode-toggle.md, and execution-types.md.algo-expert/rules/assets/<template>/strategy.py as the starting point.strategies/<template>_<symbol>/ directory if not present.strategies/<template>_<symbol>/strategy.py and:
SYMBOL, EXCHANGE, INTERVAL constants with user valuesINDICATOR_LIB to user's choice ("openalgo" or "talib")EXECUTION_TYPE to user's choice ("eoc", "limit", "stop")STRATEGY_NAME to <template>_<symbol> (default; can be overridden by env)PRODUCT to match the asset class (NSE equity → MIS or CNC; NFO → NRML)QUANTITY to a reasonable starting value (1 for equity, lot size for futures)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
self-hosted-strategies.md:
MODE if no --mode CLI argpython strategies/<name>/strategy.py --mode backtestpython strategies/<name>/strategy.py --mode live/algo-host <name> to validate and generate upload guide| 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.
The file's COSTS = cost_lookup(PRODUCT, EXCHANGE) auto-resolves:
If the user wants different broker rates, point them to algo-expert/rules/transaction-costs.md to override the constants.
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.
strategies/<name>/MODE=live without the user explicitly running itOpenAlgo execution expert. Auto-loaded knowledge base for building algorithmic trading strategies that toggle between VectorBT backtest and OpenAlgo live execution. Triggers when user mentions OpenAlgo trading strategies, dual-mode strategies, /python self-hosted strategies, options execution (short straddle, iron condor), portfolio risk caps, or live execution with stop loss / target / trailing stop / risk management.
Validate a generated strategy and produce an upload guide for OpenAlgo's /python self-hosted strategy page. Confirms env-var reads, SIGTERM, stdout-only logging.
Generate options-only execution strategies (short straddle, iron condor). Backtest mode is intentionally disabled. Live mode uses optionsmultiorder + per-leg SL.
Run multiple strategies under one supervisor with portfolio-level risk caps (portfolio SL/TP, daily PnL limits, max concurrent positions). YAML-driven.
Verify a strategy's SL / TP / trailing stop / portfolio caps fire correctly. Uses OpenAlgo sandbox + synthetic price moves. Run this before going live.
Set up the Python environment for OpenAlgo execution skills - venv, openalgo[indicators], vectorbt, talib, scikit-learn, xgboost. Scaffolds strategies/ folder and .env.