building-monte-carlo-simulations

Constructs Monte Carlo simulation frameworks with variance reduction and convergence analysis. Use when building MC simulations, implementing variance reduction, or assessing simulation accuracy.

11 stars

Best use case

building-monte-carlo-simulations is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Constructs Monte Carlo simulation frameworks with variance reduction and convergence analysis. Use when building MC simulations, implementing variance reduction, or assessing simulation accuracy.

Teams using building-monte-carlo-simulations should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/building-monte-carlo-simulations/SKILL.md --create-dirs "https://raw.githubusercontent.com/CaseMark/skills/main/skills/finance/building-monte-carlo-simulations/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/building-monte-carlo-simulations/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How building-monte-carlo-simulations Compares

Feature / Agentbuilding-monte-carlo-simulationsStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Constructs Monte Carlo simulation frameworks with variance reduction and convergence analysis. Use when building MC simulations, implementing variance reduction, or assessing simulation accuracy.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# Building Monte Carlo Simulations

## When To Use

- Pricing path-dependent derivatives (Asian options, barrier options, lookbacks) where closed-form solutions are unavailable or unreliable
- Valuing structured products with complex payoff profiles, callable features, or multi-asset underlyings
- Estimating portfolio VaR/CVaR distributions under fat-tailed or correlated scenarios
- Modeling credit exposure profiles (PFE, EPE, EE) for counterparty risk
- Stress-testing structured note payoffs across thousands of market scenarios
- Validating or benchmarking analytical pricing models against simulation-based estimates

## Inputs To Gather

- **Underlying dynamics**: Stochastic process specification (GBM, Heston, SABR, local vol, jump-diffusion) with calibrated parameters (vol surface, mean-reversion speed, vol-of-vol, correlation matrix)
- **Payoff definition**: Terminal vs. path-dependent; barrier levels, averaging windows, autocall triggers, coupon schedules
- **Market data**: Spot prices, yield curves (OIS, SOFR), dividend schedules, credit spreads, FX rates as of valuation date
- **Simulation parameters**: Number of paths (N), time steps per path (M), time horizon, random seed policy
- **Variance reduction goals**: Target standard error, acceptable runtime budget, whether antithetic/control variate baselines exist
- **Discounting convention**: Risk-neutral vs. real-world measure; deterministic vs. stochastic rates [VERIFY: confirm measure and curve choice with desk]

## Workflow

1. **Specify the stochastic model**
   - Select the SDE(s) governing each risk factor (equity, rate, credit, FX)
   - Confirm calibration inputs: implied vol surface, correlation matrix, mean-reversion parameters
   - For multi-factor models, define the correlation structure and any factor reduction (PCA truncation)

2. **Design the path generation engine**
   - Choose discretization scheme: Euler-Maruyama for simple diffusions, Milstein or QE (quadratic-exponential) for Heston, log-Euler for GBM
   - Set time-step granularity — finer steps for barrier monitoring, coarser for vanilla European payoffs
   - Generate correlated normals via Cholesky decomposition of the correlation matrix
   - Implement random number generation with reproducible seeding (Mersenne Twister or Sobol sequences for quasi-MC)

3. **Implement variance reduction techniques**
   - **Antithetic variates**: Mirror each standard normal draw; halves variance for monotone payoffs at negligible cost
   - **Control variates**: Use a correlated instrument with known analytical price (e.g., vanilla European as control for an Asian option); estimate optimal beta coefficient from pilot run
   - **Importance sampling**: Shift drift to concentrate paths in the region that drives payoff variance (useful for deep OTM options or rare default scenarios)
   - **Stratified sampling**: Partition the uniform space into equal-probability strata; draw one sample per stratum to eliminate clustering
   - **Quasi-random sequences** (Sobol, Halton): Replace pseudo-random draws for faster convergence (O(1/N) vs. O(1/sqrt(N))); apply Brownian bridge construction to concentrate low-discrepancy benefit on key time steps

4. **Compute payoffs and discount**
   - Evaluate the payoff function along each simulated path (handle path-dependency: running max/min, arithmetic average, barrier crossings)
   - Discount each path payoff to valuation date using the appropriate curve
   - For American/Bermudan exercise, implement Longstaff-Schwartz (least-squares MC) regression at each exercise date

5. **Assess convergence and accuracy**
   - Compute sample mean and standard error: SE = sample_std / sqrt(N)
   - Build 95% and 99% confidence intervals around the price estimate
   - Run convergence diagnostics: plot price estimate vs. N; confirm SE decays at expected rate
   - Compare against closed-form benchmarks where available (Black-Scholes for vanillas, Heston semi-analytical for Europeans)
   - If SE exceeds tolerance, increase N or layer additional variance reduction before reporting

