The dal package wraps the C++ public facade with Python objects and
keyword-only settings. See installation
for supported interpreters and wheel platforms; the examples below are Python
specific. The numerical methods themselves are documented with C++ examples
in yield curves, CCY curves,
Monte Carlo, and PDE.
Import the installed package with:
import dal| Workflow | Python entry points |
|---|---|
| Dates/global state | Date_, Year, Month, Day, EvaluationDate_Set, EvaluationDate_Get |
| Script products | Product_New, Product_Describe, Product_Debug, Product_DebugJson, Product_DebugTree |
| Models | BSModelData_New, LocalVolSurfaceData_New, BSLocalVolModelData_New, HybridModelData_New |
| Valuation | MonteCarlo_Value, MonteCarlo_ValueWithSettings, ScriptValuation_Explain, ScriptSimulation_Explain |
| Script settings | ScriptProductSettings_, ScriptValuationSettings_, MonteCarloSettings_, TodayFixingPolicy_ |
| Random generation | PseudoRSG_New, SobolRSG_New, *_Get_Uniform, *_Get_Normal |
| Calendar operations | Holidays_, Is_BizDay, NextBizDay, PrevBizDay, Adjust |
| Curves | DiscountZeroRate_New, convention/instrument builders, CurveCalibrationSpecBuilder_, CalibrateSingleCurve, CalibrateMultiCurveBundle, CalibrateXccyMarket, CalibrateJointXccyMarket |
| XCCY reset data | FixingIdentity_, FxResetConvention_, MarketFixingSnapshot_New, CrossCurrencySwapConfigBuilder_, XccyNotionalMode |
| Rate cashflow pricing | RateTradeDefinition_, typed terms, RatePricingMarket_, PriceRateTrades, RateTradeNodeSensitivities, RateTradeNodeSensitivitiesBatch, AggregateRatePortfolioNodeRisk, quote-risk provenance builders, AggregateRatePortfolioQuoteRisk |
| Convenience calibration | calibrate_curve from dal/api.py |
| Early-exercise PDE | EarlyExercisePdeRequest_, EarlyExercisePdeSettings_, EarlyExercisePdeResult_New |
The basic valuation shape is:
import dal
today = dal.Date_(2022, 9, 25)
dal.EvaluationDate_Set(today)
product = dal.Product_New(
["STRIKE", dal.Date_(2023, 9, 25)],
["100.0", "intrinsic = MAX(spot() - STRIKE, 0.0) call PAYS intrinsic"],
)
model = dal.BSModelData_New(100.0, 0.2, 0.05, 0.02)
result = dal.MonteCarlo_Value(product, model, 2**16, enable_aad=True)Both Python Value entries require an integer or valid __index__ path count
in 1..2147483647, excluding bool and enums; floats such as 1.0 are rejected.
The bindings copy settings and native handles before releasing the GIL for
valuation. EvaluationDate_Get / EvaluationDate_Set also release it before
native synchronization. A setter waits for an in-progress valuation; a getter
can read the stable current date while valuation runs.
The shared RNG input domains and exhaustion contract defines seed, dimension and path ranges and Python/native error types.
For precise-CDF-polished Sobol normal draws, pass both flags explicitly:
rsg = dal.SobolRSG_New(i_path=0, ndim=3, precise=True, polish=True)
normals = dal.SobolRSG_Get_Normal(rsg, 1024)See the complete mixed-coupon recipe for a fixed-coupon trade with an explicit holiday, past fixing and native AAD.
Construct keyword-only CompoundedOisFixedRow_, CompoundedOisCouponRow_,
CompoundedOisObservationRow_ and HolidayCenterData_ values, then assemble
CompoundedOisScriptSpec_. There is no inferred calendar. Dates use Date_;
fixing times use DateTime_(date, 0) and must be midnight. Call
CompoundedOis_Prepare(spec, valuation) with an explicit fixing snapshot,
then CompoundedOisScriptInstrument_New(tables).
For explicit rule_id="dal.compounded-ois-cashflows/2", pass
observation_convention=dal.CompoundedOisObservationConvention_(mode, ...)
and omit or empty observations. Exact modes are None, Lookback,
ObservationShift and Lockout; the two business-day counts are keyword-only
integers in the native int range, excluding bool and floats. None uses zeros;
Lookback/ObservationShift require positive lookback_business_days only;
Lockout requires positive lockout_business_days only. Unknown fields/tokens,
incompatible counts and nonempty manual /2 observations fail explicitly.
The default /1 still requires manual observations and rejects a convention.
CurveScriptEvaluationRequest_ takes geometry, market, valuation,
parameters and compounded_ois=tables. Optional measure_ids default to
["Price", "ParRate"], evaluation to AutoFast, derivative_method to
None and difference_step to 1e-6. Use AAD or FiniteDifference for raw
native partials. CurveScriptInstrument_Evaluate(instrument, request) returns
read-only owning values with independent container getters, including
cashflows, observations, free_parameters, measure_units and report.
CurveScriptEvaluation_Get_Value and CurveScriptEvaluation_Get_NativePartials
reject unavailable values; optional settled amounts/DFs/rates are None.
CalibrationError retains its diagnostic and report after input destruction.
CurveScriptEvaluation_Get_Table accepts summary, measures, parameters,
cashflows, observations and observation_schedule.
ON routing uses CurveScriptRoute_(..., projection=True, overnight=True),
geometry.target_overnight_route, market.overnight_curves and the explicit
use_target_curve flag. Unset tenors read as None.
Calibration specs accept compounded_ois=[tables].
Verified native /1 and /2 contracts also have a separate fixed-contract
Price quote-risk workflow: register all
fit and prospective PV tables in compounded_ois before calibration. Full and
PV-only require a square full-rank EXACT root and matching frozen context.
An unregistered/rebound PV, live-quote payoff, non-Price measure or stale context
returns owning Unavailable diagnostics; numeric getters reject access.
ON/ON2 remain unsupported by general script/MC and legacy tenor staging.
CompoundedOis_Get_ObservationSchedule(tables) returns a 22-column table.
Prepared/evaluated observation_schedule records are read-only copies;
selector CurveScriptEvaluation_Get_Table(result, "observation_schedule")
returns 26 columns: the same 22-column prefix plus source,rate,source_row,statement.
The original observations table retains 15 columns. source_row is one-based;
row,coupon_row,reused_from_row,statement are zero-based. Missing values are
None, and getters return independent row lists with native dates/times.
See the ordered columns
and four-mode example.
Owning results survive input deletion; they do not add pickle/session replay.
Build the module against matching core/public headers and libraries after
layout changes.
The shared contract defines the financial rules and defaults.
Given an existing fit = dal.Calibrate_CurveInstruments(spec) and its fixed
bound instrument, capture a snapshot with explicit numerical limits:
accuracy = dal.ScriptCurveQuoteRiskAccuracy_(
residual_absolute_limits=[1e-12] * len(spec.observations),
min_reciprocal_condition=1e-10,
response_backward_error_limit=1e-12)
snapshot = dal.ScriptCurveQuoteRiskSnapshot_New(fit, accuracy)
if snapshot.risk_available:
result = dal.CalibrationInstrument_ValueWithQuoteRisk(instrument, snapshot, spec)
if result.available:
pv, raw, dv01 = result.pv, result.raw_sensitivity, result.dv01
else:
diagnostics = result.diagnostics
else:
diagnostics = snapshot.diagnosticsThese are sample limits in raw observation units, not a universal accuracy
default. Set pv_only=True to skip the full parameter-response matrix when only
PV quote risk is needed; risk_available remains the PV admission check and
mapping_available is false. An accepted ordinary fit can still fail risk
admission. The entry
supports single-target, square full-rank EXACT deterministic fits with fixed
background curves; GSR, XCCY and MC propagation are outside this entry.
Pass request=dal.ScriptCurveQuoteRiskRequest_(quote_ids=[...]) for selected
case-sensitive IDs in that order. Empty selection means all quotes; the
result's quote_axis retains original ordinals, quote values, units and
conventions. Defaults are measure_id="Price" and live_quote_payoff=False.
Unknown/duplicate IDs, a non-Price measure or a live-quote payoff return owning
Unavailable results. Coupons stay fixed. Raw sensitivities are signed price
per decimal Rate/BasisSpread; dv01 multiplies by 1e-4 once, preserving
currency and notional. Read result.currency with the price.
Settings are strict keyword-only values; numeric fields reject booleans and
unknown fields raise TypeError. Input conversion completes before native work
releases the GIL. Properties return passive copies and survive input deletion.
Malformed required contexts throw dal.CalibrationError; valid stale contexts
or numerical rejection return inspectable status="Unavailable" results.
Numeric getters then raise RuntimeError. Missing optional evidence is None.
The matching ScriptCurveQuoteRiskSnapshot_Get_* and
ScriptCurveQuoteRiskResult_Get_* functions provide status, axes, diagnostics
and result values. See the full contract and fit construction
and runnable C++ facade example.
The settings entry points are:
Product_New(events_dates, events, *, settings=None)
MonteCarlo_ValueWithSettings(product, modelData, num_path, *, valuation=None, simulation=None)
Product_Describe(product)
ScriptValuation_Explain(product, modelData, *, valuation=None)
ScriptSimulation_Explain(product, modelData, num_path, *, valuation=None, simulation=None)
settings, valuation, and simulation take ScriptProductSettings_,
ScriptValuationSettings_, and MonteCarloSettings_ respectively, or None
for fresh defaults. Their constructors use keyword-only fields. The
Python settings reference
owns the complete field list, defaults, accepted Python types and copy semantics.
For numerical behavior, see normal precision,
exercise-policy risks and
training checkpoints.
For multi-asset EXERCISE, pass a list of at most three state names, such as
ScriptProductSettings_(regression_features=["EQ[A]", "VAR[runningAverage]"]).
EQ[...] samples a model equity at each exercise date; VAR[...] reads a
scalar script variable at that event. The list is stored with the product and
is available in Product_Describe. With no list, default_index remains the
single regression state for a multi-asset exercise product.
Model-supported IR discount-factor, Libor, and swap names can also be selected.
Rate-only GSR exercise requires an explicit list, such as
ScriptProductSettings_(regression_features=["IR[USD,SWAP,5Y]"]); see
GSR Bermudan products.
Snapshot keys require DateTime_(date, 0) for exact midnight.
fixings=None captures current global history; an explicit empty snapshot
never falls back to it. Global capture is sequential, not atomic across
sequences, and requires callers to exclude concurrent fixing writes.
The FIX source rules
and script model index
apply unchanged: past history, today's selected policy, future model, and no
fixing after its event. The complete
Python example supplies a legal
BS model and checks PV=260 / d_SCALE=80 for historical SCALE state plus a
retained future fixing. See the
Python settings reference
for defaults, strict field types, setters, detached property copies and
copy/deepcopy semantics. Snapshot handles share immutable data; workers use
native copies without Python callbacks or mutable dictionaries.
High-level Describe returns a dal.script-product/2 dictionary without market
I/O, global-date access or valuation phase. High-level Explain returns a
dal.script-valuation/1 dictionary from one independent default exact/compiled
price preparation. It may read history and initialize a model, but generates
no paths or workers and accepts no simulation settings. It neither describes
a preceding compiled/AAD call nor caches the next Value. High-level
ScriptSimulation_Explain runs the full double valuation with the given
num_path on exercise products (plain products skip the run, since their
exercise events array is empty either way) and returns the
dal.script-simulation/1 exercise diagnostics dictionary. Low-level dal._dal
and dal.dal diagnostics return raw JSON strings with the same schemas.
Diagnostics are not loadable archives; Python has no public script-product
serializer. Value results contain only already-normalized PV and optional
d_ parameter risks, with no fixing-risk or diagnostic keys.
Existing three-to-eight-argument MonteCarlo_Value retains its original
keywords/defaults and valid flag/float conversions. It cannot take the new
settings, and the settings entry cannot take flat simulation options. The
high-level product date keyword is events_dates; low-level Product_New
uses dates and requires Cell_ elements. High-level conversion leaves existing
cells intact. Unknown keywords, wrong types or extra positional settings raise
TypeError; unknown attributes raise AttributeError; invalid values and native
failures raise RuntimeError with field/constraint and source context.
Product_DebugJson remains a JSON string with schema /1 and rejects FIX or
nonempty defaults with DebugSchemaUnsupported.
MonteCarlo_ValueWithRisk(product, modelData, num_path, *, request=None, valuation=None, simulation=None) returns a read-only RiskResult_.
The omitted simulation enables native AAD; an explicit
MonteCarloSettings_(enable_aad=False) requests price only.
request = dal.RiskRequest_(
inputs=["constant:0", "model:1"], report_factors=[0.5, 0.01],
)
risk = dal.MonteCarlo_ValueWithRisk(product, model, 2**16, request=request)
raw = risk.jacobian.to_rows() # [[strike derivative, volatility derivative]]
reported = risk.reported_jacobian.to_rows()
method = risk.provenance.methodRequest fields are keyword-only inputs, outputs, report_factors and
numeric_payload_budget_bytes. IDs/factors accept lists or tuples, with None
meaning omission. Empty native inputs preserve the (1, 0) matrix and smoothed
price; price-only cannot select nonempty inputs. Budget is a nonnegative integer
excluding bool. It covers returned numeric values/Jacobian, excluding metadata,
worker/tape storage and getter copies.
output_ids, values, input_axis, complete_input_axis, jacobian,
reported_jacobian, provenance and legacy_values expose detached data.
Changing a returned matrix or copied simulation settings cannot change the result.
Coordinate IDs identify model/script ordinals within the retained snapshot;
physical units can be unknown. The raw legacy view rejects display collisions.
The AAD methodology
describes the retained product/model/history settings and mixed LSM policy risk.
Product_Get_RiskOutputs(product) returns detached read-only scalar coordinates
with id, label and slot. The payoff receiver has ID payoff; other scalar
slots use output:<ordinal>. Labels are display text. Vector storage is excluded.
The basic valuation example defines today, product and
model. Its two scalar outputs are the intrinsic value at expiry and the call
payment. The weights below follow that order.
valuation = dal.ScriptValuationSettings_(evaluation_date=today)
output_ids = [item.id for item in dal.Product_Get_RiskOutputs(product)] # ["output:0", "payoff"]
request = dal.WeightedRiskRequest_(
outputs=output_ids, weights=[2.0, -0.5],
inputs=["model:0", "model:1"], report_factors=[1.0, 0.01],
)
risk = dal.MonteCarlo_ValueWithWeightedRisk(
product, model, 2**16, request=request, valuation=valuation,
)
objective = risk.weighted_value
components = risk.component_means
gradient = risk.jacobian.to_rows() # one row in requested input orderWeightedRiskRequest_ fields are keyword-only: inputs, outputs, weights,
report_factors and numeric_payload_budget_bytes. None selects the default
payoff, unit weights and native input set. ID/numeric sequences accept lists or
tuples; numeric entries require int/float and exclude bool, enum and text.
Native preflight rejects nonfinite/mismatched weights, empty/repeated/unknown
outputs, unsupported exercise and fully expired products before history/workers.
Signed/zero weights are valid; every selected component must remain finite.
The valuation has the scalar entry's keyword-only request, valuation and
simulation settings and defaults to native AAD. Explicit price-only execution
uses MonteCarloSettings_(enable_aad=False). Empty native inputs preserve AAD
smoothing and a (1, 0) matrix. Requests/settings are copied before the GIL is
released for native work.
weighted_value, component_means, weights, output_axis, jacobian,
reported_jacobian, input_axis, complete_input_axis and provenance are
read-only owning result properties. Container/matrix getters return independent
copies, and copy/deepcopy retain the passive result after caller objects die.
The numeric budget covers 8 * (1 + inputs + 2 * outputs) bytes: objective,
raw gradient, component means and weights. Metadata, worker/tape storage,
source snapshots and detached getter copies are excluded. See the
weighted AAD methodology.
MonteCarlo_ValueWithJacobianRisk returns owning output means and a complete
selected-output by selected-input matrix. Choices after product, model and
path count are keyword-only. This example reuses valuation and output_ids
from the weighted risk example.
request = dal.JacobianRiskRequest_(
outputs=output_ids, inputs=["model:0", "model:1"],
max_block_width=2, scratch_capacity_budget_bytes=8 * 1024 * 1024,
)
risk = dal.MonteCarlo_ValueWithJacobianRisk(
product, model, 1024, request=request, valuation=valuation,
)
means = risk.values
raw = risk.jacobian.to_rows() # Two output rows, each with two input derivatives
reported = risk.reported_jacobian.to_rows()
work = risk.execution.executed_pathsRequest fields are read-only: inputs, outputs, report_factors,
max_block_width, numeric_payload_budget_bytes,
recording_capacity_budget_bytes and scratch_capacity_budget_bytes.
Width defaults to one and must fit the native channel limit. Budgets accept
nonnegative size_t integers or None; booleans, enums, fractions and strings
are rejected. ID/factor containers accept lists or tuples. Omitted output
selection means payoff; an empty output list is invalid.
Result properties are values, jacobian, reported_jacobian, selected and
complete output_axis/input_axis, provenance and execution. Getters return
detached containers/matrices. Single rows remain two-dimensional and empty
inputs retain (m, 0). Execution properties are actual_widths,
replay_attempts, executed_paths, peak_recording_bytes and
peak_scratch_bytes. Native work releases the GIL after copying typed request
and settings inputs. Each native output block replays all requested paths;
explicit passive mode performs one replay with no risk columns. The
AAD methodology defines
capacity scopes, exclusions and failure behavior.
ScriptPortfolio_New(trade_ids, products, modelData) seals equal-length nonempty
lists or tuples. Repeating the same original model object establishes one owner;
distinct model objects remain separate even if their values agree. Matching
original sampling contracts determine which trades share scenarios. Trade IDs
must be unique, and all product/model elements must be typed handles.
import dal
date = dal.Date_(2027, 1, 1)
trade_a = dal.Product_New(["X", date], ["5", "pay PAYS 2 * SPOT() + X"])
trade_b = dal.Product_New(["X", date], ["7", "pay PAYS 3 * SPOT() + X"])
model = dal.BSModelData_New(1, 0, 0, 0)
portfolio = dal.ScriptPortfolio_New(["A", "B"], [trade_a, trade_b], [model, model])
valuation = dal.ScriptValuationSettings_(evaluation_date=dal.Date_(2026, 1, 1))
inputs = ["model:0:parameter:0", "trade:0:constant:0", "trade:1:constant:0"]
weighted = dal.PortfolioMonteCarlo_ValueWithWeightedRisk(
portfolio, 17, valuation=valuation,
request=dal.PortfolioWeightedRiskRequest_(inputs=inputs, weights=[2, -1]),
)
assert weighted.component_means == [7, 10]
assert weighted.weighted_value == 4
assert weighted.jacobian.to_rows() == [[1, 2, -1]]
rows = dal.PortfolioMonteCarlo_ValueWithJacobianRisk(
portfolio, 17, valuation=valuation,
request=dal.PortfolioJacobianRiskRequest_(
inputs=inputs, outputs=["trade:1:payoff", "trade:0:payoff"], max_block_width=2,
),
)
assert rows.values == [10, 7]
assert rows.jacobian.to_rows() == [[3, 0, 1], [2, 1, 0]]
assert rows.execution.groups[0].generated_scenarios == 17Both value functions take portfolio and num_path first; request, valuation
and simulation are keyword-only. Their default simulation enables native AAD.
An explicit MonteCarloSettings_(enable_aad=False) retains sharp price-only rows
and zero risk columns; recording limits have no effect in that mode. Native
explicit empty inputs=[] retains native fuzzy prices and zero-column shapes.
Omitted inputs select all native columns; omitted outputs select each trade's
payoff in original order. Global IDs and reporting factors follow the
C++ portfolio rules.
The immutable request types share inputs, outputs, report_factors and the
three optional byte budgets: numeric_payload_budget_bytes,
recording_capacity_budget_bytes, scratch_capacity_budget_bytes. Weighted
requests add weights; Jacobian requests add positive bounded max_block_width,
default one. Numeric payloads are respectively 8*(1+n+2*m) and 8*m*(1+n);
runtime capacities include all admitted workers and native replacement headroom.
Capacity narrowing preserves requested maximum and estimator.
Owning results expose detached raw/reported matrices, selected/complete axes,
trade provenance and original group contracts. provenance.trade_ids,
provenance.model_owners and provenance.trades retain the sealed source mapping.
execution.groups reports actual widths, replay attempts and
scenario/evaluator/reversal counts; execution also reports actual peak
recording/scratch bytes. Sampling definitions, settings, lists and matrices are
copied by getters. Results survive destruction of portfolios or source handles;
getters perform no valuation or history reads. Path counts exclude bool, enums,
fractions and values beyond INT_MAX. Malformed requests fail with field and
trade/group/coordinate context, leaving prior completed results intact.
Fit raw European PRICE/decimal-IV quotes before querying prices, analytic derivatives, an explicit Dupire grid or full-refit quote responses:
import dal
today = dal.Date_(2026, 10, 19)
expiries = [dal.Date_(2027, 4, 19), dal.Date_(2027, 10, 19)]
market = dal.MarketIvFlatMarket_New(today, 100.0, 0.03, 0.01, expiries)
quotes = [
dal.MarketIvQuote_(
id=f"q{3*j+i}", expiry=expiry, strike=strike,
option_type="CALL", quote_type="DECIMAL_IV", mid=0.20,
)
for j, expiry in enumerate(expiries)
for i, strike in enumerate([90.0, 100.0, 110.0])
]
fit = dal.MarketIvFitResult_New(dal.MarketIvFitRequest_(market, quotes))
if not fit.is_success:
raise RuntimeError(f"{fit.status}: {fit.failure}")
snapshot = fit.snapshot
point = dal.MarketIvPointResult_New(snapshot, dal.MarketIvQuery_(100.0, 1.0))
if point.value_status != "SUCCESS":
raise RuntimeError(point.value_status)
grid = dal.MarketIvDupireResult_New(
snapshot, dal.MarketIvDupireRequest_([80.0, 100.0, 120.0], [0.25, 1.0]),
)
if not grid.is_success:
raise RuntimeError(grid.failure)
surface = grid.surface
outputs = [dal.MarketIvRefitOutput_(dal.MarketIvQuery_(100.0, 1.0), "CALL_PRICE")]
risk = dal.MarketIvRefitRiskResult_New(
snapshot, dal.MarketIvRefitRiskRequest_(["q1"], outputs, steps=[1e-6]),
)
if not risk.complete:
raise RuntimeError("Full refit incomplete; inspect risk.axis and risk.responses")
print(f"{'Metric':<16}{'Value':>16}")
print("-" * 32)
print(f"{'Call price':<16}{point.call_price:>16.8f}")For nonflat carry, construct MarketIvMarket_(today, spot, terms) from
MarketIvTerm_(expiry, forward, discount) values. Every quoted expiry must
match a term; extra unquoted carry knots are allowed. Dates require Date_;
query time is actual calendar days/365 from today. PRICE is a discounted
premium per unit underlying; decimal IV 0.20 means 20%. Optional bid/ask
must both be supplied in the quote's native unit. Weight defaults to one.
Quote/settings fields are keyword-only. Fit, evaluation, Dupire and refit
settings use MarketIvFitSettings_, MarketIvEvaluationSettings_,
MarketIvDupireSettings_, MarketIvRefitRiskSettings_; request settings=None
selects fresh defaults. Numbers exclude bool/enums/numeric text, counts must be
integers, and unknown settings reject. Containers/settings are read-only copied
values; copy/deepcopy and detached getters preserve the owning snapshot after
inputs or the original fit result die. Native calls copy inputs before GIL release.
Check is_success before snapshot; numerical failures retain fit diagnostics
but the snapshot getter raises SnapshotUnavailable. Point results separately
report value_status, derivative_status, dupire_status; unavailable numbers
are None. variance_t fixes log-moneyness k; fixed_k_variance_t fixes
strike K, despite its lowercase spelling. call_k/call_kk differentiate
strike, while variance_k/variance_kk differentiate log-moneyness.
risk.axis reports per-direction fits, input unit and discrete regime changes;
risk.responses reports original-row/output indices, f0/f+/f-,
symmetric_bump_slope, both side slopes and output statuses. These are complete
raw-quote refits, distinct from the fixed-base spread VJP below.
RefitMarketIvSurface(snapshot, quotes) also supports replacing a complete
same-axis mid/bid/ask set. MarketIvSurfaceAsLegacyIVS(snapshot) accepts only
explicit FLAT_CARRY; inherited legacy LocalVol remains finite differences.
See the method and defaults for the global
certificate's scope, local fitting/quality limits, budgets and model boundaries.
Run 022.market_iv_local_vol.py
with the built dal package on PYTHONPATH. It fits a smile with nonflat F/D,
constructs an owning model, prints fit and valuation tables, checks forward/DF
values and demonstrates the passive-only error.
Continue from a successful grid in the market-IV workflow:
settings = dal.MarketIvLocalVolModelSettings_("EQ[A]", "USD", "W_EQ", 1.25)
model = dal.MarketIvLocalVolModelData_New("market", grid, settings)
valuation = dal.ScriptValuationSettings_(evaluation_date=today)
pv = dal.MonteCarlo_ValueWithSettings(product, model, 65536, valuation=valuation)
execution = dal.MarketIvLocalVolModelData_Get_Execution(product, model, valuation=valuation)The four constructor arguments are required; optional settings are keyword-only:
max_step=1/52, max_internal_steps=100000,
max_simulation_dimension=100000, numeric_payload_budget_bytes=67108864
and workspace_budget_bytes=268435456. Counts require non-bool integers in
size_t range. Zero budgets deny work. Numbers reject bool/enums/numeric text;
unknown keys and invalid ranges raise ValueError.
The model inherits ModelData_ and owns its source after grid/fit inputs die.
configuration is an independent read-only settings value; summary,
capabilities, construction_execution and the execution inspection return
detached dicts; carry_terms and warnings return lists of dicts.
Carry rows include the origin, every market term and the horizon; a fractional-day
horizon has date=None. Factory and execution preparation release the GIL;
getters never expose native arrays or a mutable last-request report.
The execution report's /2 request identity includes the complete fixing
snapshot. See identity encoding and cross-interface comparison.
Pass the snapshot's evaluation date explicitly. The single declared EQ and
domestic currency, horizon and passive-only capability checks apply to normal
MC too. AAD/risk and EXERCISE reject before sampling. Native failures raise
MarketIvLocalVolError(RuntimeError) with code, stage, field,
expected and actual. Models and typed settings reject pickle; models
reject archive, including through the Storable base. Copy/deepcopy preserve
immutable ownership and identity. See the
model contract.
DupireCalibration_New(base, inputs, *, name="") creates a frozen calibration
from an existing BS model, MertonIVS_, or a Python subclass of IVS_.
Configuration is keyword-only; quote rows are strikes and columns are maturities.
inputs = dal.DupireRiskInputs_(
quote_strikes=[75.0, 105.0, 135.0], quote_maturities=[0.4, 1.2],
quote_spreads=dal.DoubleMatrix_(3, 2),
inclusion_spots=[60.0, 100.0, 140.0], max_spot_spacing=10.0,
inclusion_times=[0.5, 1.0], max_time_spacing=0.5,
)
base = dal.BSModelData_New(100.0, 0.2, 0.05, 0.02)
calibration = dal.DupireCalibration_New(base, inputs, name="local_vol")
seeds = dal.DupireParameterAdjoints_(
calibration, dal.DoubleMatrix_(len(calibration.spots), len(calibration.times), 1.0),
)
quotes = dal.DupireQuoteRisk_New(calibration, seeds)
raw = quotes.total_adjoints.to_rows()This example differentiates the sum of calibrated surface nodes. For trade risk,
create DupireModelData_New(calibration, index, currency, factor, *, name="", max_step=1/12) or use calibration.surface in a Hybrid local-vol component, then obtain a
MonteCarlo_ValueWithRisk result with every surface input selected. Then call
DupireScriptQuoteRisk_New(valuation, calibration, component, *, direct=None).
Its valuation, quote_risk, component and method retain the source and
quote results. DupireParameterAdjoints_FromRisk extracts the surface seed
separately for compatible portfolio accumulation.
The convenience model copies the surface, preserves frozen spot/rate/dividend,
and names its local-vol component equity and deterministic-rate component rate.
DupireDirectQuoteAdjoints_(calibration, matrix) supplies an optional raw PV
quote contribution. Results separate calibration_adjoints, direct_adjoints
and total_adjoints; their unit is decimal-vol. Reporting factors and path
averaging are not applied again. Snapshot getters expose copied inputs,
spots, times, vols and a detached surface, plus spot, rate,
dividend_yield, algorithm and full-content matches(other).
Numeric properties and copy/deepcopy cannot change retained calibration data.
Custom IVS subclasses call super().__init__(spot=..., rate=..., dividend_yield=...) and implement implied_vol(strike, maturity) returning a
finite numeric volatility. MertonIVS_ takes keyword-only spot, vol,
intensity, average_jump, jump_std and retains zero carry. Sampling holds
the GIL; the snapshot retains no Python callback, and native pullbacks release
the GIL. Later changes or destruction of the IVS do not affect prior results.
Numeric configuration excludes bool and enums; invalid domains, missing surface
columns and incompatible identities fail explicitly. See the
discrete derivative and estimator boundaries.
CalibrationRiskPlan_New(calibration, *, request=None) plans an immutable
quote selection over an owning CalibrationPullback_. It accepts frozen Dupire
or any supported curve provenance captured with retain_calibration_record=True.
CalibrationRiskResult_New(plan, parameter_adjoints, *, direct=None) performs
the native pullback using the existing typed parameter/direct seeds.
boundary = dal.CalibrationPullback_New(calibration)
parameters = dal.CalibrationParameterAdjoints_New(
boundary, dal.DoubleMatrix_(boundary.parameter_rows, boundary.parameter_cols, 1.0),
)
request = dal.CalibrationRiskRequest_(
inputs=["quote:3", "quote:0"], report_factors=[0.01, 0.01],
numeric_payload_budget_bytes=144,
)
plan = dal.CalibrationRiskPlan_New(boundary, request=request)
result = dal.CalibrationRiskResult_New(plan, parameters)
raw = result.jacobian.to_rows()
per_vol_point = result.reported_jacobian.to_rows()Request fields are keyword-only and read-only. Lists/tuples are copied; inputs=None
selects every source quote, while inputs=[] retains an empty (1, 0) projection
and still performs the native pullback. Unknown/repeated IDs and nonpositive or
nonfinite factors fail during planning. IDs identify source ordinals; labels
cannot establish source compatibility. Factors apply once to reported copies:
use 0.01 for a decimal-vol point or 1e-4 for a decimal-rate basis point.
The plan exposes calibration, complete_input_axis, input_axis,
selected_ordinals and numeric_payload_bytes. Coordinates retain native
row/column, units and quote metadata: curve value/strike/maturity are None,
and Dupire block fields are None. The budget counts all three complete native
quote matrices even for subset/empty selections. It excludes source/metadata,
input seeds, getter copies and temporary recording storage.
Results expose plan, quote_risk, jacobian, calibration_jacobian,
direct_jacobian and reported_jacobian. All matrices, lists and nested values
are detached copies. The common result retains native method/unit/boundary
metadata without deriving a generic PV or currency from external seeds.
Constructors exclude bool/enums and implicit dictionary/container coercions.
Plans/results support copy/deepcopy; native planning and pullback release the
GIL after owning all Python inputs. See the
native request contract
for retained payload and source-identity rules.
DupireScriptRiskPlan_New(product, modelData, calibration, component, request)
plans the complete surface inputs needed by the native Dupire pullback over a
flat-rate Hybrid. DupireScriptRiskResult_New(plan) runs the sealed valuation
and quote pullback. No manual node-risk extraction is needed.
request = dal.DupireScriptRiskRequest_(
num_paths=257,
quotes=dal.CalibrationRiskRequest_(
inputs=["quote:3", "quote:0"], report_factors=[0.01, 0.5],
),
valuation=dal.ScriptValuationSettings_(evaluation_date=dal.Date_(2026, 9, 12)),
)
plan = dal.DupireScriptRiskPlan_New(product, hybrid, calibration, "Z_LOCAL", request)
result = dal.DupireScriptRiskResult_New(plan)
price = result.valuation.values[0]
spread_risk = result.quote_risk.reported_jacobian.to_rows()Request fields are keyword-only. num_paths is required and accepts integers in
1..INT_MAX, excluding bool and enums. Optional quotes, valuation and
simulation accept their native bound types or None; omitted simulation
enables AAD. Explicit price-only settings reject during planning.
Use direct_bindings=[dal.DupireQuoteBinding_(constant_ordinal=0, quote_id="quote:3")] for an explicit script constant dependency. The ordinal
identifies the prepared script constant, and its value must equal the selected
source quote. Bindings require a copied list/tuple of typed values. Alternatively,
direct accepts a common CalibrationDirectQuoteAdjoints_ containing raw PV
partials with the local-vol surface fixed. These two forms are mutually exclusive;
the native planner validates source identity and adds direct risk once.
Plans expose component, quote_plan, complete_input_axis,
required_input_axis, direct_bindings, num_paths, valuation_settings,
simulation_settings and numeric_payload_bytes. They seal native product/model
content and capture the evaluation date. Explicit fixing snapshots remain owned;
global history is resolved at execution. Quote subset/empty selection retains all
mandatory surface/direct gradients and the native smoothed estimator.
The common quote request's budget now covers the retained valuation value and
required gradients plus all three complete quote contribution matrices. It
excludes source/metadata, getter copies and temporary worker/tape storage.
Results expose valuation, quote_risk, component, method and
numeric_payload_bytes; quote_risk is a CalibrationRiskResult_. All properties
are read-only and detached. Copy/deepcopy retain owning passive values. Planning
and execution release the GIL after copying typed inputs. See the
native automatic request boundaries.
DupireScriptCurvaturePlan_New plans finite-step differences of complete native
quote gradients, recalibrating the surface at every perturbed quote point.
DupireScriptCurvatureResult_New(plan) executes the sealed plan on common paths.
Use an existing DupireScriptRiskRequest_ to specify paths, valuation, simulation
and any direct script-constant quote bindings:
directions = dal.DoubleMatrix_(1, 6, 0.0)
directions[0, 3] = 1.0
bumps = dal.BumpOverAADRequest_(directions=directions, steps=[0.0002])
request = dal.DupireScriptCurvatureRequest_(risk=risk_request, bumps=bumps)
plan = dal.DupireScriptCurvaturePlan_New(
product, hybrid, calibration, "Z_LOCAL", request,
)
result = dal.DupireScriptCurvatureResult_New(plan)
gamma = result.hessian_products[0, 3]
gradient = result.gradientDirection columns follow the complete raw strike-major decimal-vol spread axis,
available as result.input_axis. Unit rows select Gamma/cross-Gamma; signed rows
select Hessian-vector products. First-order input subsets and report factors
affect result.base.quote_risk only; gradient and hessian_products retain
the complete raw axis. Steps are finite, positive and explicit, one per direction
row. All-zero direction rows reject. A DoubleMatrix_(0, quote_count) with
steps=[] requests the base gradient without curvature rows.
The bump constructor is keyword-only and copies a native DoubleMatrix_ and a
list/tuple of real steps. It excludes bool/enums and implicit matrix conversion.
Optional numeric_payload_budget_bytes and recording_capacity_budget_bytes
accept nonnegative size_t integers or None; zero remains an explicit cap.
The Dupire planner rejects recording-cap requests because a caller-thread tape
cap cannot constrain parallel worker tapes. The numeric cap covers the combined
bump/base result payload described in the
native financial contract.
External first-order direct seeds and exercise policies also reject.
Requests, plans and results support copy/deepcopy. All container, matrix and
nested getters return detached values. Plans expose base_plan, point,
directions, steps and numeric_payload_bytes; results add base, gradient,
input_axis, hessian_products and execution. Execution reports method,
quote_gradient_evaluations (1+2*direction_count), paths_per_evaluation and
numeric_payload_bytes. Planning freezes the evaluation date and fixing snapshot;
native planning/execution release the GIL after owning typed Python inputs.
The method is a finite-step estimator, with the native first-order smoothing and
calibration stencil constraints. This entry does not select the smooth C++
forward-over-reverse prototype.
RateCalibration_New(spec) captures an owning immutable calibration snapshot.
It accepts native single-curve, joint multi-curve, staged XCCY and joint XCCY
specifications, restricted to supported exact square systems. point contains
raw decimal quotes in provenance.axis.quotes order; parameters contains the
solved free coordinates. Staged XCCY exposes basis quotes only; its other curves
remain fixed. RateCalibration_Recalibrate(calibration, quotes) returns a new
snapshot from a copied list/tuple of finite real quotes with the same axis.
Use existing RateTradeDefinition_ values and the shared bump request:
calibration = dal.RateCalibration_New(spec)
directions = dal.DoubleMatrix_(1, len(calibration.point), 0.0)
directions[0, 0] = 1.0
bumps = dal.BumpOverAADRequest_(directions=directions, steps=[0.0002])
settings = dal.RateTradeQuoteCurvatureSettings_(weights=[1.0, -0.5])
result = dal.RateTradeQuoteCurvature([trade_a, trade_b], calibration, bumps, settings=settings)
value = result.curvature.value
gradient = result.curvature.gradient
gamma = result.curvature.hessian_products[0, 0]Trades support the native deposit, FRA, future, IRS, basis-swap, OIS and XCCY
families. Use curve component keys from calibration provenance for free curves;
joint declarations retain distinct keys even when display names repeat. All
trades must have the same actual PV currency, returned as result.currency.
This entry performs no currency conversion. Missing or empty weights mean unit
weights; supplied finite weights must match the trade count. Negative and zero
weights are allowed, and every trade is validated even at zero weight.
RateTradeQuoteCurvatureSettings_(*, weights=None, fixings=None) optionally
retains an immutable MarketFixingSnapshot_ for additional trade history.
It must agree with saved calibration observations. Without an explicit snapshot,
missing required history is captured once from global fixings. Calibration
sources, valuation inputs and historical observations stay fixed during bumps.
The finite-step method BumpOverRecalibratedNativeRateAAD recalibrates and
recomputes the full quote gradient at every point. With M directions, execution
reports 1+2*M calibrations, quote gradients and objective reverse sweeps.
DoubleMatrix_(0, quote_count) and steps=[] request the base gradient only.
Products retain raw quote units and signs; choose explicit positive steps using
convergence checks. These estimates do not enable general native higher order.
The numeric budget covers 8*(1+2*N+2*N*M+M) bytes for N quotes and M directions,
excluding solver/source storage, getter copies and allocator overhead. The
separate recording cap constrains caller-thread recalibration and objective
tapes, including cleanup reserve. Both optional caps preserve zero. Execution
also reports numeric_payload_bytes, peak_tape_bytes and cleanup_reserve_bytes.
Vectors, matrices, nested results and provenance getters are detached; snapshots,
settings and results support copy/deepcopy. Factories release the GIL after
copying typed inputs. See the
native financial contract.
Prepare a closed native Black–Scholes script once, then reuse its frozen contract and historical observations for explicit parameter points:
valuation = dal.ScriptValuationSettings_(evaluation_date=dal.Date_(2026, 1, 2))
product = dal.Product_New(
["SCALE", dal.Date_(2027, 1, 2)],
["2", "pay PAYS SCALE * FIX(EQ[UNDERLYING]) ^ 2"],
)
plan = dal.BlackScholesMonteCarloPlan_New(product, valuation=valuation)
point = [100.0, 0.2, 0.03, 0.01, *plan.script_constants]
settings = dal.SegmentedMonteCarloSettings_(first_path=7, segment_steps=64)
mean = dal.BlackScholesMonteCarlo_Get_Risk(plan, point, 129, settings=settings)
bumps = dal.BumpOverAADRequest_(
directions=dal.DoubleMatrix_([[1.0, 0.0, 0.0, 0.0, 0.0]]), steps=[0.25]
)
risk = dal.BlackScholesMonteCarlo_Get_Curvature(
plan, point, 129, bumps, settings=settings
)
spot_gamma = risk.hessian_products[0, 0]Columns follow plan.parameter_labels: spot, volatility, continuously compounded
rate, dividend yield, then script constants. Points must be lists or tuples of
finite real numbers; no coordinate scaling is applied. The path count follows
the positive integer contract above. Plan creation resolves history; subsequent
evaluations replay the sealed observations and do not read global history again.
valuation, smoothing, contract_dates, contract_events, contract_settings
and observations identify the preparation. An optional smoothing factory
argument selects the compiled native first-order smoothing width. EXERCISE
requires the separate policy estimator and is rejected by this preparation.
Keyword-only settings expose rsg (sobol/mrg32/irn), use_bb, absolute
first_path, optional Sobol-only uint64 scramble_key, normal_precision
(Default/Fast/Precise), positive segment_steps and optional
checkpoint_capacity_budget_bytes / recording_capacity_budget_bytes.
Explicit zero caps remain zero. Fixed 32-path batches preserve native reduction
order. Defaults select Sobol, offset zero, no bridge and 64-step segments.
Mean results expose value, gradient, point, parameter_labels, settings,
execution and the owning plan. Curvature exposes base with the mean and
gradient, plus point, directions, actual steps, products, settings, execution
and plan. Containers/settings are detached copies; copy/deepcopy may safely
share immutable native preparation. Numerical calls release the Python GIL.
The curvature method is BumpOverSegmentedNativeAAD: each row differences
complete native mean gradients on the same absolute paths. Its 1+2M
gradient_evaluations count is distinct from segment reverse sweeps. Empty
directions retain the base gradient and a 0 x N product. Numeric payload uses
the shared bump request's owning-double formula and excludes preparation,
tasks and random buffers. The smaller path/bump recording limit applies;
execution reports that effective limit and per-path tape/checkpoint/cleanup
maxima, excluding aggregate memory and RSS. These are finite-step secants;
nonsmooth payoffs have separate step and sampling errors. See the
native methodology.
Prepare a closed Black–Scholes EXERCISE contract and seal its valuation, historical observations and simulation settings before requesting curvature:
product = dal.Product_New(
["K", dal.Date_(2027, 4, 10), dal.Date_(2027, 10, 10)],
["50", "EXERCISE 2 * K - spot()", "EXERCISE 2 * K - spot()"],
)
simulation = dal.MonteCarloSettings_(
enable_aad=True, compiled=True, smooth=2.0,
lsmc_training_paths=256, lsmc_policy_risk_mode="Frozen",
)
plan = dal.BlackScholesLsmcPlan_New(
product, simulation=simulation,
valuation=dal.ScriptValuationSettings_(evaluation_date=dal.Date_(2026, 10, 10)),
)
point = [100.0, 0.2, 0.05, 0.0, *plan.script_constants]
bumps = dal.BumpOverAADRequest_(
directions=dal.DoubleMatrix_([[1.0, 0.0, 0.0, 0.0, 0.0]]), steps=[0.1],
)
risk = dal.BlackScholesLsmc_Get_Curvature(plan, point, 129, bumps)
spot_gamma = risk.hessian_products[0, 0]
base_policy = risk.base_policyThe point uses raw spot, volatility, rate, dividend yield, then script constants
in plan.parameter_labels order. Planning copies the contract and resolves
history once; evaluation replays those sealed observations with the supplied
constant values. simulation=None uses native-risk defaults with AAD enabled.
An explicitly disabled AAD setting, expired exercise or a contract without live
EXERCISE is rejected. Settings and numeric arguments are copied before GIL
release; no active Python scalar, objective or model callback is accepted.
Frozen fits one base policy and uses that same policy for all outer points;
its method is BumpOverFrozenNativeLsmcAAD. Repeating ordinary Frozen pricing
at bumped points fits different policies and estimates a different quantity.
RetrainedBump fits a policy at every outer point and differences the existing
complete gradient estimator, including its inner policy-only price secant.
It reports BumpOverRetrainedNativeLsmcPolicySecant. The retained
simulation.lsmc_policy_bump_relative controls the inner step independently
from risk.steps; training, validation and pricing streams remain common.
Results own plan, value, gradient, parameter_labels, point,
directions, steps, hessian_products, base_policy, simulation and
execution. Passive LsmcExercisePolicy_ elements retain coefficients, scalar
and multivariate normalization, basis powers/degree, degeneracy, effective rank,
solver/fallback and validation error in live EXERCISE order. Plan getters include
valuation, simulation, original contract dates/events/settings, live event dates,
time line and observation snapshots. Nested containers/settings are detached;
copy/deepcopy may share immutable preparation.
Execution records 1+2M gradient requests, paths per replicate,
training/validation/replicate counts, numeric payload, recording cap and maximum
batch tape/cleanup reserve. Empty directions retain the full base gradient.
Numeric payload excludes policy, preparation and temporary work. Recording caps
apply to individual fuzzy replay batches and can fail after policy training;
resource maxima exclude aggregate process memory. Explicit zero limits remain
zero. These finite-path, finite-step estimators do not imply an analytic,
symmetric Hessian or unbiased optimal-stopping Gamma. See
the estimator contract.
DoubleMatrix_ supports all of the following:
surface = dal.DoubleMatrix_(3, 2, 0.20)
surface[1, 0] = 0.21
surface = dal.DoubleMatrix_([
[0.24, 0.23],
[0.21, 0.20],
[0.22, 0.21],
])Rows must be rectangular numeric sequences. LocalVolSurfaceData_New expects a
spots-by-times matrix, so its shape must be
len(spots) × len(times).
dal.calibrate_curve(...) covers the common single discount-curve path. Use
CurveCalibrationSpecBuilder_ directly for projection-curve inputs, staged
multi-curve calibration, or lower-level solver settings. Python enum names are:
CurveParameterization:PIECEWISE_LINEAR_FWD,PIECEWISE_CONSTANT_FWD,ZERO_RATE,LOG_DISCOUNT;CurveSolveMode:EXACT,APPROXIMATE;CurveJacobianMode:ANALYTIC,BUMPED; andLogDfScheme:LOG_LINEAR,LOG_CUBIC_NATURAL,MIXED.
Calibration and quote-risk provenance calls snapshot Python-mutable specs, options and exposed result matrices while holding the GIL, then release it for native work. Concurrent edits affect later calls. Python read-only specs and immutable instrument/curve handles remain shared.
ZERO_RATE is supported by CalibrateSingleCurve and dal.calibrate_curve. Supply only
strictly-future knots; the anchor is internal and contributes no solver or Jacobian
column. The scalar initialGuess_ is a decimal continuously compounded zero rate.
dal.calibrate_curve(..., base_curve=...) treats the calibrated zero rates as spreads
over that base.
Direct construction uses:
curve = dal.DiscountZeroRate_New(
"usd_zero", "USD", today, node_dates, zero_rates,
day_count=dal.DayBasis_("ACT_365F"),
log_df_scheme=dal.LogDfScheme.LOG_LINEAR,
base=None,
)The returned DiscountZeroRate_ exposes read-only anchor_date, node_dates,
zero_rates, day_count, and log_df_scheme properties.
Python staged XCCY exposes both CalibrateXccyMarket(spec) and
CalibrateXccyMarket(spec, options). CrossCurrencyCalibrationOptions_
provides trailing-underscore and snake-case properties for the Jacobian mode
and the two independent compute flags; its defaults are ANALYTIC, True, and
True. The result keeps matrices under result.diagnostics, not at the result
top level. That diagnostics object exposes the forward jacobian, the
eff_jacobian_inverse, instrument-name and parameter-knot axes, residual
tolerance, scaling labels, and availability states, with matching
trailing-underscore aliases.
Python joint XCCY exposes the declarations, builder,
JointXccyCalibrationOptions_, calibration entry point, and result surface
with both trailing-underscore and snake-case aliases.
JointXccyCalibrationResult_ provides domestic_curve_block,
foreign_curve_block, basis_curve, fx_forward_curve, fixings, group
diagnostics, market_rates, model_rates, residuals,
jacobian_at_solution, eff_jacobian_inverse, parameter_ranges, and
residual_ranges. CalibrateJointXccyMarket(spec, options) selects analytic or
bumped Jacobians and optional matrix construction. The effective inverse has
shape totalParameters x totalResiduals; applying it to a raw decimal quote
bump requires division by the spec's tolerance_, as described in the
Jacobian methodology.
Python exports the seven-family enum, all family-specific terms classes,
RateTradeDefinition_, RatePricingMarket_, PriceRateTrades,
RateTradeNodeSensitivities, RateTradeNodeSensitivitiesBatch, and
AggregateRatePortfolioNodeRisk. The pricing and sensitivity functions use
keyword-only arguments and release the GIL around native work.
Repeated pricing also exposes PreparedRateTrades_New,
PreparedRateTrades_Get_Prices and PreparedRateTrades_Get_NodeSensitivities
with keyword-only inputs and a read-only prepared size property.
component_keys must be a Python list — a tuple is rejected with TypeError
before any native work starts. The minimal single-trade call:
r = dal.RateTradeNodeSensitivities(trade=trade, market=market, component_key="discount")
# r.eligible, r.pv, list(r.gradient), r.reasonResults are read-only projections of the C++ shapes. A complete runnable deposit example covering the batch and aggregation calls is in the dal-python README.
Python exposes RateQuoteRiskProvenanceConfig_, all four supported provenance
builders, and AggregateRatePortfolioQuoteRisk as keyword-only calls. They
release the GIL around native construction or aggregation and return read-only
objects. The axis/state fingerprint schemes, stable availability reasons,
price-per-decimal and DV01 units, and UnconvertedByActualPvCcy policy are
identical to C++.
Read source.state.scheme for the actual state domain: /3 for single-curve
and both XCCY kinds, /4 for generic joint calibration. The historical
RateQuoteRiskStateFingerprintScheme() still returns /1. Exact valuation and
fixing fractions, including unused history, participate in identity. Historical
/1 and /2 sources remain inspectable metadata but cannot be matched or used
for live aggregation/pullback. Native scheme and snapshot errors propagate as
RuntimeError; a failed call permits a correct retry. No provenance archive or
pickle interface is added. See the
migration contract.
The runnable single-curve quote-risk example
prints both fingerprints, the policy, and every bucket. The
joint XCCY example also
constructs joint provenance. The generic joint example
uses constructible spec/options, CalibrateJointMultiCurveBundle, owning result
curves, and BuildJointMultiCurveQuoteRiskProvenance. Ordinary staged
multi-curve chain rules remain outside the supported Python surface.
Storable_ exposes read-only name and type properties, and the native
YieldCurve_ / CurveBlock_ / Bag_ hierarchy is bound for archive
compatibility with the standalone web application. _StorableToJson,
_StorableFromJson, _BagNew, and _BagContents are private integration
helpers rather than supported general serialization functions.
Build an owning, explicit-date Black–Scholes request. Carry rows end at their supplied date; the last row and the last Bermudan exercise date must equal maturity.
import dal
today, maturity = dal.Date_(2026, 10, 18), dal.Date_(2027, 10, 18)
contract = dal.EarlyExercisePdeContract_(
today, maturity, 100.0, "PUT", "BERMUDAN",
exercise_dates=[dal.Date_(2027, 4, 18), maturity],
)
market = dal.EarlyExercisePdeMarket_(
100.0, 0.20, [dal.EarlyExercisePdeCarrySegment_(maturity, 0.05, 0.0)],
)
settings = dal.EarlyExercisePdeSettings_()
request = dal.EarlyExercisePdeRequest_(contract, market, settings=settings)
result = dal.EarlyExercisePdeResult_New(request)
if not result.is_success:
raise RuntimeError(result.failure.reason)
print(f"{'Style':<12}{'Price':>16}")
print("-" * 28)
print(f"{'BERMUDAN':<12}{result.price:>16.8f}")For American exercise, use "AMERICAN" and omit exercise_dates. Native
dal.OptionType_.PUT and dal.EarlyExerciseStyle_.AMERICAN enum members are
also accepted; text uses the exact uppercase spellings. Dates require dal.Date_.
Real inputs require finite int/float values excluding bool/enums; integer settings
reject fractions. Constructors copy native inputs. Settings are keyword-only,
read-only, and default to 401 nodes, 500 base intervals and fully implicit
theta=1; settings=None on the request selects the same defaults. The native
call copies its request before releasing the GIL and uses no Python callback.
status, is_success, method, request, grid, values, time_grid,
step_diagnostics, exercise_levels, exercise_regions, execution and
failure are read-only result properties alongside price. Lists and nested
values are detached copies and support copy/deepcopy. Failed numerical results
retain status/failure/diagnostics, but price and values raise; invalid input
or planned budget failure raises without returning a result. No AAD or Greeks
are exposed. See the method guide for
ACT/365 events, CN limits, all defaults, original LCP residuals and zero-based
region slices; a success status is not a continuous-model accuracy certificate.
An existing price request can be copied into a risk request:
risk_request = dal.EarlyExercisePdeRiskRequest_(request)
result = dal.EarlyExercisePdeRiskResult_New(risk_request)
if result.price_available:
print(result.price)
for row in result.risks:
if row.status in ("AVAILABLE", "AVAILABLE_EXERCISE_REGION"):
print(row.risk_id, row.value, row.unit, row.interpretation)
else:
print(row.risk_id, row.status, row.reason)EarlyExercisePdeRiskSettings_ takes keyword-only flags, absolute bumps,
stability tolerances and cumulative scenario/work/byte limits. Pass it as
EarlyExercisePdeRiskRequest_(request, risk=settings). Fields are readonly;
nested/list getters detach copies and do no new solves. Input numbers reject
Boolean/enum coercion; counts require nonnegative integers. Evaluation releases
the GIL after copying inputs and preserves existing caller tape state.
price_available does not imply every risk is available. risk_value("Gamma")
raises on an unavailable value. Gamma is a finite-scale model approximation;
Vega and carry sensitivities are per decimal parameter, without quote DV01
semantics. The complete runnable example
shows Bermudan/American contracts and a boundary PARTIAL table. See the
method and budget contract.
settings = dal.EuropeanPdeSettings_(grid_points=61, ordinary_steps=120)
risk = dal.EuropeanPdeRiskResult_New(0.05, 0.20, 110.0, settings=settings)
call_price, put_price = risk.prices
call_rho_per_bp = 1e-4 * risk.jacobian[0, 0]
call_vega_per_point = 0.01 * risk.jacobian[0, 1]The three required parameters are absolute decimal rate, volatility and strike.
Optional settings and numeric_payload_budget_bytes /
recording_capacity_budget_bytes are keyword-only. Settings are immutable:
node/ordinary-interval defaults are 61/120, upper boundary 400, expiry 1,
dividend yield 0.02 and both solve-error limits 1e-12.
Both error limits must be finite and in [0,1].
spot_index=None resolves the quarter-grid node; otherwise supply an interior
node index. Strike must be positive, below the upper boundary and away from
grid nodes. Volatility and expiry must be positive. Bool, enums and implicit
numeric coercions are rejected.
The owning result exposes copied point, settings, grid, prices,
jacobian, axes/units, spot, method, actual chronological forward/
transpose error matrices and execution resource observations. Its arrays and
matrices remain valid after GC or subsequent calls. Native work releases the
GIL. The mesh, spot node, dividend and expiry are passive; the Jacobian contains
rate/volatility/strike first derivatives only.
The numeric budget covers 8*(17+nodes+6*(ordinary_steps+2)) retained doubles,
excluding labels, containers and temporary copies. The recording limit uses
actual retained tape/event capacity with a cleanup reservation; it is not a
process heap quota. Zero limits reject nonempty requests. See
the financial program and budget details.
See dal-python/README.md for package-focused examples.