Zum Inhalt springen
← Zurück zu den Projekten

Openalgo Execution Skills

#OpenAlgo Execution Skills for Agentic Coding Tools

A skill pack for building production-grade algorithmic trading strategies on the OpenAlgo platform. Every strategy generated by these skills is a single Python file that toggles between backtest mode (VectorBT) and live execution mode (OpenAlgo SDK + WebSocket) via one flag — no separate codebases.

Strategies are also upload-ready for OpenAlgo's self-hosted /python strategy host with exchange-aware scheduling, env-var driven configuration, and SIGTERM-safe shutdown.

Works with 40+ AI coding agents via skills.sh — Claude Code, Cursor, Codex, OpenCode, Cline, Windsurf, GitHub Copilot, Gemini CLI, Roo Code, and more.

#Quick Install

# GitHub shorthand
npx skills add marketcalls/openalgo-execution-skills

# Specific skill
npx skills add marketcalls/openalgo-execution-skills -s algo-strategy

#Slash Commands

Command What It Does
/algo-setup Detects OS, creates venv, installs openalgo[indicators], vectorbt, talib, scikit-learn, xgboost. Scaffolds strategies/ and .env
/algo-strategy <template> <symbol> [exchange] [interval] Generates a single dual-mode strategy file. Asks for indicator library (openalgo or talib) and execution type (eoc / limit / stop)
/algo-options <template> <underlying> Options-only execution (short-straddle, iron-condor, broken-wing-butterfly). Backtest mode disabled
/algo-portfolio <config.yaml> Multi-strategy supervisor with portfolio SL/TP and daily PnL caps
/algo-risk-test <strategy-file> Synthetic-tick verification of SL/TP/trailing/portfolio-stop firing
/algo-host <strategy-name> Validates and packages a strategy for upload to OpenAlgo's /python self-hosted strategy page
/algo-expert Auto-loaded knowledge base (24 rule files)

#Single-File Dual-Mode Pattern

Every generated strategy looks like this:

# Local backtest (uses VectorBT)
python strategies/my_ema/strategy.py --mode backtest

# Local live (real OpenAlgo orders + WS risk manager)
# Live vs sandbox is controlled in OpenAlgo's UI analyzer toggle
python strategies/my_ema/strategy.py --mode live

# Self-hosted via OpenAlgo /python (env-driven, no CLI)
# Upload through http://localhost:5000/python

The same signals(df) function feeds both VectorBT (backtest) and the live event loop. The same risk thresholds (SL/TP/trailing) apply in both modes. The same fee and slippage assumptions are honored on both sides.

#Three Execution Types

Asked at strategy creation time, baked into the file:

Type When to use How orders are placed
end-of-candle (default) Trend, momentum, mean-reversion strategies Signal evaluated at bar close, MARKET order on next bar
real-time limit Breakout-on-touch, scalping, depth-aware entries Pre-place LIMIT orders, modify/cancel on tick events
stop-trigger ORB triggers, fail-safe stops Broker-side SL/SL-M orders activated on price hit

#Indicator Library Choice

Asked at strategy creation. Default is openalgo.ta (Numba-JIT, 100+ indicators). User can pick talib for standard indicators only — specialty indicators (Supertrend, Ichimoku, Donchian, HMA, KAMA) always come from openalgo since talib doesn't have them.

#Real-World Cost Modeling

4-segment Indian market fees baked in (matches vectorbt-backtesting-skills conventions):

Segment fees fixed_fees slippage
Intraday Equity (MIS) 0.0225% Rs 20 5 bps
Delivery Equity (CNC) 0.111% Rs 20 3 bps
F&O Futures (NRML) 0.018% Rs 20 2 bps
F&O Options (NRML) 0.098% Rs 20 10 bps

Backtest applies these via VectorBT fees, fixed_fees, slippage parameters. Live mode optionally uses LIMIT-with-offset to control slippage and tracks measured slippage per fill, with end-of-session drift report.

#Risk Management

