Skip to content
TotalFinance

risk · wire operation

Portfolio optimization

Solve a portfolio: minVariance, maxSharpe (tangency), meanVariance utility, riskParity (equal risk contribution), hrp (hierarchical risk parity), or kelly. Returns the Computed envelope: value.weights + value.objective, assumptions echo the objective and budget, and diagnostics carry converged/iterations — a non-converged solve adds an optimize.not_converged warning instead of pretending.

totalfinance.risk.optimize
MCP tool name
totalfinance_risk_optimize
Pack / profiles
risk / default, full, portfolio
Default discovery
Included in the default tool set
Required capabilities
None
Effects / authorization
none / none
Cost / cancellation
small / Do not assume inline interruption
Handle-eligible inputs
None
Idempotency
not-applicable

Input schema

FieldTypeMeaning
objectiveRequired"minVariance" | "maxSharpe" | "meanVariance" | "riskParity" | "hrp" | "kelly"Which portfolio to solve for
covarianceRequirednumber[][]Asset covariance matrix (per-period, decimal² units), square
meanOptionalnumber[]Per-asset expected returns (decimals) — required for maxSharpe/meanVariance/kelly
riskFreeRatePerPeriodOptionalnumberPER-PERIOD risk-free rate (decimal; maxSharpe only) — the same period as the covariance matrix, NOT annualized. Renamed from `riskFreeRate` because every other risk-free rate in the library is annual, and the two were silently interchangeable here
riskAversionOptionalnumberλ for meanVariance (default 1)
fractionOptionalnumberKelly fraction (default 1 = full Kelly)
longOnlyOptionalbooleanForbid short positions
budgetOptionalnumberΣw target (default 1 = fully invested)
Complete JSON Schema

Loading…

Output schema

FieldTypeMeaning
valueRequiredobjectThe computed result
assumptionsRequiredobjectEvery applied convention, echoed
diagnosticsRequiredobjectEngine/method/warnings (+ convergence where iterative)
Complete JSON Schema

Loading…