pub struct Swap { /* private fields */ }Expand description
Implementations§
Source§impl Swap
impl Swap
Sourcepub fn new(
legs: Vec<Leg>,
payer: Vec<bool>,
settings: Shared<Settings<Date>>,
) -> QlResult<Swap>
pub fn new( legs: Vec<Leg>, payer: Vec<bool>, settings: Shared<Settings<Date>>, ) -> QlResult<Swap>
Builds a multi-leg swap from its legs and their payer flags (the C++
multi-leg constructor, swap.cpp:46).
A true flag marks a paid leg, stored as the multiplier -1; a false
flag a received leg, stored as +1. The swap registers with the settings
evaluation date and with every flow of every leg.
§Errors
The number of payer flags must match the number of legs.
Sourcepub fn two_leg(
first_leg: Leg,
second_leg: Leg,
settings: Shared<Settings<Date>>,
) -> Swap
pub fn two_leg( first_leg: Leg, second_leg: Leg, settings: Shared<Settings<Date>>, ) -> Swap
Builds a two-leg swap whose first leg is paid and second received (the
C++ two-leg constructor, swap.cpp:30).
Sourcepub fn number_of_legs(&self) -> usize
pub fn number_of_legs(&self) -> usize
The number of legs.
Sourcepub fn start_date(&self) -> QlResult<Date>
pub fn start_date(&self) -> QlResult<Date>
Sourcepub fn maturity_date(&self) -> QlResult<Date>
pub fn maturity_date(&self) -> QlResult<Date>
The latest maturity date over the legs.
§Errors
The swap must have at least one leg, each non-empty.
Sourcepub fn leg_npv(&mut self, j: usize) -> QlResult<Real>
pub fn leg_npv(&mut self, j: usize) -> QlResult<Real>
The j-th leg’s NPV.
§Errors
The index must be within range and the engine must have provided the value.
Sourcepub fn leg_bps(&mut self, j: usize) -> QlResult<Real>
pub fn leg_bps(&mut self, j: usize) -> QlResult<Real>
The j-th leg’s BPS.
§Errors
The index must be within range and the engine must have provided the value.
Sourcepub fn start_discounts(&mut self, j: usize) -> QlResult<DiscountFactor>
pub fn start_discounts(&mut self, j: usize) -> QlResult<DiscountFactor>
The discount factor at the j-th leg’s start date.
§Errors
The index must be within range and the engine must have provided the value.
Sourcepub fn end_discounts(&mut self, j: usize) -> QlResult<DiscountFactor>
pub fn end_discounts(&mut self, j: usize) -> QlResult<DiscountFactor>
The discount factor at the j-th leg’s end date.
§Errors
The index must be within range and the engine must have provided the value.
Sourcepub fn npv_date_discount(&mut self) -> QlResult<DiscountFactor>
pub fn npv_date_discount(&mut self) -> QlResult<DiscountFactor>
Sourcepub fn deep_update(&mut self)
pub fn deep_update(&mut self)
Invalidates the cached results and notifies observers (the C++
Swap::deepUpdate).
C++ additionally walks each leg’s flows calling deepUpdate on them, to
refresh coupons whose pricer caches; the crate’s cash-flow surface exposes
no such hook yet, so the leg walk reduces to the update step until one
lands.
Trait Implementations§
Source§impl Instrument for Swap
impl Instrument for Swap
Source§fn base(&self) -> &InstrumentBase
fn base(&self) -> &InstrumentBase
Source§fn base_mut(&mut self) -> &mut InstrumentBase
fn base_mut(&mut self) -> &mut InstrumentBase
Source§fn is_expired(&self) -> QlResult<bool>
fn is_expired(&self) -> QlResult<bool>
Source§fn setup_arguments(&self, arguments: &mut dyn Arguments) -> QlResult<()>
fn setup_arguments(&self, arguments: &mut dyn Arguments) -> QlResult<()>
Source§fn setup_expired(&mut self)
fn setup_expired(&mut self)
setupExpired): zero value, cleared extras.Source§fn fetch_results(&mut self, results: &dyn Results) -> QlResult<()>
fn fetch_results(&mut self, results: &dyn Results) -> QlResult<()>
Source§fn perform_calculations(&mut self) -> QlResult<()>
fn perform_calculations(&mut self) -> QlResult<()>
performCalculations): reset, fill and
validate the arguments, calculate, fetch the results. Override only
when pricing without an engine. Read moreSource§fn calculate(&mut self) -> QlResult<()>
fn calculate(&mut self) -> QlResult<()>
Instrument::calculate). Read moreSource§fn recalculate(&mut self) -> QlResult<()>
fn recalculate(&mut self) -> QlResult<()>
LazyObject::recalculate, inherited by every C++ instrument; goes
through the virtual calculate, so expired instruments short-circuit).Source§fn error_estimate(&mut self) -> QlResult<Real>
fn error_estimate(&mut self) -> QlResult<Real>
errorEstimate()).Source§fn valuation_date(&mut self) -> QlResult<Date>
fn valuation_date(&mut self) -> QlResult<Date>
valuationDate()).