Struct PyInstrument
pub struct PyInstrument {
pub(crate) inner: AnyInstrument,
}Expand description
A tradable instrument.
Fields§
§inner: AnyInstrumentImplementations§
§impl PyInstrument
impl PyInstrument
pub(crate) fn __repr__(&self) -> String
pub(crate) fn engine(&self) -> Option<&'static str>
pub(crate) fn engine(&self) -> Option<&'static str>
Which model prices this instrument, for the products that choose
one: a European swaption’s engine (surface or hull_white) or a
bond option’s (yield_vol or hull_white). None for every other
product, which prices one way.
pub(crate) fn underlying(&self) -> Option<PyInstrument>
pub(crate) fn underlying(&self) -> Option<PyInstrument>
The instrument an option is written on, as an instrument of its own:
a European swaption’s swap, a bond option’s bond. None for a product
with no underlying.
pub(crate) fn market_data_needs(&self) -> PyResult<Vec<(String, String)>>
pub(crate) fn market_data_needs(&self) -> PyResult<Vec<(String, String)>>
The market data this instrument needs, as identifiers only.
A dictionary of strings — no numbers, because a declaration carries none. Every value is the identifier’s canonical spelling, the one the vocabulary parses back to the same identifier — never debug formatting, which nothing round-trips.
pub(crate) fn fixings_needed(
&self,
valuation: NaiveDate,
) -> Vec<(String, NaiveDate)>
pub(crate) fn fixings_needed( &self, valuation: NaiveDate, ) -> Vec<(String, NaiveDate)>
The published fixings a valuation on valuation will read, as
(index, date) pairs.
A query over the instrument’s own resets, not a valuation: it takes no
market, and the date decides only which resets are already past —
those are the ones a fixings store must hold, and the only ones
reported, because a reset still to come is projected off a curve.
Every index spelling is the canonical store key, so a reported pair
goes straight into MarketContext.with_fixings unretyped. An instrument with
no floating reset reports an empty list.
pub(crate) fn contract_dates(&self) -> Vec<(String, NaiveDate)>
pub(crate) fn contract_dates(&self) -> Vec<(String, NaiveDate)>
The contract dates this instrument resolved to, as (name, date) pairs.
These are exactly the dates a stated constructor takes, so a product built through the derived form can be read back and rebuilt through the stated one — which is what makes the two forms checkable against each other rather than merely both present.
Empty for a product with no stated form: the listing names what a caller
could state, not every date a product holds. final_payment_date remains
the accessor for a calibration pillar.
pub(crate) fn diagnostics(
&self,
py: Python<'_>,
market: &PyMarket,
) -> PyResult<PyObject>
pub(crate) fn diagnostics( &self, py: Python<'_>, market: &PyMarket, ) -> PyResult<PyObject>
What this product’s valuation resolved to on market: a bond option
(yield-vol engine), a bond future option, an FX option, a CDS or a
credit-linked swap, each as its own diagnostics class. Any other
product raises ValueError naming diagnostics.
pub(crate) fn with_hull_white_convexity(&self) -> PyResult<Self>
pub(crate) fn with_hull_white_convexity(&self) -> PyResult<Self>
This rate future with its convexity modelled under Hull-White on the
market’s parameters for its currency, rather than stated — a term
contract by the Hull-White convexity bias, a compounded overnight one in
arrears from its first unprinted day, an averaged one print by print.
Any other product raises ValueError naming it.
pub(crate) fn final_payment_date(&self) -> Option<NaiveDate>
pub(crate) fn final_payment_date(&self) -> Option<NaiveDate>
The date of the instrument’s final payment — the pillar a calibration
rung on it belongs to — or None for a product no ladder is built
from.
pub(crate) fn latest_relevant_date(&self) -> Option<NaiveDate>
pub(crate) fn latest_relevant_date(&self) -> Option<NaiveDate>
The latest date the instrument reads: the latest of its payment dates
and of its IBOR coupons’ fixing-window ends. None for a
product with no legs.
pub(crate) fn legs(&self) -> PyResult<Option<Vec<PyLeg>>>
pub(crate) fn legs(&self) -> PyResult<Option<Vec<PyLeg>>>
The instrument’s legs, in the order it declares them, or None for a
product that carries no coupon schedule.
Each carries the discount key this instrument declares, so a leg taken out of an instrument values on the same curve it valued on inside it. Two legs the instrument declares that a caller sums must therefore come to the instrument’s own present value, and a test asserts they do.
A cross-currency swap’s legs are on the sides the trade has them, each
discounted on its own currency’s collateral, so each values to its
leg_npvs row in its own currency. A resetting leg comes back for its
schedule and refuses to be valued: its notionals are forward FX.
pub(crate) fn npv(
&self,
py: Python<'_>,
market: &PyMarket,
currency: Option<&str>,
) -> PyResult<f64>
pub(crate) fn npv( &self, py: Python<'_>, market: &PyMarket, currency: Option<&str>, ) -> PyResult<f64>
The instrument’s present value against market.
The core’s AnyInstrument::npv — the passive instantiation of the same
seam a book values through — with the interpreter lock released for the
duration, as Book.npv releases it.
pub(crate) fn par_rate(
&self,
py: Python<'_>,
market: &PyMarket,
) -> PyResult<f64>
pub(crate) fn par_rate( &self, py: Python<'_>, market: &PyMarket, ) -> PyResult<f64>
The par rate — the fixed rate, coupon or forward that values the instrument at zero.
pub(crate) fn par_spread(
&self,
py: Python<'_>,
market: &PyMarket,
) -> PyResult<f64>
pub(crate) fn par_spread( &self, py: Python<'_>, market: &PyMarket, ) -> PyResult<f64>
The par spread — the margin over the floating side that values the instrument at zero, where the product defines one.
pub(crate) fn cashflow_records(
&self,
py: Python<'_>,
market: &PyMarket,
) -> PyResult<PyRecords>
pub(crate) fn cashflow_records( &self, py: Python<'_>, market: &PyMarket, ) -> PyResult<PyRecords>
The instrument’s cashflow schedule against market, as named parallel
columns.
One row per coupon, over the instrument’s legs in the order it declares
them. It takes a market, not a curve: the projected rate, the
pay-date discount factor and the present value are priced quantities,
and which curve fills which role is the market’s to resolve. The same
lift-view-resolve seam npv walks, with the interpreter lock released
for the duration.
A product carrying no leg raises rather than returning an empty table, which would be indistinguishable from a schedule whose coupons have all paid.
pub(crate) fn implied_vol(
&self,
py: Python<'_>,
market: &PyMarket,
premium: Option<f64>,
) -> PyResult<f64>
pub(crate) fn implied_vol( &self, py: Python<'_>, market: &PyMarket, premium: Option<f64>, ) -> PyResult<f64>
The one flat volatility under which this option or straddle, priced at
it, is worth premium — or, with none given, its own value against
market. An FX option, a surface-engine European swaption, or a
straddle of either.
pub(crate) fn npv_ccy(&self) -> String
pub(crate) fn npv_ccy(&self) -> String
The currency npv is in: a cash-settled forward’s settlement
currency, a cross-currency swap’s quoted leg’s whichever side is paid.
pub(crate) fn leg_npvs(
&self,
py: Python<'_>,
market: &PyMarket,
pnl_ccy: Option<&str>,
) -> PyResult<PyRecords>
pub(crate) fn leg_npvs( &self, py: Python<'_>, market: &PyMarket, pnl_ccy: Option<&str>, ) -> PyResult<PyRecords>
A cross-currency swap’s value by leg against market, pay leg first:
side, ccy, npv_local, npv_ccy, npv, pnl_ccy, npv_pnl — each leg in its
own currency, in npv_ccy and in pnl_ccy (default npv_ccy), each
value column summing to the swap’s value in that currency.
Trait Implementations§
§impl Clone for PyInstrument
impl Clone for PyInstrument
§fn clone(&self) -> PyInstrument
fn clone(&self) -> PyInstrument
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl DerefToPyAny for PyInstrument
§impl IntoPy<Py<PyAny>> for PyInstrument
impl IntoPy<Py<PyAny>> for PyInstrument
§impl PyClass for PyInstrument
impl PyClass for PyInstrument
§impl PyClassImpl for PyInstrument
impl PyClassImpl for PyInstrument
§const IS_BASETYPE: bool = false
const IS_BASETYPE: bool = false
§const IS_SUBCLASS: bool = false
const IS_SUBCLASS: bool = false
§const IS_MAPPING: bool = false
const IS_MAPPING: bool = false
§const IS_SEQUENCE: bool = false
const IS_SEQUENCE: bool = false
§type ThreadChecker = SendablePyClass<PyInstrument>
type ThreadChecker = SendablePyClass<PyInstrument>
§type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::ImmutableChild
type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::ImmutableChild
§type BaseNativeType = PyAny
type BaseNativeType = PyAny
PyAny by default, and when you declare
#[pyclass(extends=PyDict)], it’s PyDict.fn items_iter() -> PyClassItemsIter
fn lazy_type_object() -> &'static LazyTypeObject<Self>
fn dict_offset() -> Option<isize>
fn weaklist_offset() -> Option<isize>
§impl<'a, 'py> PyFunctionArgument<'a, 'py> for &'a PyInstrument
impl<'a, 'py> PyFunctionArgument<'a, 'py> for &'a PyInstrument
§impl PyMethods<PyInstrument> for PyClassImplCollector<PyInstrument>
impl PyMethods<PyInstrument> for PyClassImplCollector<PyInstrument>
fn py_methods(self) -> &'static PyClassItems
§impl PyTypeInfo for PyInstrument
impl PyTypeInfo for PyInstrument
§fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
§fn type_object_bound(py: Python<'_>) -> Bound<'_, PyType>
fn type_object_bound(py: Python<'_>) -> Bound<'_, PyType>
§fn is_type_of_bound(object: &Bound<'_, PyAny>) -> bool
fn is_type_of_bound(object: &Bound<'_, PyAny>) -> bool
object is an instance of this type or a subclass of this type.§fn is_exact_type_of_bound(object: &Bound<'_, PyAny>) -> bool
fn is_exact_type_of_bound(object: &Bound<'_, PyAny>) -> bool
object is an instance of this type.