4040
4141class CreditPremiumLeg (_BaseLeg , _WithExDiv ):
4242 """
43- Define a *Leg* containing :class:`~rateslib.periods.CreditPremiumPeriod`.
43+ A *Leg* containing :class:`~rateslib.periods.CreditPremiumPeriod`.
44+
45+ .. rubric:: Examples
46+
47+ .. ipython:: python
48+ :suppress:
49+
50+ from rateslib import Schedule
51+ from rateslib.legs import CreditPremiumLeg
52+ from datetime import datetime as dt
53+
54+ .. ipython:: python
55+
56+ cpl = CreditPremiumLeg(
57+ schedule=Schedule(
58+ effective=dt(2000, 3, 20),
59+ termination=dt(2001, 3, 20),
60+ frequency="Q",
61+ modifier="FEX",
62+ ),
63+ convention="Act360",
64+ fixed_rate=1.0,
65+ notional=10e6,
66+ )
67+ cpl.cashflows()
4468
4569 .. role:: red
4670
@@ -87,15 +111,6 @@ class CreditPremiumLeg(_BaseLeg, _WithExDiv):
87111 premium_accrued: bool, :green:`optional (set by 'defaults')`
88112 Whether an accrued premium is paid on the event of mid-period credit default.
89113
90-
91- Notes
92- -----
93- TODO
94-
95- Examples
96- --------
97- See :ref:`Leg Examples<legs-doc>`
98-
99114 """
100115
101116 @property
@@ -111,6 +126,8 @@ def periods(self) -> list[CreditPremiumPeriod]:
111126
112127 @property
113128 def fixed_rate (self ) -> DualTypes_ :
129+ """The fixed rate parameter of each composited
130+ :class:`~rateslib.periods.CreditPremiumPeriod`."""
114131 return self ._fixed_rate
115132
116133 @fixed_rate .setter
@@ -121,10 +138,14 @@ def fixed_rate(self, value: DualTypes_) -> None:
121138
122139 @property
123140 def schedule (self ) -> Schedule :
141+ """The :class:`~rateslib.scheduling.Schedule` object of *Leg*."""
124142 return self ._schedule
125143
126144 @property
127145 def amortization (self ) -> Amortization :
146+ """
147+ The :class:`~rateslib.legs.Amortization` object associated with the schedule.
148+ """
128149 return self ._amortization
129150
130151 def accrued (self , settlement : datetime ) -> DualTypes :
@@ -225,50 +246,51 @@ def spread(
225246
226247class CreditProtectionLeg (_BaseLeg ):
227248 """
228- Create a credit protection leg composed of :class:`~rateslib.periods.CreditProtectionPeriod` s .
249+ A *Leg* containing :class:`~rateslib.periods.CreditProtectionPeriod`.
229250
230- Parameters
231- ----------
232- args : tuple
233- Required positional args to :class:`BaseLeg`.
234- kwargs : dict
235- Required keyword arguments to :class:`BaseLeg`.
251+ .. rubric:: Examples
236252
237- Notes
238- -----
239- The NPV of a credit protection leg is the sum of the period NPVs.
253+ .. ipython:: python
254+ :suppress:
240255
241- .. math::
256+ from rateslib import dt, CreditProtectionLeg, Schedule
242257
243- P = \\ sum_{i=1}^n P_i
258+ .. ipython:: python
244259
245- The analytic delta is the sum of the period analytic deltas.
260+ cpl = CreditProtectionLeg(
261+ schedule=Schedule(
262+ effective=dt(2000, 3, 20),
263+ termination=dt(2001, 3, 30),
264+ frequency="Z",
265+ ),
266+ notional=10e6,
267+ )
268+ cpl.cashflows()
246269
247- .. math::
270+ .. role:: red
248271
249- A = - \\ frac{ \\ partial P}{ \\ partial S} = \\ sum_{i=1}^n - \\ frac{ \\ partial P_i}{ \\ partial S}
272+ .. role:: green
250273
251- Examples
252- --------
274+ Parameters
275+ ----------
276+ schedule: Schedule, :red:`required`
277+ The :class:`~rateslib.scheduling.Schedule` object which structures contiguous *Periods*.
278+ The schedule object also contains data for payment dates, payment dates for notional
279+ exchanges and ex-dividend dates for each period.
253280
254- .. ipython:: python
255- :suppress:
281+ .. note::
256282
257- from rateslib.curves import Curve
258- from rateslib.scheduling import Schedule
259- from rateslib.legs import CreditProtectionLeg
260- from datetime import datetime as dt
283+ The following define generalised **settlement** parameters.
261284
262- .. ipython:: python
285+ currency : str, :green:`optional (set by 'defaults')`
286+ The local settlement currency of the leg (3-digit code).
287+ notional : float, Dual, Dual2, Variable, :green:`optional (set by 'defaults')`
288+ The initial leg notional, defined in units of *reference currency*.
289+ amortization: float, Dual, Dual2, Variable, str, Amortization, :green:`optional (set as zero)`
290+ Set a non-constant notional per *Period*. If a scalar value, adjusts the ``notional`` of
291+ each successive period by that same value. Should have
292+ sign equal to that of notional if the notional is to reduce towards zero.
263293
264- disc_curve = Curve({dt(2022, 1, 1): 1.0, dt(2023, 1, 1): 0.98})
265- hazard_curve = Curve({dt(2022, 1, 1): 1.0, dt(2023, 1, 1): 0.995})
266- protection_leg = CreditProtectionLeg(
267- schedule=Schedule(dt(2022, 1, 1), "9M", "Z"),
268- notional=1000000,
269- )
270- protection_leg.cashflows(rate_curve=hazard_curve, disc_curve=disc_curve)
271- protection_leg.npv(rate_curve=hazard_curve, disc_curve=disc_curve)
272294 """ # noqa: E501
273295
274296 @property
@@ -284,10 +306,14 @@ def periods(self) -> list[CreditProtectionPeriod]:
284306
285307 @property
286308 def schedule (self ) -> Schedule :
309+ """The :class:`~rateslib.scheduling.Schedule` object of *Leg*."""
287310 return self ._schedule
288311
289312 @property
290313 def amortization (self ) -> Amortization :
314+ """
315+ The :class:`~rateslib.legs.Amortization` object associated with the schedule.
316+ """
291317 return self ._amortization
292318
293319 def __init__ (
@@ -299,15 +325,15 @@ def __init__(
299325 amortization : DualTypes_ | list [DualTypes ] | Amortization | str = NoInput (0 ),
300326 currency : str_ = NoInput (0 ),
301327 # period
302- convention : str_ = NoInput (0 ),
328+ # convention: str_ = NoInput(0),
303329 ) -> None :
304330 self ._schedule = schedule
305331 self ._notional : DualTypes = _drb (defaults .notional , notional )
306332 self ._amortization : Amortization = _get_amortization (
307333 amortization , self ._notional , self .schedule .n_periods
308334 )
309335 self ._currency : str = _drb (defaults .base_currency , currency ).lower ()
310- self ._convention : str = _drb (defaults .convention , convention )
336+ # self._convention: str = _drb(defaults.convention, convention)
311337
312338 self ._regular_periods = tuple (
313339 [
@@ -321,7 +347,7 @@ def __init__(
321347 start = self .schedule .aschedule [i ],
322348 end = self .schedule .aschedule [i + 1 ],
323349 frequency = self .schedule .frequency_obj ,
324- convention = self ._convention ,
350+ # convention=self._convention,
325351 termination = self .schedule .aschedule [- 1 ],
326352 stub = self .schedule ._stubs [i ],
327353 roll = NoInput (0 ), # defined by Frequency
0 commit comments