一键导入
algo-setup
// Set up the Python environment for OpenAlgo execution skills - venv, openalgo[indicators], vectorbt, talib, scikit-learn, xgboost. Scaffolds strategies/ folder and .env.
// Set up the Python environment for OpenAlgo execution skills - venv, openalgo[indicators], vectorbt, talib, scikit-learn, xgboost. Scaffolds strategies/ folder and .env.
| name | algo-setup |
| description | Set up the Python environment for OpenAlgo execution skills - venv, openalgo[indicators], vectorbt, talib, scikit-learn, xgboost. Scaffolds strategies/ folder and .env. |
| argument-hint | [python-version] |
| allowed-tools | Read, Write, Edit, Bash, Glob, Grep |
Set up the local Python environment for building and running OpenAlgo dual-mode trading strategies.
$0 (optional) = python interpreter name (python, python3, python3.12). Default: python.
Detect the OS (Windows / macOS / Linux) via uname -s or os.name. Use OS-specific install commands for the TA-Lib C library (which pip install ta-lib depends on).
Create venv if not already present:
python -m venv venv
Install TA-Lib C library (required by Python ta-lib):
brew install ta-libsudo apt install libta-lib-dev (may need sudo apt update)pip install ta-lib uses pre-built wheels - no C library install neededActivate venv and install Python packages from requirements.txt:
# Linux/macOS
source venv/bin/activate
pip install -r requirements.txt
# Windows
venv\Scripts\activate
pip install -r requirements.txt
Scaffold folders:
strategies/
(empty - generated strategies will land here)
backtests/
(empty - generated backtest CSV/HTML output lands here)
Create .env by copying .env.sample and prompt the user to fill in OPENALGO_API_KEY:
cp .env.sample .env
Verify the install by running:
from openalgo import api, ta
import vectorbt as vbt
import talib
import sklearn
import xgboost
print("OK")
Print next steps:
Setup complete. Next:
1. Edit .env and set OPENALGO_API_KEY
2. Make sure OpenAlgo is running at http://127.0.0.1:5000
3. Generate a strategy: /algo-strategy ema-crossover SBIN NSE 5m
OPENALGO_API_KEY=... in the shell - the user pastes it into .env manuallypip exists outside the venv after step 4 - always activate firstSkip step 2. Activate the existing venv, run pip install -r requirements.txt against it, and continue.
sudo apt update && sudo apt install build-essential libta-lib-dev. If that fails (older distros), suggest skipping TA-Lib and using only INDICATOR_LIB="openalgo" in strategies.from openalgo import api works (SDK installs without network). Real connection is verified in /algo-strategy.OpenAlgo 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.
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.