Page cover

Run 1B option simulations

In this example we:

  • Simulate 1,000,000,000 option price paths.

  • Split the run into 2,000 independent chunks.

  • Return sums and squared sums, then compute the final price and error bar locally.

A smaller run is not the same experiment if the whole point is the error bar.

Experiment: European call option

Each path is independent, so the job does not need shared state or a distributed framework.

import math
from dataclasses import dataclass

import numpy as np
from burla import remote_parallel_map

TOTAL = 1_000_000_000
N_CHUNKS = 2_000
PER_CHUNK = TOTAL // N_CHUNKS

Step 1: Plan independent chunks

The chunk id becomes part of the random seed, so reruns are reproducible without shared state.

Step 2: Simulate on the worker

The worker is normal NumPy. It returns enough statistics to combine results exactly.

No simulated path comes back to the client. Only sufficient statistics do.

Step 3: Smoke test one chunk

Run one chunk first to check memory, runtime, and output shape.

Step 4: Run and reduce locally

The result list is tiny because the workers do not return raw paths.

What's the point?

Monte Carlo is nice because the distributed-systems part should be almost nonexistent. Pick independent chunks, seed them cleanly, return sufficient statistics.

Do not ship every simulated path back to the client. That would turn a clean simulation into an output-size problem. Return sum, sum_sq, counts, quantile sketches, or top events. The worker function is the experiment. The input list is the queue.

Last updated