Per-position (in every strategy):

  • Stop loss (% or absolute)
  • Take profit (% or absolute)
  • Trailing stop (% or absolute, watermark-based)
  • Time-based exit (max hold minutes)

Portfolio-level (via /algo-portfolio):

  • Portfolio SL / TP (e.g. -2% / +3% of capital)
  • Daily PnL stop (resets at IST midnight)
  • Daily PnL target
  • Max concurrent positions
  • Max symbol concentration

All caps work in both backtest and live modes — backtest computes equity per bar inside the runner, live tracks realized + unrealized P&L from tradebook() and positionbook().

#Self-Hosted via OpenAlgo /python

Every strategy is upload-ready for OpenAlgo's built-in /python strategy host:

  • Reads OPENALGO_STRATEGY_EXCHANGE, HOST_SERVER, OPENALGO_API_KEY from env (with fallbacks)
  • SIGTERM-safe shutdown (graceful WS disconnect, state flush)
  • stdout-only logging (host captures to logs/strategies/)
  • SQLite state per strategy survives restarts
  • Exchange-aware calendar gating works automatically

The /algo-host skill validates compatibility and generates an upload checklist with exact form values to enter on http://localhost:5000/python.

#Strategy Templates (12)

Template Type Default Execution Description
ema-crossover Trend end-of-candle EMA fast/slow crossover with trailing stop
rsi Mean-reversion end-of-candle RSI oversold/overbought with time exit
supertrend Trend end-of-candle Supertrend with ATR-based stops
donchian Breakout end-of-candle Donchian channel breakout
macd Trend end-of-candle MACD zero-line + signal crossover
opening-range Breakout stop-trigger ORB with broker-side SL-M triggers
atr-breakout Volatility real-time limit LIMIT pegged at breakout band
bb-squeeze Volatility end-of-candle Bollinger Band squeeze + breakout
short-straddle Options eoc + stop ATM straddle with per-leg SL
iron-condor Options eoc + stop Wing-defined credit spread
ml-logistic ML end-of-candle Logistic regression on engineered features
ml-xgb ML end-of-candle XGBoost classifier with walk-forward training

#Prerequisites

#1. OpenAlgo Platform

git clone https://github.com/marketcalls/openalgo.git
cd openalgo
pip install -r requirements.txt
python app.py

OpenAlgo runs at http://127.0.0.1:5000. WebSocket at ws://127.0.0.1:8765. Connect a broker via the OpenAlgo dashboard and grab the API key.

#2. Python Environment

python -m venv venv
source venv/bin/activate           # Linux/Mac
# venv\Scripts\activate            # Windows

pip install -r requirements.txt

#3. Configure API Keys

cp .env.sample .env
# Edit .env with OPENALGO_API_KEY and host URLs

#Configuration

The .env file is read by every generated strategy:

OPENALGO_API_KEY=your_api_key_here
HOST_SERVER=http://127.0.0.1:5000
WEBSOCKET_URL=ws://127.0.0.1:8765

When uploaded to OpenAlgo's /python, the platform injects OPENALGO_STRATEGY_EXCHANGE, OPENALGO_API_KEY, STRATEGY_ID, STRATEGY_NAME and inherits HOST_SERVER and WEBSOCKET_URL from OpenAlgo's own .env.

#Knowledge Base (23 Rule Files)

Category Rule Files
SDK & Data sdk-reference, order-constants, symbol-format, lot-sizes, websocket-feeds
Strategy Pattern unified-strategy-pattern, mode-toggle, indicator-libraries, execution-types, event-loop
Risk & Portfolio risk-management, portfolio-risk
Costs transaction-costs, slippage-handling
Domain Strategies options-execution, volatility-strategies, ml-strategies
Patterns execution-patterns, state-persistence, logging-and-alerts, pitfalls, strategy-catalog
Hosting self-hosted-strategies

#Companion Skill Packs

This pack composes naturally with:

This pack is the execution + dual-mode layer. The other two are research / analysis layers.

#License

MIT

Neue Version verfügbar.