Equity Monte Carlo Simulator

by alexmartinsgomes

Not rated
GitHub

About

Give any AI agent the power to run a serious Monte Carlo forecast for a stock or ETF - in one tool call.

Details

Author
alexmartinsgomes
Categories
Finance, Other, AI

Setup

Install Equity Monte Carlo Simulator in your MCP client (Claude Desktop, Cursor, Windsurf, and others).

Repository: https://github.com/alexmartinsgomes/mcp-monte-carlo

Follow the installation instructions in the repository README, then restart your MCP client.

Give any AI agent the power to run a serious Monte Carlo forecast for a stock or ETF - in one tool call.

Give any AI agent the power to run a serious Monte Carlo forecast for a stock or ETF — in one tool call.

This is anMCP(Model Context Protocol) server. Connect it once to Hermes, Claude Desktop, Cursor, or any MCP-capable agent, and the agent can download market history, fit a volatility model, simulate thousands of future price paths, and return percentiles, drawdowns, and risk probabilities — without you writing a single line of simulation code.

You: "What does a bad year look like for SPY over the next 12 months?" Agent → forecast_asset_monte_carlo("SPY") → EGARCH + skewed-t Monte Carlo (5,000 paths by default) You ← JSON: price/return percentiles, vol, max drawdowns, loss probabilities

Large language models are excellent at reasoning and explanation. They arenotengines for sampling fat-tailed returns under time-varying volatility. Left alone, an agent might invent plausible-looking percentiles or hand-wave “historical vol $\times\sqrt{T}$”.

The agent stays in charge ofinterpretationandconversation. The MCP ownsestimationandsimulation.

Yahoo Finance (max history) │ adjusted daily Close ▼ Log returns │ ▼ Fit EGARCH(1,1) + leverage + skewed-t shocks │ constant mean drift (historical mean) ▼ Simulate N paths (default 5,000) out to 10 years │ ▼ Summarize each horizon → percentiles, vol, MDD, probabilities

Usesyfinanceto pull themaximumavailable daily history. TheClosefield is already adjusted for splits and dividends, so returns are suitable for long-horizon compounding.

The mean model isconstant: each simulated day has drift equal to the fitted historical average $\mu$. That is a simple, transparent assumption — not a crystal ball for future expected return.

Equity volatility is neither constant nor symmetric:

- Volatility clustering— turbulent days tend to follow turbulent days.
- Leverage effect— largedownmoves tend to raise future vol more than equally largeupmoves.

This server fitsEGARCH(1,1) with leverage($p=1$, $o=1$, $q=1$) via thearchpackage. Conditionally, log-variance evolves roughly as:

\ln(\sigma_t^2)=\omega+\alpha\bigl(\lvert z_{t-1}\rvert-\mathbb{E}[\lvert z\rvert]\bigr)+\gamma z_{t-1}+\beta\ln(\sigma_{t-1}^2)

For equities, the leverage coefficient $\gamma$ is typicallynegative: a negative shock $z$ increases tomorrow’s volatility.

Gaussian shocks understate crash risk. Standardized innovations are drawn from askewed tdistribution, so simulated paths can show:

- fat tails (extreme moves more often than a normal),
- skewness (asymmetric left/right risk).

Given the fitted parameters, the server simulates $N$ forward trajectories (n_paths; vectorized NumPy loop for stability out to multi-year horizons). Each path is a full price series; horizons are slices of those same paths so short- and long-term stats are coherent.

forecast_asset_monte_carlo(ticker, n_paths=5000)

When to use:The user wants forward scenarios, risk ranges, or path statistics for a ticker (e.g.SPY,AAPL).

- Price percentiles1, 5, 10, 25, 50, 75, 90, 95, 99
- Return percentiles (%)— same grid, vs today’s price
- Annualized volatility (%)— cross-sectional vol of path outcomes at that horizon
- Max-drawdown percentiles (%)— peak-to-trough loss along each path up to that horizon
- Probabilities— end below start, ±20% moves, max drawdown over 20%

n_pathsdefaults to5000(minimum100). More paths → smoother percentile estimates, slower run.

When to use:Validate data quality or model sanitybefore(or instead of) a full forecast — enough history? sensible parameters? how fat are residual tails?

Returns history span, last price, fitted EGARCH + skew-t parameters, AIC/BIC, last conditional volatility (daily and annualized), and residual skewness / excess kurtosis.

