
algo-portfolio
Run multiple strategies under one supervisor with portfolio-level risk caps (portfolio SL/TP, daily PnL limits, max concurrent positions). YAML-driven.
- Installs
- 41
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/marketcalls/openalgo-execution-skills --skill algo-portfolio- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads algo-portfolio automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
Launch a multi-strategy portfolio with global risk caps.
Arguments
$0= path to YAML config. Default:portfolio.yamlin current directory- Pass
--mode backtestor--mode liveafter the config path
If no config exists, generate a starter portfolio.yaml.
Instructions
- Read
algo-expert/rules/portfolio-risk.md. - If the config file doesn't exist, generate this starter:
# Portfolio Runner Configuration
# See algo-expert/rules/portfolio-risk.md for cap explanations
capital: 1000000
portfolio_caps:
portfolio_sl_pct: 0.02 # halt all at -2% capital
portfolio_tp_pct: 0.03 # halt all at +3% capital
daily_loss_pct: 0.015 # daily loss limit
daily_target_pct: 0.025 # daily target
max_concurrent_positions: 5
max_symbol_concentration: 0.30 # max 30% of capital in one symbol
strategies:
# List your generated strategies. The runner spawns each as a subprocess.
- name: ema_sbin
path: strategies/ema_crossover_SBIN/strategy.py
env:
SYMBOL: SBIN
INTERVAL: 5m
- name: rsi_reliance
path: strategies/rsi_RELIANCE/strategy.py
env:
SYMBOL: RELIANCE
INTERVAL: 15m
- Verify each strategy path exists. If not, suggest running
/algo-strategyto create them first. - Generate a runner script
run_portfolio.pyat the project root (or update if exists) that wrapscore/portfolio_runner.py:
"""Portfolio runner entry point."""
import argparse, logging, os, sys
from pathlib import Path
from dotenv import find_dotenv, load_dotenv
# Add core helpers to path
_HERE = Path(__file__).resolve().parent
for p in [_HERE, *_HERE.parents]:
c = p / ".claude" / "skills" / "algo-expert" / "rules" / "assets" / "core"
if c.exists():
sys.path.insert(0, str(c.parent)); break
from openalgo import api
from core.portfolio_runner import PortfolioRunner
logging.basicConfig(level=os.getenv("LOG_LEVEL", "INFO"),
format="%(asctime)s [%(levelname)s] %(name)s - %(message)s",
stream=sys.stdout)
load_dotenv(find_dotenv(usecwd=True))
def make_client():
return api(
api_key=os.getenv("OPENALGO_API_KEY", ""),
host=os.getenv("HOST_SERVER") or os.getenv("OPENALGO_HOST", "http://127.0.0.1:5000"),
)
def main():
p = argparse.ArgumentParser()
p.add_argument("--config", default="portfolio.yaml")
p.add_argument("--mode", choices=["backtest", "live"], default="live")
args = p.parse_args()
runner = PortfolioRunner(args.config, client_factory=make_client, mode=args.mode)
runner.start()
runner.join()
if __name__ == "__main__":
main()
-
Run it:
python run_portfolio.py --config portfolio.yaml --mode live -
Tell the user:
- Each strategy runs in its own subprocess (full isolation)
- SIGTERM is propagated when caps breach OR on Ctrl-C
- The runner monitors aggregate P&L every 15s via
client.positionbook() - On breach:
cancelallorder+closepositionare called platform-wide - Live vs sandbox is decided by OpenAlgo's UI analyzer toggle (same as a single strategy)
Backtest mode
Aggregate-equity backtest of multiple strategies needs custom merging logic (rebalancing weights, cap timing). The default runner does NOT do this in backtest mode - each child runs its own VectorBT backtest independently. To get a true portfolio backtest, see algo-expert/rules/portfolio-risk.md for the merge-equities pattern.
Cap precedence
When multiple caps fire at once, the most restrictive wins. The kill switch fires once per session - re-running the runner resets daily counters at IST midnight.
Telegram alerts on cap breach
To wire Telegram alerts when the portfolio halts, set TELEGRAM_USERNAME in .env and extend core/portfolio_runner.py's stop_all() method. See logging-and-alerts.md.
Avoid
- Do not use icons/emojis
- Do not silently increase the cap when it breaches - that defeats the safety net
- Do not run two
PortfolioRunnerprocesses against the same OpenAlgo instance - they'd both try to flatten on breach and conflict
FAQ
What does the algo-portfolio skill do?
Run multiple strategies under one supervisor with portfolio-level risk caps (portfolio SL/TP, daily PnL limits, max concurrent positions). YAML-driven.
How do I install algo-portfolio?
Run npx skills add https://github.com/marketcalls/openalgo-execution-skills --skill algo-portfolio in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/algo-portfolio/ (personal) or .claude/skills/algo-portfolio/ (project).
Which AI agents can use algo-portfolio?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is algo-portfolio safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains algo-portfolio?
It is published by marketcalls in marketcalls/openalgo-execution-skills. It has 41 recorded installs.
More from marketcalls/openalgo-execution-skills
algo-strategy
marketcalls/openalgo-execution-skills
Open the skill to read its SKILL.md instructions.
algo-options
marketcalls/openalgo-execution-skills
Open the skill to read its SKILL.md instructions.
algo-risk-test
marketcalls/openalgo-execution-skills
Verify a strategy's SL / TP / trailing stop / portfolio caps fire correctly. Uses OpenAlgo sandbox + synthetic price moves. Run this before going live.
algo-expert
marketcalls/openalgo-execution-skills
Open the skill to read its SKILL.md instructions.
algo-host
marketcalls/openalgo-execution-skills
Open the skill to read its SKILL.md instructions.
algo-setup
marketcalls/openalgo-execution-skills
Set up the Python environment for OpenAlgo execution skills - venv, openalgo[indicators], vectorbt, talib, scikit-learn, xgboost. Scaffolds strategies/ folder and .env.
Popular other skills
hyperframes-cli
heygen-com/hyperframes
The HyperFrames CLI by job - scaffold, check, look at frames, edit the timeline, preview, render locally or in the cloud, publish, project history - plus reading its JSON and recovering from build or render failures.
triage
mattpocock/skills
Move issues and external PRs through a state machine of triage roles, categorise, verify, grill if needed, and write agent-ready briefs.
ask-matt
mattpocock/skills
Ask which skill or flow fits your situation. A router over the skills in this repo.
to-questionnaire
mattpocock/skills
Turn a decision you can't fully answer into a questionnaire for someone else to fill in.
loop-me
mattpocock/skills
Grill me about specs for the workflows I want to build, within this workspace.