AgentStack
Browse Sign in
Browse Why AgentStack Sell Docs
Sign in
SKILL verified MIT Self-run

Monte Carlo Pricing

skill-brainbytes-dev-everything-claude-trading-monte-carlo-pricing · by brainbytes-dev

A Claude skill from brainbytes-dev/everything-claude-trading.

No reviews yet
0 installs
17 views
0.0% view→install

Install

$ agentstack add skill-brainbytes-dev-everything-claude-trading-monte-carlo-pricing

✓ scanned · ✓ verified, works with Claude Code, Cursor, and more.

Security review

✓ Passed

No issues found. Passed automated security review. · v0.1.0 How review works →

  • Prompt-injection patterns
  • Secret / credential exfiltration
  • Dangerous shell & filesystem operations
  • Untrusted network calls
  • Known-malicious package signatures

What it can access

  • Network access No
  • Filesystem access No
  • Shell / process execution No
  • Environment & secrets No
  • Dynamic code execution No

From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.

View the full security report →

Verified badge

Passed review? Show it. Paste this badge into your README, it links to the public security report.

AgentStack Verified badge Links to your public security report.
[![AgentStack Verified](https://agentstack.voostack.com/badges/verified.svg)](https://agentstack.voostack.com/security/report/skill-brainbytes-dev-everything-claude-trading-monte-carlo-pricing)

Reliability & compatibility

Security review passed
0 installs to date
no reviews yet
4mo ago

Declared compatibility

Claude CodeClaude Desktop

Compatibility is declared by the source manifest. End-to-end runtime verification is coming, see below.

Preview Execution monitoring

We're building live execution health for every listing: tool-call success rate, median latency, uptime, and last-checked timestamps, measured, not self-reported. It isn't live yet, so we don't show numbers we can't stand behind.

How agent discovery & health will work →
Are you the author of Monte Carlo Pricing? Claim this listing to set pricing, connect Stripe payouts, and keep 70% of every sale.
Sign up to claim

About

Monte Carlo Methods for Derivatives Pricing

> Random number generation, GBM simulation, path-dependent options, variance reduction, Longstaff-Schwartz for Americans, and convergence analysis.

When to Activate

  • User pricing path-dependent or exotic derivatives (Asian, barrier, lookback)
  • Pricing options on multiple underlyings (basket, rainbow, worst-of)
  • American option pricing via Longstaff-Schwartz regression
  • Evaluating variance reduction techniques for pricing efficiency
  • Multi-factor model simulation (stochastic vol, rates, credit)
  • Convergence analysis and error estimation for MC prices

Core Concepts

Monte Carlo Pricing Framework

The price of a derivative under risk-neutral pricing:

V0 = exp(-rT) * E^Q[payoff(ST)]

Monte Carlo estimates this expectation by:

  1. Simulating N paths of the underlying under the risk-neutral measure
  2. Computing the payoff for each path
  3. Averaging the payoffs and discounting

VMC = exp(-rT) (1/N) sum{i=1}^{N} payoff_i

Standard error = sigmapayoff / sqrt(N), where sigmapayoff is the std dev of simulated payoffs.

GBM Path Simulation

Under risk-neutral GBM: dS = rSdt + sigmaSdW

Exact Simulation (log-normal): S(t+dt) = S(t) exp((r - sigma^2/2)dt + sigmasqrt(dt)Z) where Z ~ N(0,1)

  • Exact: no discretization error regardless of dt
  • Use for simple GBM dynamics (constant vol, no barriers)

Euler Discretization: S(t+dt) = S(t) + rS(t)dt + sigmaS(t)sqrt(dt)*Z

  • Introduces discretization bias of order O(dt)
  • Required for more complex SDEs (stochastic vol, local vol) where exact simulation is unavailable
  • Can produce negative stock prices; use log-Euler: ln(S(t+dt)) = ln(S(t)) + (r - sigma^2/2)dt + sigmasqrt(dt)*Z

Milstein Scheme: S(t+dt) = S(t) + rS(t)dt + sigmaS(t)sqrt(dt)Z + 0.5sigma^2S(t)(Z^2 - 1)*dt

  • Higher-order accuracy: O(dt) vs. O(sqrt(dt)) for Euler
  • For GBM, Milstein = exact simulation (coincidence of the specific SDE)
  • Useful for general SDEs where exact simulation is unavailable

Random Number Generation

  • Use high-quality pseudo-random generators: Mersenne Twister (MT19937) is standard
  • Box-Muller or inverse CDF to transform uniform to normal variates
  • Quasi-random sequences (Sobol, Halton) for faster convergence:
  • QMC convergence: O(1/N) vs. O(1/sqrt(N)) for pseudo-random MC
  • Sobol sequences preferred for high dimensions (up to 1000+ dimensions)
  • Scrambled Sobol: adds randomization for error estimation while preserving QMC convergence
  • Seed management: fix seeds for reproducibility; vary seeds for independence testing

Multi-Asset Simulation

For correlated assets with covariance matrix Sigma:

  1. Cholesky decomposition: Sigma = L * L' where L is lower triangular
  2. Generate independent Z = [Z1, ..., Zd] ~ N(0, I)
  3. Correlated normals: W = L * Z
  4. Simulate each asset using its correlated Brownian increment W_i
  5. For d assets and N time steps: need d*N normal variates per path

Methodology

Variance Reduction Techniques

Antithetic Variates

  • For each path using Z, also simulate the path using -Z
  • Average the two payoffs: reduces variance when payoff is monotonic in Z
  • Variance reduction factor: up to 2x for simple payoffs
  • Free to implement (no additional random numbers needed)
  • Works poorly for payoffs that are symmetric in Z (e.g., straddles)

Control Variates

  • Use a correlated quantity with known expected value as a control
  • Adjusted estimate: VCV = VMC + beta * (E[C] - C_MC)
  • beta = -cov(payoff, C) / var(C) (optimal beta)
  • Common controls: stock price itself (E[ST] = S0*exp(rT)), geometric Asian option (closed-form), BSM European option
  • Can reduce variance by 10-100x for well-chosen controls
  • Multiple controls: use regression to find optimal combination

Importance Sampling

  • Change the probability measure to sample more from the region that matters
  • V = E^P[payoff] = E^Q[payoff * dP/dQ] where Q is the importance sampling distribution
  • Shift the mean of the GBM drift to make ITM paths more likely for OTM options
  • Optimal importance distribution minimizes the variance of the weighted estimator
  • Risk: poor choice of Q can increase variance; requires care

Stratified Sampling

  • Divide the probability space into strata; sample uniformly within each stratum
  • Ensures tails are sampled proportionally
  • Latin hypercube sampling: generalization to multiple dimensions
  • Typically combined with other techniques for maximum benefit

Path-Dependent Option Pricing

Asian Options

  • Payoff depends on the average price: max(avg(S) - K, 0) for fixed-strike Asian call
  • Simulate full price path, compute the average at each monitoring date
  • Arithmetic average: no closed-form, MC is the standard method
  • Geometric average: closed-form exists, use as control variate for arithmetic
  • Variance reduction: geometric Asian control variate reduces variance by 50-90%

Barrier Options

  • Payoff depends on whether the path crosses a barrier
  • Naive MC with discrete monitoring misses barrier crossings between time steps
  • Brownian bridge correction: compute probability of crossing barrier between observed points
  • Continuity correction (Broadie-Glasserman-Kou): adjust barrier by 0.5826sigmasqrt(dt) for discrete monitoring approximation of continuous barrier
  • Importance sampling: shift drift toward the barrier to increase the frequency of barrier hits

Lookback Options

  • Payoff depends on the maximum or minimum price over the path
  • Simulate path and track running max/min
  • Discretization bias: discrete monitoring underestimates continuous max/min
  • Correction: apply Brownian bridge to estimate continuous extremum between discrete points

Longstaff-Schwartz for American Options

The LSM algorithm uses regression to estimate continuation value:

  1. Simulate N paths of the underlying to maturity
  2. At the final time step: exercise value = intrinsic value
  3. Work backward from T-dt to dt:

a. At time step t, identify in-the-money paths b. Regress discounted future cashflows on basis functions of current stock price (e.g., 1, S, S^2, or Laguerre polynomials) c. Fitted regression = estimated continuation value C(S) d. Exercise if intrinsic value > C(S); otherwise continue

  1. Option price = average of discounted cashflows along optimal exercise paths

Key implementation details:

  • Basis functions: polynomials of S (degree 3-5 usually sufficient), Laguerre or Hermite polynomials
  • Only use ITM paths for regression (reduces noise)
  • Forward pass after backward exercise decisions to get unbiased estimate
  • Bias: LSM gives a lower bound (suboptimal exercise policy); use dual method for upper bound
  • N = 50,000-200,000 paths typically needed for stable estimates

Examples

European Call via MC

S=100, K=100, r=5%, sigma=30%, T=1.0
Exact BSM price: $14.23

Standard MC (N=10,000): $14.35, SE=$0.28, 95% CI: [$13.80, $14.90]
Standard MC (N=100,000): $14.21, SE=$0.09, 95% CI: [$14.03, $14.39]
Antithetic (N=50,000 pairs): $14.24, SE=$0.06, 95% CI: [$14.12, $14.36]
Control variate + antithetic: $14.23, SE=$0.02, 95% CI: [$14.19, $14.27]

Variance reduction: 196x improvement from SE=$0.28 to SE=$0.02

Arithmetic Asian Option with Control Variate

S=100, K=100, r=5%, sigma=30%, T=1.0, monthly averaging (12 dates)

Geometric Asian (closed-form): $8.42
Arithmetic Asian (MC, N=100,000): $8.89, SE=$0.07
With geometric Asian control variate: $8.91, SE=$0.01

Control variate reduced SE by 7x (variance by 49x).
The correlation between arithmetic and geometric Asian payoffs is 0.998.

Longstaff-Schwartz American Put

S=100, K=100, r=5%, sigma=30%, T=1.0, monthly exercise (12 dates)
N=100,000 paths, basis functions: 1, S, S^2, S^3

European put (MC): $10.08
American put (LSM): $10.85
Early exercise premium: $0.77

Regression at t=0.5 (example):
  Continuation value = 2.31 + 0.15*S - 0.002*S^2 (fitted)
  At S=85: continuation = 2.31 + 12.75 - 14.45 = $0.61
  Intrinsic = 100 - 85 = $15.00
  Decision: exercise (intrinsic >> continuation)

Binomial tree (N=500) benchmark: $10.87 — LSM within $0.02.

Quality Gate

  • Standard error must be reported with every MC price — a price without error bounds is meaningless
  • SE target: less than 1% of option price, or less than $0.05, whichever is tighter
  • Convergence check: verify that price stabilizes as N increases (no systematic drift)
  • At least one variance reduction technique should be applied (antithetic is minimum)
  • For barrier options: Brownian bridge correction must be applied; verify with analytical formula where available
  • For American options (LSM): validate against binomial tree for simple cases; difference should be <$0.05
  • Random number generator must pass standard tests (Mersenne Twister or better)
  • For QMC (Sobol): use scrambled sequences and randomize for error estimation
  • Discretization: use exact simulation for GBM; for other SDEs, verify convergence by halving dt
  • Multi-asset: verify Cholesky decomposition reproduces target correlation matrix (simulate and measure)
  • Seed must be documented for reproducibility

Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

Install and usage instructions live in the source repository linked above.

Reviews

No reviews yet, be the first.

Versions

  • v0.1.0 Imported from the upstream source.