Repository navigation
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Batch TREE - short-rate lattice (T2/6): Lattice base + DiscretizedAsset + DiscretizedOption/DiscountBond
The rollback protagonist + the abstract lattice interface. Absent on main. Owns the central asset<->lattice ownership decision.
Scope
QuantLib/ql/numericalmethod.hpp (Lattice base) + ql/discretizedasset.hpp (DiscretizedAsset, DiscretizedOption, DiscretizedDiscountBond) -> crates/libitofin/src/methods/lattices/ + discretizedasset.rs.
Contract (verified against source)
Lattice(numericalmethod.hpp:37): holds aTimeGrid; the abstract interfaceinitialize(asset, t),rollback(asset, to),partial_rollback(asset, to),present_value(asset),grid(t). In Rust a trait (TreeLattice in T3 impls it).DiscretizedAsset(discretizedasset.hpp:36):values_,time_,method_(the lattice). High-levelinitialize/rollback/partial_rollback/present_valueDELEGATE to the lattice (discretizedasset.hpp:182-199). Low-level:reset(size),mandatory_times(),pre_adjust_values_impl/post_adjust_values_impl(guarded bypre/post_adjust_valueswith aclose_enoughtime-dedup),is_on_time(t),adjust_values.DiscretizedOption(discretizedasset.hpp:160, REQUIRED - DiscretizedSwaption extends it): holds an underlying asset +exercise_type+exercise_times;post_adjust_values_impl->apply_exercise_condition=max(underlying.values[i], values[i]).DiscretizedDiscountBond(discretizedasset.hpp:147): trivial -reset(size) -> Array(size, 1.0), emptymandatory_times.- RUST DESIGN (advisor - the central decision): the asset<->lattice ownership cycle. The asset holds an
Rc<dyn Lattice>(method_) and the lattice mutates the asset each rollback call. Resolve by CLONING theRcout of the asset before the call (so the borrow of the asset and the call through the lattice don't alias). Document the chosen shape. - Deps on main:
Array,Exercise,TimeGrid.
Oracle (Rust-authored)
DiscretizedDiscountBond:reset(n)-> all-ones Array;present_valueon a flat trivial lattice == the discount.- The
pre/post_adjust_valuesguard fires the impl exactly once per time (theclose_enoughdedup), andis_on_timematches the grid. DiscretizedOption::apply_exercise_condition== elementwisemax(underlying, values).- Confirm-by-stubbing: drop the
close_enoughguard and assert a double-adjust is detectable; break the max() and assert the exercise test fails.
Deps / est
- ~300 LOC. Size: M. Epic: [EPIC-9] Methods: remaining MC and finite-difference depth #71. Batch TREE wave 1 (parallel with T1; the Lattice trait is defined here, impl'd in T3).
GATE AMENDMENT (apply)
The asset<->lattice Rc-clone discipline must ALSO extend to the option's underlying: DiscretizedOption::post_adjust_values_impl (discretizedasset.cpp:31) calls underlying_.partial_rollback(time()) - an asset<->asset coupling. Clone the underlying's Rc handle out before that call too, not only the asset<->lattice handle.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request
Activity
docs(methods): note the American exercise-window panic in Discretized…