Skip to content

[QL-9.7] Lattice base + DiscretizedAsset + DiscretizedOption/DiscountBond #461

Closed

Description

@benbenbang

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 a TimeGrid; the abstract interface initialize(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-level initialize/rollback/partial_rollback/present_value DELEGATE to the lattice (discretizedasset.hpp:182-199). Low-level: reset(size), mandatory_times(), pre_adjust_values_impl/post_adjust_values_impl (guarded by pre/post_adjust_values with a close_enough time-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), empty mandatory_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 the Rc out 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_value on a flat trivial lattice == the discount.
  • The pre/post_adjust_values guard fires the impl exactly once per time (the close_enough dedup), and is_on_time matches the grid.
  • DiscretizedOption::apply_exercise_condition == elementwise max(underlying, values).
  • Confirm-by-stubbing: drop the close_enough guard and assert a double-adjust is detectable; break the max() and assert the exercise test fails.

Deps / est


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.

Activity

  1. added a commit that references this issue on Jul 22, 2026
    70d245e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions