Struct PyDayCountFraction
pub(crate) struct PyDayCountFraction {
inner: DayCountFraction,
}Expand description
A day-count convention, named once and measured with repeatedly.
A free year_fraction would collide with the crate’s own shared ACT/365
measure, which is a different function of the same name — from Python
nothing would say which one a caller had reached. Naming the convention
first says it.
Fields§
§inner: DayCountFractionImplementations§
§impl PyDayCountFraction
impl PyDayCountFraction
§impl PyDayCountFraction
impl PyDayCountFraction
fn new(code: &str) -> PyResult<Self>
fn __repr__(&self) -> String
fn __str__(&self) -> &'static str
fn act_360() -> Self
fn act_365_fixed() -> Self
fn nl_365() -> Self
fn thirty_360() -> Self
fn thirty_360_us() -> Self
fn thirty_e_360() -> Self
fn thirty_e_360_isda() -> Self
fn act_act_isda() -> Self
fn act_act_icma() -> Self
fn act_act_afb() -> Self
fn bus_252() -> Self
fn one() -> Self
fn year_fraction(&self, start: NaiveDate, end: NaiveDate) -> f64
fn year_fraction(&self, start: NaiveDate, end: NaiveDate) -> f64
The year fraction between two dates, context-free.
A convention that wants period context or a business calendar —
ACT/ACT.ICMA, 30E/360.ISDA, 30U/360, BUS/252 — is answered under
its context-free reading here: ACT/ACT.ICMA measures the two dates as
their own reference period, and 30U/360 applies no end-of-month February
rule. The two methods below give each what it wants.
fn year_fraction_with_context(
&self,
start: NaiveDate,
end: NaiveDate,
period_end: NaiveDate,
frequency: Named<Frequency>,
schedule_end: NaiveDate,
end_of_month: bool,
reference_days: Option<u16>,
) -> f64
fn year_fraction_with_context( &self, start: NaiveDate, end: NaiveDate, period_end: NaiveDate, frequency: Named<Frequency>, schedule_end: NaiveDate, end_of_month: bool, reference_days: Option<u16>, ) -> f64
The year fraction with the schedule context the period-aware conventions read: the containing period’s end, the coupon frequency, the schedule’s maturity, and whether it rolls on month end.
reference_days states an explicit ICMA reference-period length for the
markets whose coupons chain in exact day steps (91/182/364); omitting it
recovers the reference period by stepping back one frequency tenor,
which is what a calendar-month market wants.
fn year_fraction_with_calendar(
&self,
start: NaiveDate,
end: NaiveDate,
calendar: &PyCalendar,
) -> f64
fn year_fraction_with_calendar( &self, start: NaiveDate, end: NaiveDate, calendar: &PyCalendar, ) -> f64
The year fraction measured against a business calendar — what BUS/252
divides its business-day count by. Conventions that ignore the calendar
return what they would have returned without one.
Trait Implementations§
§impl Clone for PyDayCountFraction
impl Clone for PyDayCountFraction
§fn clone(&self) -> PyDayCountFraction
fn clone(&self) -> PyDayCountFraction
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for PyDayCountFraction
impl DerefToPyAny for PyDayCountFraction
impl Eq for PyDayCountFraction
§impl From<DayCountFraction> for PyDayCountFraction
impl From<DayCountFraction> for PyDayCountFraction
§fn from(inner: DayCountFraction) -> Self
fn from(inner: DayCountFraction) -> Self
§impl Hash for PyDayCountFraction
impl Hash for PyDayCountFraction
§impl IntoPy<Py<PyAny>> for PyDayCountFraction
impl IntoPy<Py<PyAny>> for PyDayCountFraction
§impl PartialEq for PyDayCountFraction
impl PartialEq for PyDayCountFraction
§fn eq(&self, other: &PyDayCountFraction) -> bool
fn eq(&self, other: &PyDayCountFraction) -> bool
self and other values to be equal, and is used by ==.§impl PyClass for PyDayCountFraction
impl PyClass for PyDayCountFraction
§impl PyClassImpl for PyDayCountFraction
impl PyClassImpl for PyDayCountFraction
§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<PyDayCountFraction>
type ThreadChecker = SendablePyClass<PyDayCountFraction>
§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 PyClassNewTextSignature<PyDayCountFraction> for PyClassImplCollector<PyDayCountFraction>
impl PyClassNewTextSignature<PyDayCountFraction> for PyClassImplCollector<PyDayCountFraction>
fn new_text_signature(self) -> Option<&'static str>
§impl<'a, 'py> PyFunctionArgument<'a, 'py> for &'a PyDayCountFraction
impl<'a, 'py> PyFunctionArgument<'a, 'py> for &'a PyDayCountFraction
§impl PyMethods<PyDayCountFraction> for PyClassImplCollector<PyDayCountFraction>
impl PyMethods<PyDayCountFraction> for PyClassImplCollector<PyDayCountFraction>
fn py_methods(self) -> &'static PyClassItems
§impl PyTypeInfo for PyDayCountFraction
impl PyTypeInfo for PyDayCountFraction
§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.