@@ -79,6 +79,37 @@ class FloatPeriod(_BasePeriodStatic):
7979
8080 .. role:: green
8181
82+ .. rubric:: Examples
83+
84+ .. ipython:: python
85+ :suppress:
86+
87+ from rateslib.periods.components import FloatPeriod
88+ from rateslib import fixings
89+ from datetime import datetime as dt
90+ from pandas import Series
91+
92+ .. ipython:: python
93+
94+ fixings.add("MY_RATE_INDEX_6M", Series(index=[dt(2000, 1, 1)], data=[2.66]))
95+ period = FloatPeriod(
96+ start=dt(2000, 1, 1),
97+ end=dt(2000, 7, 1),
98+ payment=dt(2000, 7, 1),
99+ notional=1e6,
100+ convention="Act360",
101+ frequency="S",
102+ fixing_method="ibor",
103+ method_param=0,
104+ rate_fixings="MY_RATE_INDEX"
105+ )
106+ period.cashflows()
107+
108+ .. ipython:: python
109+ :suppress:
110+
111+ fixings.pop("MY_RATE_INDEX_6M")
112+
82113 Parameters
83114 ----------
84115 .
@@ -494,6 +525,35 @@ class ZeroFloatPeriod(_BasePeriodStatic):
494525
495526 For *analytic delta* purposes the :math:`\xi=-z`.
496527
528+ .. rubric:: Examples
529+
530+ .. ipython:: python
531+ :suppress:
532+
533+ from rateslib.periods.components import ZeroFloatPeriod
534+ from rateslib.scheduling import Schedule
535+ from datetime import datetime as dt
536+
537+ .. ipython:: python
538+
539+ fixings.add("MY_RATE_INDEX_6M", Series(
540+ index=[dt(2000, 1, 1), dt(2000, 7, 1), dt(2001, 1, 1), dt(2001, 7, 1)],
541+ data=[1.0, 2.0, 3.0, 4.0]
542+ ))
543+ period = ZeroFloatPeriod(
544+ schedule=Schedule(dt(2000, 1, 1), "2Y", "S"),
545+ fixing_method="IBOR",
546+ rate_fixings="MY_RATE_INDEX",
547+ convention="Act360",
548+ method_param=0,
549+ )
550+ period.cashflows()
551+
552+ .. ipython:: python
553+ :suppress:
554+
555+ fixings.pop("MY_RATE_INDEX_6M")
556+
497557 .. role:: red
498558
499559 .. role:: green
@@ -581,35 +641,12 @@ class ZeroFloatPeriod(_BasePeriodStatic):
581641 index_only: bool, :green:`optional (set as False)`
582642 A flag which determines non-payment of notional on supported *Periods*.
583643
584-
585- Examples
586- --------
587-
588- A typical :class:`~rateslib.periods.components.ZeroFloatPeriod`.
589-
590- .. ipython:: python
591- :suppress:
592-
593- from rateslib.periods.components import ZeroFloatPeriod
594- from rateslib.scheduling import Schedule
595- from datetime import datetime as dt
596-
597- .. ipython:: python
598-
599- period = ZeroFloatPeriod(
600- schedule=Schedule(dt(2000, 1, 1), "2Y", "S"),
601- fixing_method="IBOR",
602- rate_fixings=[1.1, 2.1, 3.1, 4.1],
603- convention="Act360",
604- )
605- period.cashflows()
606-
607644 """ # noqa: E501
608645
609646 @property
610647 def rate_params (self ) -> _FloatRateParams :
611648 """The :class:`~rateslib.periods.components.parameters._FixedRateParams` of the *Period*."""
612- return self ._float_periods [0 ].rate_params
649+ return self .float_periods [0 ].rate_params
613650
614651 @property
615652 def period_params (self ) -> _PeriodParams :
@@ -648,6 +685,14 @@ def float_spread(self, value: DualTypes) -> None:
648685 for period in self ._float_periods :
649686 period .rate_params .float_spread = value
650687
688+ @property
689+ def float_periods (self ) -> list [FloatPeriod ]:
690+ """
691+ The individual :class:`~rateslib.periods.components.period.FloatPeriod` that are
692+ compounded.
693+ """
694+ return self ._float_periods
695+
651696 def __init__ (
652697 self ,
653698 * ,
@@ -746,8 +791,8 @@ def try_rate(
746791 ** kwargs : Any ,
747792 ) -> Result [DualTypes ]:
748793 try :
749- r_i = [period .rate (rate_curve = rate_curve ) for period in self ._float_periods ]
750- d_i = [period .period_params .dcf for period in self ._float_periods ]
794+ r_i = [period .rate (rate_curve = rate_curve ) for period in self .float_periods ]
795+ d_i = [period .period_params .dcf for period in self .float_periods ]
751796 except Exception as e :
752797 return Err (e )
753798
@@ -785,8 +830,8 @@ def unindexed_reference_cashflow(
785830 ** kwargs : Any ,
786831 ) -> DualTypes :
787832 # determine each rate from individual Periods
788- r_i = [period .rate (rate_curve = rate_curve ) for period in self ._float_periods ]
789- d_i = [period .period_params .dcf for period in self ._float_periods ]
833+ r_i = [period .rate (rate_curve = rate_curve ) for period in self .float_periods ]
834+ d_i = [period .period_params .dcf for period in self .float_periods ]
790835 r = np .prod (1.0 + np .array (r_i ) * np .array (d_i ) / 100.0 ) - 1.0
791836 return - self .settlement_params .notional * r
792837
@@ -822,8 +867,8 @@ def try_unindexed_reference_cashflow_analytic_rate_fixings(
822867 fx_vol : FXVolOption_ = NoInput (0 ),
823868 ) -> Result [DataFrame ]:
824869 try :
825- r_i = [period .rate (rate_curve = rate_curve ) for period in self ._float_periods ]
826- d_i = [period .period_params .dcf for period in self ._float_periods ]
870+ r_i = [period .rate (rate_curve = rate_curve ) for period in self .float_periods ]
871+ d_i = [period .period_params .dcf for period in self .float_periods ]
827872 dfs_i = [
828873 period .try_unindexed_reference_cashflow_analytic_rate_fixings (
829874 rate_curve = rate_curve ,
@@ -832,7 +877,7 @@ def try_unindexed_reference_cashflow_analytic_rate_fixings(
832877 fx_vol = fx_vol ,
833878 index_curve = index_curve ,
834879 ).unwrap ()
835- for period in self ._float_periods
880+ for period in self .float_periods
836881 ]
837882 except Exception as e :
838883 return Err (e )
0 commit comments