Docs / nablatensor-quant / com.nablatensor.quant

final class

MonteCarlo

Records a Product once against a market record M and replays it for price and every Greek from one adjoint sweep. M is EquityMarket for the built-in catalogue; any double-only record works.

try (MonteCarlo<EquityMarket> mc = MonteCarlo.of(Products.asianCall())
        .market(EquityMarket.atmOneYear())
        .steps(252)                       // or .timeGrid(TimeGrid.of(t1, t2, ...))
        .greeks()
        .fastest()
        .build()) {

  Nabla.TypedValuation<EquityMarket> p = mc.run(1_000_000, 42L);
  System.out.println(p.price() + " delta " + p.greek(EquityMarket::spot));

  // Seam 2: move the market on the compiled kernel, no re-record.
  var bumped = mc.run(mc.market().withSpot(101.0), 1_000_000, 42L);
}

Building records the tape and generates the kernel; running is a launch. Hold the MonteCarlo, re-run it under as many markets and seeds as you like.

Methods

static Builder<M> of(Product<M> product)
M market()

The market the tape was recorded against; the default for long).

boolean hasGreeks()

Whether this kernel was built with the adjoint sweep.

String engine()
int nodes()
double recordSeconds()
double buildSeconds()
Nabla.TypedValuation<M> run(long scenarios, long seed)

Replays under the recorded market.

Nabla.TypedValuation<M> run(M state, long scenarios, long seed)

Replays under an arbitrary market state — a kernel argument, so nothing rebuilds.

void close()