Doesnotsimulate paths. Preferforecast_asset_monte_carlofor percentiles and drawdowns.

- macOS, Linux, or Windows
- uv(recommended)
- Python≥ 3.12(declared inpyproject.toml)
- Network access (Yahoo Finance download)

uv run python -c " from server import run_inspect, run import json print(json.dumps(run_inspect('SPY'), indent=2)) print(json.dumps(run('SPY', 200)['horizons']['1y'], indent=2)) "
uv run mcp-monte-carlo # or, from a published clone / path: uvx --from /path/to/mcp-monte-carlo mcp-monte-carlo

Preferuv runagainst a synced project (faster and more reliable than a colduvx):

mcp_servers: mcp-monte-carlo: command: /opt/homebrew/bin/uv # which uv → paste absolute path args: - run - --directory - /ABSOLUTE/PATH/TO/mcp-monte-carlo - mcp-monte-carlo connect_timeout: 120 timeout: 300

Then:hermes mcp test mcp-monte-carloor/reload-mcpin a chat.

{ "mcpServers": { "mcp-monte-carlo": { "command": "uvx", "args": [ "--from", "/ABSOLUTE/PATH/TO/mcp-monte-carlo", "mcp-monte-carlo" ] } } }

Once published on GitHub, others can point--fromat the repo URL or clone locally and use the same pattern.

- “Inspect the EGARCH model forQQQ, then forecast with 2,000 paths.”
- “ForAAPL, what is the 5th percentile price in 1 year, and the probability of a >20% max drawdown?”
- “Compare 1-year median and 95th percentile max drawdown forSPYvsTLT.”

mcp-monte-carlo/ ├── server.py # MCP tools + EGARCH/skew-t Monte Carlo (single module) ├── pyproject.toml # package metadata, deps, console entry point ├── uv.lock # locked dependency versions ├── README.md └── .gitignore

One Python file keeps the project easy to read, audit, and ship.

This is aresearch / educational risk tool, not investment advice and not a guarantee of future prices.

- Past drift $\mu$ isnota forecast of expected return; long-horizon medians inherit that assumption.
- EGARCH(1,1)+leverage and skewed-t are strong defaults for many liquid equities/ETFs — not universally “optimal” for every ticker.
- Yahoo data quality and corporate actions can affect results; always checkinspect_asset_modelon unfamiliar symbols.
- Extremely long horizons (5y–10y) compound model risk; treat tails as illustrative, not certainties.

Created by Alexandre Martins. Use and adapt freely for personal agents and learning; if you redistribute, keep attribution and these caveats visible.

Portfolio & trading-strategy stress diagnostics for AI agents: multi-asset stress with hedge-break detection, a daily preregistered regime outlook and deflated-Sharpe backtest-integrity checks. Remote streamable HTTP, free tier, no auth.

Estimates departmental value-leak (wasted spend/time) from headcount and labor cost data for Claude, Cursor, and other MCP agents.

Measured market statistics for AI agents — day-type probabilities, volume-wave events with measured win rates, options max pain and dealer gamma; remote MCP at https://api.quantdata.uk/mcp, no key needed to try.

Graded trading signals & market analysis (FX, crypto, sports, prediction markets) with a public machine-graded track record. Free track-record tools; pay per call with x402 USDC or credit packs.

Connect TradeOS to GPT, Claude, and other MCP-compatible AI tools. The TradeOS MCP Server lets your assistant work directly with your trading data, indicators, strategy logic, and agent workflows, helping you analyze markets, monitor setups, and automate trading intelligence from your TradeOS environment

Use TradeOS MCP Server to bring your trading data, indicators, strategy logic, and agent workflows into MCP-compatible AI tools. Copy your server URL, add it to GPT or Claude, and let your AI assistant work directly with your TradeOS trading intelligence.

The most complete AI-powered trading toolkit for Claude and MCP clients. Backtesting + Live Sentiment + Yahoo Finance + 30+ Technical Analysis Tools — all in one MCP server.

AI trading memory layer for MT5/forex with 15 MCP tools — store/recall trades, pattern discovery, strategy evolution, and Outcome-Weighted Memory.

Full-lifecycle algorithmic trading: describe strategies in plain English, AI generates code, backtest on real data, deploy live to 10+ brokers. Stocks, options, crypto, futures. Free tier available.

Deterministic macro regime engine for AI trading agents — RISK_ON / NEUTRAL / RISK_OFF / STRESS with transparent scoring rules.

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.