Manual 02 Underlyings and curves
Market data
Underlying
The spot price and the dividend yield of an asset are stored in an Underlying, passed to the metrics next to the model (the models hold only their parameters). The dividend yield is a number or a curve, a type parameter of the one Underlying type:
Underlying(100.0) # no dividends
Underlying(100.0, 0.01) # 1% continuous dividend yield
Underlying(100.0, FinancialMonteCarlo.Curve([0.01, 0.015, 0.02], 1.0)) # time dependent dividendsZero rates
Discounting and the risk neutral drift come from a ZeroRate, of a constant rate or of a curve (again one type, the rate a type parameter):
ZeroRate(0.02) # constant rate
ZeroRate(FinancialMonteCarlo.Curve([0.00, 0.01, 0.02], 1.0)) # instantaneous rates on a uniform grid up to 1.0
ZeroRate(FinancialMonteCarlo.ImpliedCurve([0.01, 0.015], [0.5, 1.0])) # from zero rates quoted at given maturitiesCurves
Time dependent quantities are represented as curves of instantaneous rates, linearly interpolated between the nodes. Models never need the instantaneous value itself, only its integral between two times, which is what is used both for the drift of each simulation step and for discounting.
FinancialMonteCarlo.Curvebuilds the curve directly from instantaneous rates;FinancialMonteCarlo.ImpliedCurvebuilds the instantaneous curve that reproduces given zero rates, i.e. such that $\int_0^{T_i} r(t)\,dt = r_i T_i$. This is what you want when you have market quoted zero rates or dividend yields.
Both take two vectors or two tuples. The nodes are stored as static vectors (StaticArrays), so a curve, an underlying and a zero rate holding one are isbits values: Enzyme differentiates them without runtime activity and a GPU kernel can capture them. The number of nodes is part of the type, so a curve built from vectors has a type known only at run time: build it once, outside the code that is differentiated or run in a loop, or from tuples, which give an inferred constructor.
Curves combine with numbers through +, -, * and /, applied to the values. Two curves can only be added or subtracted: the result is a FinancialMonteCarlo.CurveDifference, whose integral is the difference of the integrals of the two curves, exact and without new nodes. This is how the drift $r - d$ is formed when both the rate and the dividend are curves. Curves are not multiplied or divided by each other.
There is no support for multi-currency.
See Market data in the API reference for the full signatures.