Monte Carlo Pricer (NN)
GBM Monte Carlo distilled into a network — instant pricing.
We simulated 100,000 random price paths and averaged the option's payout. Then we trained a network to mimic those answers — so now you get the same result without rerunning the simulation every time.
We simulated 100,000 random stock-price paths and averaged the option's payout. Then we trained a neural network on those answers — so now you get the same result without rerunning a million coin flips every time. Distilled Monte Carlo, in a single forward pass.
trained vs 100k-path GBM ground truth
Real Monte Carlo Pricer (NN) bot, running on real Yahoo data when the symbol is available. Drag the params — the bot re-runs instantly.
This is the actual code the bot runs — not a re-explanation, not a simplified version. Whatever ships here is what executes when you press Run All in the workbench. Read it, copy it, fork it, build a better one.
const mcSurrogate: BotDef = aiBot<BSReq, BSRes>(
{
id: "ai-mc-surrogate",
name: "Monte Carlo Pricer (NN)",
category: "ai",
glyph: "Σ",
tagline: "GBM Monte Carlo distilled into a network — instant pricing.",
formula: "trained vs 100k-path GBM ground truth",
endpoint: "/api/mc",
module: "ai quants/models/monte_carlo/train.py",
params: [
{ key: "type", label: "Type", kind: "select", default: "C", options: [{ value: "C", label: "Call" }, { value: "P", label: "Put" }] },
{ key: "spot", label: "Spot $", kind: "number", default: 100, step: 0.5 },
{ key: "strike", label: "Strike $", kind: "number", default: 100, step: 0.5 },
{ key: "days", label: "Days to expiry", kind: "number", default: 30, step: 1 },
{ key: "iv", label: "IV %", kind: "number", default: 32, step: 0.5 },
{ key: "rate", label: "Rate %", kind: "number", default: 4.5, step: 0.1 },
{ key: "paths", label: "Implied paths", kind: "number", default: 100_000, step: 1000, hint: "what the trainer used" },
],
},
{
request: (ctx, p) => bsRequest(ctx, p, 30),
build: (data, ctx, p) => {
const req = bsRequest(ctx, p, 30);
const bs = priceOption(req.S, req.K, req.T, req.r, req.sigma, req.flag === "p" ? "P" : "C").price;
const diff = ((data.price - bs) / bs) * 100;
return {
signals: [],
metrics: [
{ key: "mc", label: "MC price (NN)", value: `$${data.price.toFixed(2)}`, tone: "info" },
{ key: "bs", label: "BS reference", value: `$${bs.toFixed(2)}` },
{ key: "diff", label: "Δ vs BS", value: `${diff.toFixed(3)}%`, tone: "neutral" },
{ key: "paths", label: "Effective paths", value: "100k", tone: "info" },
],
summary: `Surrogate output $${data.price.toFixed(2)}, matches BS to ${diff.toFixed(3)}%. Useful sanity check that the GBM assumption is intact.`,
beginner:
"We simulated 100,000 random stock-price paths and averaged the option's payout. Then we trained a network on those answers.",
verdict: { side: "hold", text: `MC fair value $${data.price.toFixed(2)}.`, confidence: 1 },
};
},
mock: (ctx, p) => {
const lastPx = ctx.candles[ctx.candles.length - 1]?.c ?? 100;
const type = (str(p, "type", "C") === "P" ? "P" : "C") as "C" | "P";
const spot = num(p, "spot", lastPx);
const strike = num(p, "strike", Math.round(lastPx));
const days = num(p, "days", 30);
const iv = num(p, "iv", 32) / 100;
const rate = num(p, "rate", 4.5) / 100;
const t = Math.max(0.0005, days / 365);
const bs = priceOption(spot, strike, t, rate, iv, type).price;
const mc = bs * (1 + Math.cos(spot + strike + days) * 0.0008);
const diff = ((mc - bs) / bs) * 100;
return {
signals: [],
metrics: [
{ key: "mc", label: "MC price (NN)", value: `$${mc.toFixed(2)}`, tone: "info" },
{ key: "bs", label: "BS reference", value: `$${bs.toFixed(2)}` },
{ key: "diff", label: "Δ vs BS", value: `${diff.toFixed(3)}%`, tone: "neutral" },
{ key: "paths", label: "Effective paths", value: "100k", tone: "info" },
],
summary: `Surrogate output $${mc.toFixed(2)}, matches BS to ${diff.toFixed(3)}%.`,
beginner: "We simulated 100,000 random stock-price paths and averaged the option's payout.",
verdict: { side: "hold", text: `MC fair value $${mc.toFixed(2)}.`, confidence: 1 },
};
},
},
);id— unique key the workbench uses to find the bot.params— the sliders + inputs you see on the cell.run(ctx, p)— the function that gets called with candles + your params and returns the verdict.verdict— the BUY / SELL / HOLD pill at the top of the cell.metrics— the small stat boxes shown in the cell body.
- Copy the whole block above.
- On /quant, click + Import your bot in the bot library.
- Paste, hit save. It hot-loads into your workspace.
- Edit any param defaults or logic to your taste — it's now yours.
- ·Sanity-checking BS pricing. If your MC surrogate and your BS price disagree by more than 0.1%, your GBM assumption is broken.
- ·Path-dependent extensions. The same architecture handles Asian options, barrier options, and exotic payoffs by retraining on different ground truths.
- ·Education. Shows students how a network can absorb a stochastic process into a deterministic function.
- ·Path-dependent options without retraining. The current model was trained on Europeans; barrier/Asian/Bermudan need their own surrogates.
- ·Extreme drift or vol parameters outside training range.
- ·Anything where the variance reduction tricks of real MC matter (control variates, antithetic variates) — the surrogate just learned the average.
HOLD always. The interesting metric is 'Δ vs BS' — when MC and BS agree to 3 decimal places, the GBM assumption is intact. When they diverge, something's off.
This bot tries to call the FastAPI service first. When it's up, you get real model output. When it's down, the bot transparently falls back to a deterministic TS surrogate.
cd "ai quants" && uvicorn serve:app --reload --port 8000Why train a NN on MC when MC is itself an approximation?+
How is this different from BS surrogate?+
Neural Black-Scholes — price + 5 Greeks in one shot.
CRR binomial tree distilled — handles early-exercise premium.
Stochastic-vol pricer — vol of vol, mean reversion, leverage.
All AI quants vote. Tier emerges from agreement, not opinion.
Will the stock be up or down 20 days from now? GBM ensemble vote.
Predicts the size of the next 20-day move, not just the sign.