Amortization#
- class rateslib.legs.Amortization(n, initial, amortization=NoInput.blank)#
Bases:
objectAn amortization schedule for any
_BaseLeg.Examples
In [1]: obj = Amortization(n=5, initial=1e6, amortization="to_zero") In [2]: obj.outstanding Out[2]: (1000000.0, 800000.0, 600000.0, 400000.0, 199999.99999999994) In [3]: obj.amortization Out[3]: (200000.0, 200000.0, 200000.0, 200000.0)
- Parameters:
Notes
If
amortizationis:not specified then the schedule is assumed to have no amortization.
some scalar then the amortization amount will be a constant value per period.
a list or tuple of n-1 scalars, then this is defines a custome amortization schedule.
a string flag then an amortization schedule will be calculated directly:
“to_zero”: each period will be a constant value ending with zero implied ending balance.
“{float}%”: each period will amortize by a constant percentage of the outstanding balance.
Using Amortization with Instruments
This section exemplifies how to use
Amortizationwith instruments.Key Points
Amortization can be added to Instruments using the per leg
amortizationargument.It supports constant notional amortization, or custom schedules or the
Amortizationclass can be used to calculate other simple structures.Some Instruments have not yet integrated amortization into their calculation, such as Bonds.
Standard Amortization
The
FixedLegandFloatLegclasses both haveamortizationas an input argument. AnAmortizationclass can be directly supplied or other values are internally passed to this class for syntactic convenience.The simplest, and most common, type of
amortizationto apply is a constant notional per period.In [4]: fxl = FixedLeg( ...: schedule=Schedule(dt(2000, 1, 1), "1y", "Q"), ...: notional=10e6, ...: amortization=1e6, # <- 1mm reduction per period ...: ) ...: In [5]: fxl.cashflows()[["Type", "Acc Start", "Notional"]] Out[5]: Type Acc Start Notional 0 FixedPeriod 2000-01-01 10000000.0 1 FixedPeriod 2000-04-01 9000000.0 2 FixedPeriod 2000-07-01 8000000.0 3 FixedPeriod 2000-10-01 7000000.0
In [6]: fll = FloatLeg( ...: schedule=Schedule(dt(2000, 1, 1), "1y", "M"), ...: notional=10e6, ...: amortization=0.5e6, # 0.5mm reduction per period ...: ) ...: In [7]: fll.cashflows()[["Type", "Acc Start", "Notional"]] Out[7]: Type Acc Start Notional 0 FloatPeriod 2000-01-01 10000000.0 1 FloatPeriod 2000-02-01 9500000.0 2 FloatPeriod 2000-03-01 9000000.0 3 FloatPeriod 2000-04-01 8500000.0 4 FloatPeriod 2000-05-01 8000000.0 5 FloatPeriod 2000-06-01 7500000.0 6 FloatPeriod 2000-07-01 7000000.0 7 FloatPeriod 2000-08-01 6500000.0 8 FloatPeriod 2000-09-01 6000000.0 9 FloatPeriod 2000-10-01 5500000.0 10 FloatPeriod 2000-11-01 5000000.0 11 FloatPeriod 2000-12-01 4500000.0
Here, the amortization is expressed in a specific notional amount reduction per period so, when applied to an
IRS, each leg with different frequencies should be input directly.If a Leg has a final notional exchange then any amortized amount would, under standard convention, be paid out at the same time as the notional change. The final cashflow will be reduced by the amount of interim exchanges that have already occurred. This can be exemplified on a
XCS.In [8]: irs = IRS( ...: effective=dt(2000, 1, 1), ...: termination="1Y", ...: frequency="Q", ...: leg2_frequency="S", ...: notional=1e6, ...: amortization=2e5, # <- Reduces notional on 1st July to 600,000 ...: leg2_amortization=-4e5, # <- Aligns the notional on 1st July ...: ) ...: In [9]: irs.cashflows()[["Type", "Acc Start", "Notional"]] Out[9]: Type Acc Start Notional leg1 0 FixedPeriod 2000-01-01 1000000.0 1 FixedPeriod 2000-04-01 800000.0 2 FixedPeriod 2000-07-01 600000.0 3 FixedPeriod 2000-10-01 400000.0 leg2 0 FloatPeriod 2000-01-01 -1000000.0 1 FloatPeriod 2000-07-01 -600000.0
In [10]: xcs = XCS( ....: effective=dt(2000, 1, 1), ....: termination="1y", ....: spec="eurusd_xcs", ....: notional=5e6, ....: amortization=1e6, # <- 1mm reduction and notional exchange per period ....: leg2_mtm=False, ....: ) ....: In [11]: xcs.cashflows()[["Type", "Period", "Acc Start", "Payment", "Ccy", "Notional", "Reference Ccy"]] Out[11]: Type Period Acc Start Payment Ccy Notional Reference Ccy leg1 0 Cashflow NaN NaT 2000-01-03 EUR -5000000.0 NaN 1 FloatPeriod Regular 2000-01-03 2000-04-05 EUR 5000000.0 NaN 2 Cashflow NaN NaT 2000-04-03 EUR 1000000.0 NaN 3 FloatPeriod Regular 2000-04-03 2000-07-06 EUR 4000000.0 NaN 4 Cashflow NaN NaT 2000-07-03 EUR 1000000.0 NaN 5 FloatPeriod Regular 2000-07-03 2000-10-04 EUR 3000000.0 NaN 6 Cashflow NaN NaT 2000-10-02 EUR 1000000.0 NaN 7 FloatPeriod Regular 2000-10-02 2001-01-04 EUR 2000000.0 NaN 8 Cashflow NaN NaT 2001-01-02 EUR 2000000.0 NaN leg2 0 Cashflow NaN NaT 2000-01-03 USD 5000000.0 EUR 1 FloatPeriod Regular 2000-01-03 2000-04-05 USD -5000000.0 EUR 2 Cashflow NaN NaT 2000-04-03 USD -1000000.0 EUR 3 FloatPeriod Regular 2000-04-03 2000-07-06 USD -4000000.0 EUR 4 Cashflow NaN NaT 2000-07-03 USD -1000000.0 EUR 5 FloatPeriod Regular 2000-07-03 2000-10-04 USD -3000000.0 EUR 6 Cashflow NaN NaT 2000-10-02 USD -1000000.0 EUR 7 FloatPeriod Regular 2000-10-02 2001-01-04 USD -2000000.0 EUR 8 Cashflow NaN NaT 2001-01-02 USD -2000000.0 EUR
Mark-to-market
XCSalso supportamortizationwhich affects the MTM cashflows respectively.In [12]: xcs = XCS( ....: effective=dt(2000, 1, 1), ....: termination="1y", ....: spec="eurusd_xcs", ....: notional=5e6, ....: amortization=1e6, # <- 1mm reduction and notional exchange per period ....: leg2_mtm=True, ....: ) ....: In [13]: xcs.cashflows()[["Type", "Period", "Acc Start", "Payment", "Ccy", "Notional", "Reference Ccy"]] Out[13]: Type Period Acc Start Payment Ccy Notional Reference Ccy leg1 0 Cashflow NaN NaT 2000-01-03 EUR -5000000.0 NaN 1 FloatPeriod Regular 2000-01-03 2000-04-05 EUR 5000000.0 NaN 2 Cashflow NaN NaT 2000-04-03 EUR 1000000.0 NaN 3 FloatPeriod Regular 2000-04-03 2000-07-06 EUR 4000000.0 NaN 4 Cashflow NaN NaT 2000-07-03 EUR 1000000.0 NaN 5 FloatPeriod Regular 2000-07-03 2000-10-04 EUR 3000000.0 NaN 6 Cashflow NaN NaT 2000-10-02 EUR 1000000.0 NaN 7 FloatPeriod Regular 2000-10-02 2001-01-04 EUR 2000000.0 NaN 8 Cashflow NaN NaT 2001-01-02 EUR 2000000.0 NaN leg2 0 Cashflow NaN NaT 2000-01-03 USD 5000000.0 EUR 1 FloatPeriod Regular 2000-01-03 2000-04-05 USD -5000000.0 EUR 2 MtmCashflow NaN NaT 2000-04-03 USD 5000000.0 EUR 3 Cashflow NaN NaT 2000-04-03 USD -1000000.0 EUR 4 FloatPeriod Regular 2000-04-03 2000-07-06 USD -4000000.0 EUR 5 MtmCashflow NaN NaT 2000-07-03 USD 4000000.0 EUR 6 Cashflow NaN NaT 2000-07-03 USD -1000000.0 EUR 7 FloatPeriod Regular 2000-07-03 2000-10-04 USD -3000000.0 EUR 8 MtmCashflow NaN NaT 2000-10-02 USD 3000000.0 EUR 9 Cashflow NaN NaT 2000-10-02 USD -1000000.0 EUR 10 FloatPeriod Regular 2000-10-02 2001-01-04 USD -2000000.0 EUR 11 Cashflow NaN NaT 2001-01-02 USD -2000000.0 EUR
Custom Amortization
By using the
Amortizationclass custom amortization can be directly input to an Instrument. The following examples are the same, with the first being syntactic convenience for the second. The above examples are also syntactic convenience for applying the same amortization amount each period.In [14]: irs = IRS( ....: effective=dt(2000, 1, 1), ....: termination="1Y", ....: frequency="Q", ....: leg2_frequency="S", ....: notional=1e6, ....: amortization=[100000, 300000, -5000], # <- Reduces notional on 1st July to 600,000 ....: leg2_amortization=[-400000], # <- Aligns the notional on 1st July ....: ) ....: In [15]: irs.cashflows()[["Type", "Acc Start", "Notional"]] Out[15]: Type Acc Start Notional leg1 0 FixedPeriod 2000-01-01 1000000.0 1 FixedPeriod 2000-04-01 900000.0 2 FixedPeriod 2000-07-01 600000.0 3 FixedPeriod 2000-10-01 605000.0 leg2 0 FloatPeriod 2000-01-01 -1000000.0 1 FloatPeriod 2000-07-01 -600000.0
In [16]: irs = IRS( ....: effective=dt(2000, 1, 1), ....: termination="1Y", ....: frequency="Q", ....: leg2_frequency="S", ....: notional=1e6, ....: amortization=Amortization(4, 1e6, [100000, 300000, -5000]), ....: leg2_amortization=Amortization(2, -1e6, [-400000]) ....: ) ....: In [17]: irs.cashflows()[["Type", "Acc Start", "Notional"]] Out[17]: Type Acc Start Notional leg1 0 FixedPeriod 2000-01-01 1000000.0 1 FixedPeriod 2000-04-01 900000.0 2 FixedPeriod 2000-07-01 600000.0 3 FixedPeriod 2000-10-01 605000.0 leg2 0 FloatPeriod 2000-01-01 -1000000.0 1 FloatPeriod 2000-07-01 -600000.0
Unsupported Instruments
Instruments that currently do not support amortization are Bonds.
In [18]: try: ....: FixedRateBond( ....: effective=dt(2000, 1, 1), ....: termination="1y", ....: spec="us_gb", ....: notional=5e6, ....: amortization=1e6, ....: fixed_rate=2.0, ....: ) ....: except Exception as e: ....: print(e) ....: FixedRateBond.__init__() got an unexpected keyword argument 'amortization'
In [19]: try: ....: IndexFixedRateBond( ....: effective=dt(2000, 1, 1), ....: termination="1y", ....: spec="us_gb", ....: notional=5e6, ....: amortization=1e6, ....: fixed_rate=2.0, ....: index_base=100.0, ....: ) ....: except Exception as e: ....: print(e) ....: IndexFixedRateBond.__init__() got an unexpected keyword argument 'amortization'
Attributes Summary
A tuple of (n-1) amortization amounts for each Period.
A tuple of n outstanding notional amounts for each Period.
Attributes Documentation
- amortization#
A tuple of (n-1) amortization amounts for each Period.
- outstanding#
A tuple of n outstanding notional amounts for each Period.