6. **Compute Greeks via simulation**
   - **Bump-and-reprice**: Shift each input parameter (spot, vol, rate) by a small delta; re-run simulation with same random seeds; finite-difference the prices
   - **Pathwise (IPA) method**: Differentiate the payoff along each path analytically for smooth payoffs — faster and lower variance than bump-and-reprice
   - **Likelihood ratio method**: For discontinuous payoffs (digitals, barriers) where pathwise fails
   - Report delta, gamma, vega, rho, theta with associated standard errors

## Output

- **Price estimate** with standard error, confidence interval, and number of paths used
- **Greeks table**: Delta, gamma, vega, rho, theta (with SEs) for each relevant risk factor
- **Convergence report**: SE vs. N plot, variance reduction efficiency ratios (variance with/without each technique)
- **Model specification summary**: SDE choice, discretization scheme, calibration inputs, time-step count
- **Assumptions and limitations log**: Which simplifications were made (constant rates, flat dividend yield, no jumps), and their expected impact on accuracy

## Quality Checks

- Confirm the simulation reproduces known analytical prices for vanilla test cases within 2 SEs
- Verify put-call parity holds (for European-style instruments) across simulated prices
- Check that antithetic/control variate application actually reduces SE (compare with and without)
- Validate that increasing N by 4x roughly halves the standard error (confirms sqrt(N) convergence)
- Ensure correlation matrix is positive semi-definite before Cholesky decomposition; flag and correct if not
- For barrier options, confirm that finer time steps reduce barrier-crossing bias (continuity correction applied where appropriate) [VERIFY: barrier monitoring frequency vs. contractual observation dates]
- Cross-check Greeks against analytical Greeks or trader intuition for sign and magnitude
- Confirm random seed reproducibility: identical seeds produce identical prices across runs

Related Skills

building-rolling-forecasts

11
from CaseMark/skills

Structures rolling forecast process with driver-based projections and continuous planning methodology. Use when creating rolling forecasts, updating financial projections, or managing continuous planning.

building-real-estate-pro-formas

11
from CaseMark/skills

Constructs property pro forma models with rent roll analysis, expense projections, and cash flow forecasting. Use when building real estate models, projecting property cash flows, or analyzing investment returns.

building-quantitative-trading-models

11
from CaseMark/skills

Structures systematic trading strategy development with signal generation, backtesting, and validation. Use when building quant models, backtesting strategies, or validating trading signals.

building-merger-models

11
from CaseMark/skills

Constructs merger consequence analysis with accretion/dilution, pro forma financials, and synergy assumptions. Use when modeling mergers, calculating accretion/dilution, or analyzing deal structures.

building-lbo-models

11
from CaseMark/skills

Constructs leveraged buyout models with debt capacity, returns analysis, and exit scenarios. Use when modeling LBOs, calculating sponsor returns, or analyzing leveraged transactions.

building-financial-projections

11
from CaseMark/skills

Constructs integrated three-statement financial models with scenario analysis and assumption documentation. Use when building financial models, projecting financial statements, or creating forecast scenarios.

building-equity-valuation-models

11
from CaseMark/skills

Constructs DCF, comparable company, and precedent transaction valuation models with sensitivity analysis. Use when valuing public companies, building financial models, or estimating fair value ranges.

building-driver-based-models

11
from CaseMark/skills

Constructs driver-based financial models with operational metric linkage and sensitivity analysis. Use when building driver-based forecasts, linking operational and financial metrics, or modeling business drivers.

building-annual-operating-plans

11
from CaseMark/skills

Structures annual operating plan development with revenue, expense, and capital budget integration. Use when building annual budgets, creating operating plans, or developing financial targets.

modeling-book-building-dynamics

11
from CaseMark/skills

Structures book-building analysis with demand tiers, allocation methodology, and price sensitivity assessment. Use when managing book-building, analyzing investor demand, or optimizing allocation strategies.

conducting-monte-carlo-portfolio-analysis

11
from CaseMark/skills

Runs Monte Carlo simulations for portfolio analysis with return distribution, tail risk, and path-dependent scenario evaluation. Use when running portfolio simulations, estimating tail risk, or analyzing return distributions.

building-venture-return-models

11
from CaseMark/skills

Constructs venture return models with entry valuation, follow-on reserve, multiple scenario exits, and portfolio-level fund math. Use when modeling VC returns, calculating fund economics, or projecting portfolio outcomes.