Skip to content

Commit ccd078c

Browse files
authored
DOC: edits (#1115)
1 parent 0ad667c commit ccd078c

File tree

21 files changed

+164
-315
lines changed

21 files changed

+164
-315
lines changed

docs/source/spec/calendars/aud_nsw.rst

Lines changed: 0 additions & 17 deletions
This file was deleted.

python/rateslib/curves/curves.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def roll(self, tenor: datetime | str | int, id: str_ = NoInput(0)) -> RolledCurv
139139
""" # noqa: E501
140140
_: _BaseCurve = self # type: ignore[assignment]
141141
if isinstance(tenor, str):
142-
tenor_ = add_tenor(_._nodes.initial, tenor, "NONE", NoInput(0))
142+
tenor_: datetime | int = add_tenor(_._nodes.initial, tenor, "NONE", NoInput(0))
143143
else:
144144
tenor_ = tenor
145145

python/rateslib/instruments/__init__.py

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
FixedRateBond,
77
FloatRateNote,
88
IndexFixedRateBond,
9+
_BaseBondInstrument,
910
)
1011
from rateslib.instruments.cds import CDS
1112
from rateslib.instruments.fly import Fly
@@ -14,18 +15,20 @@
1415
from rateslib.instruments.fx_options import (
1516
FXBrokerFly,
1617
FXCall,
17-
FXOption,
1818
FXPut,
1919
FXRiskReversal,
2020
FXStraddle,
2121
FXStrangle,
22+
_BaseFXOption,
23+
_BaseFXOptionStrat,
2224
)
2325
from rateslib.instruments.fx_swap import FXSwap
2426
from rateslib.instruments.fx_vol_value import FXVolValue
2527
from rateslib.instruments.iirs import IIRS
2628
from rateslib.instruments.irs import IRS
2729
from rateslib.instruments.ndf import NDF
2830
from rateslib.instruments.portfolio import Portfolio
31+
from rateslib.instruments.protocols import _BaseInstrument
2932
from rateslib.instruments.sbs import SBS
3033
from rateslib.instruments.spread import Spread
3134
from rateslib.instruments.stir_future import STIRFuture
@@ -35,35 +38,45 @@
3538
from rateslib.instruments.zcs import ZCS
3639

3740
__all__ = [
38-
"FRA",
41+
# derivatives
3942
"IRS",
40-
"XCS",
43+
"FRA",
44+
"SBS",
4145
"STIRFuture",
4246
"ZCS",
47+
# cross currency
48+
"XCS",
49+
"NDF",
50+
"FXSwap",
51+
"FXForward",
52+
# inflation
4353
"ZCIS",
4454
"IIRS",
55+
# credit
4556
"CDS",
46-
"SBS",
47-
"NDF",
48-
"Portfolio",
49-
"Fly",
50-
"Spread",
51-
"Value",
52-
"FXForward",
53-
"FXVolValue",
54-
"FXSwap",
57+
# securities
5558
"FixedRateBond",
5659
"FloatRateNote",
5760
"IndexFixedRateBond",
5861
"BondFuture",
5962
"Bill",
63+
# fx options
6064
"FXPut",
6165
"FXCall",
62-
"FXOption",
6366
"FXRiskReversal",
6467
"FXStraddle",
6568
"FXStrangle",
6669
"FXBrokerFly",
70+
# generics
71+
"Portfolio",
72+
"Fly",
73+
"Spread",
74+
"Value",
75+
"FXVolValue",
6776
"BondCalcMode",
6877
"BillCalcMode",
78+
"_BaseInstrument",
79+
"_BaseBondInstrument",
80+
"_BaseFXOption",
81+
"_BaseFXOptionStrat",
6982
]

python/rateslib/instruments/bonds/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from rateslib.instruments.bonds.fixed_rate_bond import FixedRateBond
55
from rateslib.instruments.bonds.float_rate_note import FloatRateNote
66
from rateslib.instruments.bonds.index_fixed_rate_bond import IndexFixedRateBond
7+
from rateslib.instruments.bonds.protocols import _BaseBondInstrument
78

89
__all__ = [
910
"FixedRateBond",
@@ -13,4 +14,5 @@
1314
"FloatRateNote",
1415
"BillCalcMode",
1516
"BondCalcMode",
17+
"_BaseBondInstrument",
1618
]

python/rateslib/instruments/bonds/float_rate_note.py

Lines changed: 0 additions & 185 deletions
Original file line numberDiff line numberDiff line change
@@ -47,101 +47,6 @@ class FloatRateNote(_BaseBondInstrument):
4747
"""
4848
Create a floating rate note (FRN) security.
4949
50-
Parameters
51-
----------
52-
effective : datetime
53-
The adjusted or unadjusted effective date.
54-
termination : datetime or str
55-
The adjusted or unadjusted termination date. If a string, then a tenor must be
56-
given expressed in days (`"D"`), months (`"M"`) or years (`"Y"`), e.g. `"48M"`.
57-
frequency : str in {"M", "B", "Q", "T", "S", "A"}, optional
58-
The frequency of the schedule. "Z" is not permitted.
59-
stub : str combining {"SHORT", "LONG"} with {"FRONT", "BACK"}, optional
60-
The stub type to enact on the swap. Can provide two types, for
61-
example "SHORTFRONTLONGBACK".
62-
front_stub : datetime, optional
63-
An adjusted or unadjusted date for the first stub period.
64-
back_stub : datetime, optional
65-
An adjusted or unadjusted date for the back stub period.
66-
See notes for combining ``stub``, ``front_stub`` and ``back_stub``
67-
and any automatic stub inference.
68-
roll : int in [1, 31] or str in {"eom", "imm", "som"}, optional
69-
The roll day of the schedule. Inferred if not given.
70-
eom : bool, optional
71-
Use an end of month preference rather than regular rolls for inference. Set by
72-
default. Not required if ``roll`` is specified.
73-
modifier : str, optional
74-
The modification rule, in {"F", "MF", "P", "MP"}
75-
calendar : calendar or str, optional
76-
The holiday calendar object to use. If str, looks up named calendar from
77-
static data.
78-
payment_lag : int, optional
79-
The number of business days to lag regular coupon payments by.
80-
payment_lag_exchange : int, optional
81-
The number of business days to lag notional exchange payments by.
82-
notional : float, optional
83-
The leg notional, which is applied to each period.
84-
currency : str, optional
85-
The currency of the leg (3-digit code).
86-
amortization: float, optional
87-
The amount by which to adjust the notional each successive period. Should have
88-
sign equal to that of notional if the notional is to reduce towards zero.
89-
convention: str, optional
90-
The day count convention applied to calculations of period accrual dates.
91-
See :meth:`~rateslib.scheduling.dcf`.
92-
float_spread : float, optional
93-
The spread applied to determine cashflows. Can be set to `None` and designated
94-
later, perhaps after a mid-market spread for all periods has been calculated.
95-
spread_compound_method : str, optional
96-
The method to use for adding a floating spread to compounded rates. Available
97-
options are `{"none_simple", "isda_compounding", "isda_flat_compounding"}`.
98-
fixings : float or list, optional
99-
If a float scalar, will be applied as the determined fixing for the first
100-
period. If a list of *n* fixings will be used as the fixings for the first *n*
101-
periods. If any sublist of length *m* is given as the first *m* RFR fixings
102-
within individual curve and composed into the overall rate.
103-
fixing_method : str, optional
104-
The method by which floating rates are determined, set by default. See notes.
105-
method_param : int, optional
106-
A parameter that is used for the various ``fixing_method`` s. See notes.
107-
ex_div : int
108-
The number of business days prior to a cashflow which determines the last settlement date
109-
for which a coupon payment is still receivable. See :meth:`BondMixin.ex_div`.
110-
settle : int
111-
The number of business days for regular settlement time, i.e, 1 is T+1.
112-
calc_mode : str
113-
A calculation mode for dealing with bonds under different conventions. See notes.
114-
curves : CurveType, str or list of such, optional
115-
A single *Curve* or string id or a list of such.
116-
117-
A list defines the following curves in the order:
118-
119-
- Forecasting *Curve* for ``leg1``.
120-
- Discounting :class:`~rateslib.curves.Curve` for ``leg1``.
121-
spec : str, optional
122-
An identifier to pre-populate many field with conventional values. See
123-
:ref:`here<defaults-doc>` for more info and available values.
124-
metric: str, optional
125-
The pricing metric returned by the ``rate`` method of the *Instrument*.
126-
127-
Notes
128-
-----
129-
.. warning::
130-
131-
FRNs based on RFR rates which have ex-div days must ensure that fixings are
132-
available to define the entire period. This means that `ex_div` days must be less
133-
than the `fixing_method` `method_param` lag minus the time to settlement time.
134-
135-
That is, a bond with a `method_param` of 5 and a settlement time of 2 days
136-
can have an `ex_div` period of at maximum 3.
137-
138-
A bond with a `method_param` of 2 and a settlement time of 1 day cnan have an
139-
`ex_div` period of at maximum 1.
140-
141-
Attributes
142-
----------
143-
ex_div_days : int
144-
leg1 : FloatLeg
14550
"""
14651

14752
_rate_scalar = 1.0
@@ -373,96 +278,6 @@ def accrued(
373278
settlement: datetime,
374279
rate_curve: CurveOption_ = NoInput(0),
375280
) -> DualTypes:
376-
"""
377-
Calculate the accrued amount per nominal par value of 100.
378-
379-
Parameters
380-
----------
381-
settlement : datetime
382-
The settlement date which to measure accrued interest against.
383-
curve : Curve, optional
384-
If ``forecast`` is *True* and fixings are future based then must provide
385-
a forecast curve.
386-
387-
Notes
388-
-----
389-
The settlement of an FRN will always be a definite amount. The
390-
``fixing_method``, ``method_param`` and ``ex_div`` will contain a
391-
valid combination of parameters such that when payments need to be
392-
cleared these definitive amounts can be calculated
393-
via previously published fixings.
394-
395-
If the coupon is IBOR based then the accrued
396-
fractionally apportions the coupon payment based on calendar days, including
397-
negative accrued during ex div periods. This rarely poses a problem since
398-
IBOR is fixed well in advance of settlement.
399-
400-
.. math::
401-
402-
\\text{Accrued} = \\text{Coupon} \\times \\frac{\\text{Settle - Last Coupon}}{\\text{Next Coupon - Last Coupon}}
403-
404-
With RFR rates, however, and since ``settlement`` typically occurs
405-
in the future, e.g. T+2, it may be
406-
possible, particularly if the bond is *ex-div* that some fixings are not known
407-
today, but they will be known by ``settlement``. This is also true if we
408-
wish to calculate the forward dirty price of a bond and need to forecast
409-
the accrued amount (and also for a forecast IBOR period).
410-
411-
Thus, there are two options:
412-
413-
- In the analogue mode where very few fixings might be missing, and we require
414-
these values to calculate negative accrued in an ex-div period we do not
415-
require a ``curve`` but repeat the last historic fixing.
416-
- In the digital mode where the ``settlement`` is likely in the future we
417-
use a ``curve`` to forecast rates,
418-
419-
Examples
420-
--------
421-
An RFR based FRN where the fixings are known up to the end of period.
422-
423-
.. ipython:: python
424-
:suppress:
425-
426-
from rateslib import FloatRateNote
427-
from pandas import date_range
428-
429-
.. ipython:: python
430-
431-
fixings = Series(2.0, index=date_range(dt(1999, 12, 1), dt(2000, 6, 2)))
432-
frn = FloatRateNote(
433-
effective=dt(1998, 12, 7),
434-
termination=dt(2015, 12, 7),
435-
frequency="S",
436-
currency="gbp",
437-
convention="Act365F",
438-
ex_div=3,
439-
fixings=fixings,
440-
fixing_method="rfr_observation_shift",
441-
method_param=5,
442-
)
443-
frn.accrued(dt(2000, 3, 27))
444-
frn.accrued(dt(2000, 6, 4))
445-
446-
447-
An IBOR based FRN where the coupon is known in advance.
448-
449-
.. ipython:: python
450-
451-
fixings = Series(2.0, index=[dt(1999, 12, 5)])
452-
frn = FloatRateNote(
453-
effective=dt(1998, 12, 7),
454-
termination=dt(2015, 12, 7),
455-
frequency="S",
456-
currency="gbp",
457-
convention="Act365F",
458-
ex_div=7,
459-
fixings=fixings,
460-
fixing_method="ibor",
461-
method_param=2,
462-
)
463-
frn.accrued(dt(2000, 3, 27))
464-
frn.accrued(dt(2000, 6, 4))
465-
""" # noqa: E501
466281
acc_idx = self.leg1._period_index(settlement)
467282
if self.leg1.rate_params.fixing_method == FloatFixingMethod.IBOR:
468283
frac = self.kwargs.meta["calc_mode"]._settle_accrual(self, settlement, acc_idx)
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
from rateslib.instruments.fx_options.brokerfly import FXBrokerFly
2-
from rateslib.instruments.fx_options.call_put import FXCall, FXOption, FXPut
3-
from rateslib.instruments.fx_options.risk_reversal import FXRiskReversal
2+
from rateslib.instruments.fx_options.call_put import FXCall, FXPut, _BaseFXOption
3+
from rateslib.instruments.fx_options.risk_reversal import FXRiskReversal, _BaseFXOptionStrat
44
from rateslib.instruments.fx_options.straddle import FXStraddle
55
from rateslib.instruments.fx_options.strangle import FXStrangle
66

77
__all__ = [
88
"FXCall",
99
"FXPut",
10-
"FXOption",
1110
"FXRiskReversal",
1211
"FXStraddle",
1312
"FXStrangle",
1413
"FXBrokerFly",
14+
"_BaseFXOption",
15+
"_BaseFXOptionStrat",
1516
]

0 commit comments

Comments
 (0)