optimize-allocation

optimize-allocation is a skill for Claude Code, Codex from tusharagg1/aifolimizer. It costs 85 tokens per session (1,041 once invoked), scanned A, original, MIT.

A portfolio calculator that finds target percentages for individual investments using expected returns and risk. It uses mean-variance optimisation, which compares possible mixes of investments, and can include analyst price targets as estimates.

In plain words
What is it for?
Use it to optimise an active trading portfolio, compare efficient-frontier options, or plan a rebalance with possible sales.
Why use it?
It turns a collection of holdings into suggested weights and shows which positions to add, reduce, or sell for a chosen risk-and-return balance.

Skill for Claude CodeCodex

Part of the aifolimizer plugin — 28 skills, 2 agents shipped together

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/tusharagg1/aifolimizer/optimize-allocation
Any agent
npx skills add tusharagg1/aifolimizer --skill optimize-allocation
Clone the repo
git clone --depth 1 https://github.com/tusharagg1/aifolimizer

Made for: Claude Code, Codex.

Or install aifolimizer, the plugin that ships this one along with the rest of its 28 skills, 2 agents.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for optimize-allocation

README.md
[![agentmods](https://agentmods.dev/badge/skills/tusharagg1/aifolimizer/optimize-allocation.svg)](https://agentmods.dev/skills/tusharagg1/aifolimizer/optimize-allocation)
Your own site
<a href="https://agentmods.dev/skills/tusharagg1/aifolimizer/optimize-allocation"><img src="https://agentmods.dev/badge/skills/tusharagg1/aifolimizer/optimize-allocation.svg" alt="Measured on agentmods" height="20"></a>
Per session 85 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,041 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00085 $0.01041
Opus 5 $0.00043 $0.00521
Sonnet 5 $0.00017 $0.00208
Haiku 4.5 $0.00009 $0.00104

Measured 4d ago against content hash 78f5e4dad003, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

optimize-allocation scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/skills/optimize-allocation/SKILL.md · 73 lines

How it starts

The opening of the file, as written. The whole thing — 73 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Optimize Allocation (Max-Sharpe / Black-Litterman)

Goal

Compute the optimal weight per holding and the concrete add/trim changes vs the current book that maximise risk-adjusted return. Engine: PyPortfolioOpt Efficient Frontier with Ledoit-Wolf shrinkage covariance, longs-only, 35% cap per name. Analyst price targets are blended as Black-Litterman views when available.

This is the trading-bucket reweighting tool. It WILL suggest selling overweighted names - distinct from auto-rebalance, which only adds new cash to the long-term ETF core and never sells.

Decision Memory Protocol (load first, log after)

Before forming any view, load prior decisions so verdicts stay consistent across sessions:

  • mcp__aifolimizer__get_cross_ticker_lessons (max_lessons=3) - portfolio-level win/loss patterns
  • For any name you issue a per-ticker BUY/SELL/TRIM/HOLD/ADD on, also load mcp__aifolimizer__get_ticker_decision_history (ticker=…, max_decisions=5) and mcp__aifolimizer__get_ticker_reflection (symbol=…, n=3). If a prior decision exists and this run flips it, state explicitly WHY (new data / catalyst / price); never silently contradict a logged decision.

After output, log every actionable reweight: for each BUY/SELL/TRIM/ADD issued, call mcp__aifolimizer__log_recommendation (skill="optimize-allocation", ticker, action, conviction, rationale, target_pct, stop_pct). Skipping breaks the cross-session feedback loop and causes drift.

When to invoke

  • "What's the optimal allocation / optimal weights?"
  • "How much of each should I add or trim?"
  • "Rebalance my holdings for best risk-adjusted return"
  • After a large drift, new capital, or a thesis change across multiple names

How to run

Step 1 - Profile + regime (call FIRST):

  1. mcp__aifolimizer__get_profile - account types, capital (never hardcode)
  2. mcp__aifolimizer__get_personal_context - ground the Non-Reg-vs-registered tax note in the user's actual province / marginal_tax_rate_pct / account_waterfall instead of generic text. If present=false, keep the note generic and suggest running profile-setup.
  3. mcp__aifolimizer__get_market_breadth - regime; if bear_high_fear, flag that max-Sharpe on trailing returns can over-tilt to recent winners

Read the full file on GitHub · 73 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 4d ago First seen · 73 lines · 85 tokens per session scan A 78f5e4dad003

Subscribe to this mod's changes

optimize-allocation is a skill published in the GitHub repository tusharagg1/aifolimizer (2 stars, last pushed 27d ago), licensed MIT. It adds 85 tokens to every session and 1,041 once invoked, about $0.0004 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

quantoracle

63 deterministic quantitative finance calculators + 10 composite workflows via MCP. Options pricing, Greeks, exotic derivatives, risk metrics, portfolio optimization, Monte Carlo, statistics, crypto/DeFi, FX/macro, TVM, strategy backtesting, rebalance planning, options strategy selection, hedging. 1,000 free…

QuantOracledev/quantoracle · 92 tokens

gitee-expert

You have access to Gitee (gitee.com), China's largest GitHub-style platform. This skill teaches the effective workflows for discovery, intel, translation and webhook monitoring.

sandraschi/gitee-mcp · 0 tokens

session-start

Bridge to Gitee (gitee.com), China's largest Chinese-language code hosting platform: live activity radar, repo intel, user/repo search and zh->en translation via your local LLM.

sandraschi/gitee-mcp · 0 tokens

transcribe-filing

Transcribe an insurance rate filing or internal rating manual into an OpenRater workbook, then validate, build, verify, and rate it through the OpenRater MCP tools. Use when the user shares a filing/manual (PDF or pages) and wants it executable — "build this filing", "digitize this rating manual", "make this rateable"…

vadim-filimonov/openrater · 102 tokens

gitee-mcp

Gitee bridge session context - humming radar, repo intel, search, zh->en translation. Load when exploring Chinese open-source activity.

sandraschi/gitee-mcp · 32 tokens

vibe-trading

Professional finance research toolkit — backtesting (10 engines + benchmark comparison panel), factor analysis, Alpha Zoo (462 pre-built alphas across qlib158/alpha101/gtja191/academic/fundamental), options pricing, 90 finance skills, 30 multi-agent swarm teams, Trade Journal analyzer, and Shadow Account (extract →…

HKUDS/Vibe-Trading · 166 tokens