FXSwap#
- class rateslib.instruments.FXSwap(effective, termination, pair, *, roll=NoInput.blank, eom=NoInput.blank, modifier=NoInput.blank, calendar=NoInput.blank, notional=NoInput.blank, leg2_notional=NoInput.blank, split_notional=NoInput.blank, fx_rate=NoInput.blank, points=NoInput.blank, curves=NoInput.blank, spec=NoInput.blank)#
Bases:
_BaseInstrumentAn FX swap composing two
CustomLegof individualCashflowof different currencies.Examples
Paying a 3M EURUSD FX Swap expressed in USD notional at 56.5 swap points.
In [1]: fxs = FXSwap( ...: effective=dt(2022, 1, 19), ...: termination="3m", ...: calendar="tgt|fed", ...: pair="eurusd", ...: leg2_notional=-10e6, ...: split_notional=-10.25e6, ...: fx_rate=1.15, ...: points=56.5, ...: ) ...: In [2]: fxs.cashflows() Out[2]: Type Ccy Payment Notional DF Cashflow NPV FX Rate Base Ccy NPV Ccy Collateral FX Fixing FX Fix Date Reference Ccy leg1 0 Cashflow EUR 2022-01-19 10000000.0 None -8.695652e+06 None 1.0 EUR None None 1.15000 2022-01-17 USD 1 Cashflow EUR 2022-04-19 -10250000.0 None 8.869467e+06 None 1.0 EUR None None 1.15565 2022-04-13 USD leg2 0 Cashflow USD 2022-01-19 -10000000.0 None 1.000000e+07 None 1.0 USD None None NaN NaT NaN 1 Cashflow USD 2022-04-19 10250000.0 None -1.025000e+07 None 1.0 USD None None NaN NaT NaN
Pricing
An FX Swap requires a disc curve and a leg2 disc curve to discount the cashflows of the respective currencies (typically with the same collateral definition). The following input formats are allowed:
curves = [disc_curve, leg2_disc_curve] # two curves are applied in the given order curves = [None, disc_curve, None, leg2_disc_curve] # four curves applied to each leg curves = {"disc_curve": disc_curve, "leg2_disc_curve": leg2_disc_curve} # dict form is explicit
- Parameters:
. –
Note
The following define generalised scheduling parameters.
effective (datetime, required) – The settlement date of the first currency pair.
termination (datetime, str, required) – The settlement of the second currency pair. If given as string requires additional scheduling arguments to derive from
effective.roll (RollDay, int in [1, 31], str in {“eom”, “imm”, “som”}, optional) – If
terminationis str tenor, the roll day for its determination.eom (bool, optional) – If
terminationis str tenor, the end-of-month preference ifrollis not specified.modifier (Adjuster, str in {“NONE”, “F”, “MF”, “P”, “MP”}, optional (set by ‘defaults’)) – If
terminationis str tenor, the adjustment to apply to its determination.calendar (calendar, str, optional (set as ‘all’)) –
If
terminationis str tenor, the calendar to apply to its determination.Note
The following define generalised settlement parameters.
pair (FXIndex, str, required) – The FX pair of the Instrument (6-digit code).
notional (float, Dual, Dual2, Variable, optional (set by ‘defaults’)) – To define the notional of the trade in units of LHS pair use
notional.leg2_notional (float, Dual, Dual2, Variable, optional (negatively inherited from leg1)) – To define the notional of the trade in units of RHS pair use
leg2_notional. Only one ofnotionalorleg2_notionalcan be specified.split_notional (float, Variable, optional) –
If the second cashflow has a rate adjusted notional to mitigate spot FX risk this is entered as this argument. If not given the FX Swap is assumed not to have split notional. Expressed in the same units as that given for either
notionalorleg2_notional.Note
The following are rate parameters. Both must be given simultaneously or not at all.
fx_rate (float, Dual, Dual2, Variable, optional) – The
fx_ratewith direction according topairto define the missing notional.points (float, Dual, Dual2, Variable, optional) –
The swap points valued (in 10,000ths) to add to
fx_rateto arrive at the FX rate at maturity of the swap.Note
The following are meta parameters.
curves (_BaseCurve, str, dict, _Curves, Sequence, optional) – Pricing objects passed directly to the Instrument’s methods’
curvesargument. See Pricing.spec (str, optional) – A collective group of parameters. See default argument specifications.
Notes
An FXSwap is constructed from two Legs where one is non-deliverable. A fully specified Instrument is one whose non-deliverable fx fixings are set at initialisation via
pointsand eitherfx_fixingsorleg2_fx_fixings. If these are not given then these values will be forecastFXFixing, which will likely impact risk sensitivity calculations. This is best observed in the following example where two similar FXSwaps are created, but their risks (as demonstrated by the Dual gradients) are different.In [3]: eurusd = Curve({dt(2000, 1, 1): 1.0, dt(2001, 1, 1): 0.95}) In [4]: usdusd = Curve({dt(2000, 1, 1): 1.0, dt(2001, 1, 1): 0.94}) In [5]: fxf = FXForwards( ...: fx_rates=FXRates({"eurusd": 1.15}, settlement=dt(2000, 1, 3)), ...: fx_curves={"usdusd": usdusd, "eureur": eurusd, "eurusd": eurusd}, ...: ) ...: In [6]: fxs1 = FXSwap( ...: dt(2000, 1, 10), ...: dt(2000, 4, 10), ...: pair="eurusd", ...: notional=1e6, ...: fx_rate=1.1502327721341274, # <- mid-market value inserted as float ...: points=30.303287307187343 # <- mid-market value inserted as float ...: ) ...: In [7]: fxs2 = FXSwap( ...: dt(2000, 1, 10), ...: dt(2000, 4, 10), ...: pair="eurusd", ...: notional=1e6, ...: ) ...: In [8]: fxs1.npv(curves=[eurusd, usdusd], fx=fxf) Out[8]: <Dual: 0.000000, (fx_eurusd), [-11005.5]> In [9]: fxs2.npv(curves=[eurusd, usdusd], fx=fxf) Out[9]: <Dual: 0.000000, (fx_eurusd), [-0.0]>
Attributes Summary
The
_KWArgscontainer for the Instrument.The
CustomLegof the Instrument.The
CustomLegof the Instrument.A list of the Legs of the Instrument.
A scaling quantity associated with the
Solverrisk calculations.The default
_SettlementParamsof the Instrument.Methods Summary
analytic_delta(*[, curves, solver, fx, vol, ...])Calculate the analytic rate delta of a Leg of the Instrument.
cashflows(*[, curves, solver, fx, vol, ...])Return aggregated cashflow data for the Instrument.
cashflows_table(*[, curves, solver, fx, ...])Aggregate the values derived from a
cashflows(), grouped by date, settlement currency and collateral.delta(*[, curves, solver, fx, vol, base, ...])Calculate delta risk of an Instrument against the calibrating instruments in a
Solver.exo_delta(*[, curves, solver, fx, vol, ...])Calculate delta risk of an Instrument against some exogenous user created Variables, via a
Solver.gamma(*[, curves, solver, fx, vol, base, ...])Calculate cross-gamma risk of an Instrument against the calibrating instruments of a
Solver.local_analytic_rate_fixings(*[, curves, ...])Calculate the sensitivity to rate fixings of the Instrument, expressed in local settlement currency per basis point.
local_fixings(identifiers[, scalars, ...])Calculate the sensitivity to fixings of the Instrument, expressed in local settlement currency.
npv(*[, curves, solver, fx, vol, base, ...])Calculate the NPV of the Instrument converted to any other base accounting currency.
rate(*[, curves, solver, fx, vol, base, ...])Calculate some pricing rate metric for the Instrument.
reset_fixings([state])Resets any fixings values of the Instrument derived using the given data state.
spread(*[, curves, solver, fx, vol, base, ...])Calculate some pricing spread metric for the Instrument.
Attributes Documentation
- legs#
A list of the Legs of the Instrument.
- settlement_params#
The default
_SettlementParamsof the Instrument.This is used to define a
basecurrency when one is not specified.
Methods Documentation
- analytic_delta(*, curves=NoInput.blank, solver=NoInput.blank, fx=NoInput.blank, vol=NoInput.blank, base=NoInput.blank, local=False, settlement=NoInput.blank, forward=NoInput.blank, leg=1)#
Calculate the analytic rate delta of a Leg of the Instrument.
Examples
In [10]: curve = Curve({dt(2000, 1, 1): 1.0, dt(2010, 1, 1): 0.75}) In [11]: irs = IRS(dt(2000, 1, 1), "3Y", spec="usd_irs", fixed_rate=1.0, curves=[curve]) In [12]: irs.analytic_delta() Out[12]: 287.14750127899316 In [13]: irs.analytic_delta(local=True) Out[13]: {'usd': 287.14750127899316}
- Parameters:
curves (_Curves, optional) – Pricing objects. See Pricing on each Instrument for details of allowed inputs.
solver (Solver, optional) – A
Solverobject containing Curve, Smile, Surface, or Cube mappings for pricing.fx (FXForwards, optional) – The
FXForwardsobject used for forecasting FX rates, if necessary.vol (_Vol, optional) – Pricing objects. See Pricing on each Instrument for details of allowed inputs.
base (str, optional (set to settlement currency)) – The currency to convert the local settlement NPV to.
local (bool, optional (set as False)) – An override flag to return a dict of NPV values indexed by string currency.
settlement (datetime, optional) – The assumed settlement date of the PV determination. Used only to evaluate ex-dividend status.
forward (datetime, optional) – The future date to project the PV to using the
disc_curve.leg (int, optional (set as 1)) – The Leg over which to calculate the analytic rate delta.
- Return type:
float, Dual, Dual2, Variable or dict of such indexed by string currency.
- cashflows(*, curves=NoInput.blank, solver=NoInput.blank, fx=NoInput.blank, vol=NoInput.blank, base=NoInput.blank, settlement=NoInput.blank, forward=NoInput.blank)#
Return aggregated cashflow data for the Instrument.
Warning
This method is a convenience method to provide a visual representation of all associated calculation data. Calling this method to extract certain values should be avoided. It is more efficient to source relevant parameters or calculations from object attributes or other methods directly.
Examples
In [1]: irs = IRS(dt(2000, 1, 1), "3Y", spec="usd_irs", fixed_rate=1.0) In [2]: irs.cashflows() Out[2]: Type Ccy Payment Notional Period Convention DCF Acc Start Acc End DF Cashflow NPV FX Rate Base Ccy NPV Ccy Collateral Rate Spread leg1 0 FixedPeriod USD 2001-01-04 1000000.0 Regular Act360 1.013889 2000-01-03 2001-01-02 None -10138.888889 None 1.0 USD None None 1.0 NaN 1 FixedPeriod USD 2002-01-04 1000000.0 Regular Act360 1.013889 2001-01-02 2002-01-02 None -10138.888889 None 1.0 USD None None 1.0 NaN 2 FixedPeriod USD 2003-01-06 1000000.0 Regular Act360 1.013889 2002-01-02 2003-01-02 None -10138.888889 None 1.0 USD None None 1.0 NaN leg2 0 FloatPeriod USD 2001-01-04 -1000000.0 Regular Act360 1.013889 2000-01-03 2001-01-02 None NaN None 1.0 USD None None NaN 0.0 1 FloatPeriod USD 2002-01-04 -1000000.0 Regular Act360 1.013889 2001-01-02 2002-01-02 None NaN None 1.0 USD None None NaN 0.0 2 FloatPeriod USD 2003-01-06 -1000000.0 Regular Act360 1.013889 2002-01-02 2003-01-02 None NaN None 1.0 USD None None NaN 0.0
Providing relevant pricing objects will ensure all data that can be calculated is returned.
In [3]: curve = Curve({dt(2000, 1, 1): 1.0, dt(2010, 1, 1): 0.75}) In [4]: irs.cashflows(curves=[curve]) Out[4]: Type Ccy Payment Notional Period Convention DCF Acc Start Acc End DF Cashflow NPV FX Rate Base Ccy NPV Ccy Collateral Rate Spread leg1 0 FixedPeriod USD 2001-01-04 1000000.0 Regular Act360 1.013889 2000-01-03 2001-01-02 0.971359 -10138.888889 -9848.496702 1.0 USD -9848.496702 None 1.000000 NaN 1 FixedPeriod USD 2002-01-04 1000000.0 Regular Act360 1.013889 2001-01-02 2002-01-02 0.943835 -10138.888889 -9569.435745 1.0 USD -9569.435745 None 1.000000 NaN 2 FixedPeriod USD 2003-01-06 1000000.0 Regular Act360 1.013889 2002-01-02 2003-01-02 0.916946 -10138.888889 -9296.817681 1.0 USD -9296.817681 None 1.000000 NaN leg2 0 FloatPeriod USD 2001-01-04 -1000000.0 Regular Act360 1.013889 2000-01-03 2001-01-02 0.971359 29161.694029 28326.461668 1.0 USD 28326.461668 None 2.876222 0.0 1 FloatPeriod USD 2002-01-04 -1000000.0 Regular Act360 1.013889 2001-01-02 2002-01-02 0.943835 29161.694029 27523.820438 1.0 USD 27523.820438 None 2.876222 0.0 2 FloatPeriod USD 2003-01-06 -1000000.0 Regular Act360 1.013889 2002-01-02 2003-01-02 0.916946 29161.694029 26739.710399 1.0 USD 26739.710399 None 2.876222 0.0
- Parameters:
curves (_Curves, optional) – Pricing objects. See Pricing on each Instrument for details of allowed inputs.
solver (Solver, optional) – A
Solverobject containing Curve, Smile, Surface, or Cube mappings for pricing.fx (FXForwards, optional) – The
FXForwardsobject used for forecasting FX rates, if necessary.vol (_Vol, optional) – Pricing objects. See Pricing on each Instrument for details of allowed inputs.
base (str, optional (set to settlement currency)) – The currency to convert the local settlement NPV to.
settlement (datetime, optional) – The assumed settlement date of the PV determination. Used only to evaluate ex-dividend status.
forward (datetime, optional) – The future date to project the PV to using the
disc_curve.
- Return type:
DataFrame
- cashflows_table(*, curves=NoInput.blank, solver=NoInput.blank, fx=NoInput.blank, vol=NoInput.blank, base=NoInput.blank, settlement=NoInput.blank, forward=NoInput.blank)#
Aggregate the values derived from a
cashflows(), grouped by date, settlement currency and collateral.Examples
In [5]: irs = IRS(dt(2000, 1, 1), "3Y", spec="usd_irs", fixed_rate=1.0) In [6]: curve = Curve({dt(2000, 1, 1): 1.0, dt(2010, 1, 1): 0.75}) In [7]: irs.cashflows_table(curves=[curve]) Out[7]: local_ccy USD collateral_ccy NaN payment 2001-01-04 19022.80514 2002-01-04 19022.80514 2003-01-06 19022.80514
- Parameters:
curves (_Curves, optional) – Pricing objects. See Pricing on each Instrument for details of allowed inputs.
solver (Solver, optional) – A
Solverobject containing Curve, Smile, Surface, or Cube mappings for pricing.fx (FXForwards, optional) – The
FXForwardsobject used for forecasting FX rates, if necessary.vol (_Vol, optional) – Pricing objects. See Pricing on each Instrument for details of allowed inputs.
base (str, optional (set to settlement currency)) – The currency to convert the local settlement NPV to.
local (bool, optional (set as False)) – An override flag to return a dict of NPV values indexed by string currency.
settlement (datetime, optional) – The assumed settlement date of the PV determination. Used only to evaluate ex-dividend status.
forward (datetime, optional) – The future date to project the PV to using the
disc_curve.
- Return type:
DataFrame
- delta(*, curves=NoInput.blank, solver=NoInput.blank, fx=NoInput.blank, vol=NoInput.blank, base=NoInput.blank, settlement=NoInput.blank, forward=NoInput.blank)#
Calculate delta risk of an Instrument against the calibrating instruments in a
Solver.Examples
In [8]: curve = Curve({dt(2000, 1, 1): 1.0, dt(2002, 1, 1): 0.85, dt(2010, 1, 1): 0.75}) In [9]: solver = Solver( ...: curves=[curve], ...: instruments=[ ...: IRS(dt(2000, 1, 1), "2Y", spec="usd_irs", curves=[curve]), ...: IRS(dt(2000, 1, 1), "5Y", spec="usd_irs", curves=[curve]), ...: ], ...: s=[2.0, 2.25], ...: instrument_labels=["2Y", "5Y"], ...: id="US_RATES" ...: ) ...: SUCCESS: `func_tol` reached after 6 iterations (levenberg_marquardt), `f_val`: 8.499591036903249e-16, `time`: 0.0035s In [10]: irs = IRS(dt(2000, 1, 1), "3Y", spec="usd_irs", curves=[curve]) In [11]: irs.delta(solver=solver) Out[11]: local_ccy usd display_ccy usd type solver label instruments US_RATES 2Y 129.580448 5Y 162.173287
- Parameters:
curves (_Curves, optional) – Pricing objects. See Pricing on each Instrument for details of allowed inputs.
solver (Solver, required) – A
Solverobject containing Curve, Smile, Surface, or Cube mappings for pricing.fx (FXForwards, optional) – The
FXForwardsobject used for forecasting FX rates, if necessary.vol (_Vol, optional) – Pricing objects. See Pricing on each Instrument for details of allowed inputs.
base (str, optional (set to settlement currency)) – The currency to convert the local settlement NPV to.
settlement (datetime, optional) – The assumed settlement date of the PV determination. Used only to evaluate ex-dividend status.
forward (datetime, optional) – The future date to project the PV to using the
disc_curve.
- Return type:
DataFrame
Notes
Delta measures the sensitivity of the PV to a change in any of the calibrating instruments of the given
Solver. Values are returned according to therate_scalarquantity at an Instrument level and according to themetricused to derive therate()method of each Instrument.
- exo_delta(*, curves=NoInput.blank, solver=NoInput.blank, fx=NoInput.blank, vol=NoInput.blank, base=NoInput.blank, settlement=NoInput.blank, forward=NoInput.blank, vars, vars_scalar=NoInput.blank, vars_labels=NoInput.blank)#
Calculate delta risk of an Instrument against some exogenous user created Variables, via a
Solver.See What are exogenous variables? in the cookbook.
Examples
This example calculates the risk of the fixed rate increasing by 1bp and the notional increasing by 1mm. Mathematically this should be equivalent to the npv and the analytic delta (although the calculation is based on AD and is completely independent of the solver).
In [12]: curve = Curve({dt(2000, 1, 1): 1.0, dt(2002, 1, 1): 0.85, dt(2010, 1, 1): 0.75}) In [13]: solver = Solver( ....: curves=[curve], ....: instruments=[ ....: IRS(dt(2000, 1, 1), "2Y", spec="usd_irs", curves=[curve]), ....: IRS(dt(2000, 1, 1), "5Y", spec="usd_irs", curves=[curve]), ....: ], ....: s=[2.0, 2.25], ....: instrument_labels=["2Y", "5Y"], ....: id="US_RATES" ....: ) ....: SUCCESS: `func_tol` reached after 6 iterations (levenberg_marquardt), `f_val`: 8.499591036903249e-16, `time`: 0.0035s In [14]: irs = IRS(dt(2000, 1, 1), "3Y", spec="usd_irs", fixed_rate=Variable(3.0, ["R"]), notional=Variable(1e6, ["N"]), curves=[curve]) In [15]: irs.exo_delta(solver=solver, vars=["R", "N"], vars_scalar=[1e-2, 1e6]) Out[15]: local_ccy usd display_ccy usd type solver label exogenous US_RATES R -291.752073 N -25123.690181 In [16]: irs.analytic_delta() Out[16]: <Dual: 291.752073, (N, 460870, 460871, ...), [0.0, 49.2, 239.9, ...]> In [17]: irs.npv() Out[17]: <Dual: -25123.690181, (N, R, 460870, ...), [-0.0, -29175.2, 982218.9, ...]>
- Parameters:
curves (_Curves, optional) – Pricing objects. See Pricing on each Instrument for details of allowed inputs.
solver (Solver, required) – A
Solverobject containing Curve, Smile, Surface, or Cube mappings for pricing.fx (FXForwards, optional) – The
FXForwardsobject used for forecasting FX rates, if necessary.vol (_Vol, optional) – Pricing objects. See Pricing on each Instrument for details of allowed inputs.
base (str, optional (set to settlement currency)) – The currency to convert the local settlement NPV to.
settlement (datetime, optional) – The assumed settlement date of the PV determination. Used only to evaluate ex-dividend status.
forward (datetime, optional) – The future date to project the PV to using the
disc_curve.vars (list[str], required) – The variable tags which to determine sensitivities for.
vars_scalar (list[float], optional) – Scaling factors for each variable, for example converting rates to basis point etc. Defaults to ones.
vars_labels (list[str], optional) – Alternative names to relabel variables in DataFrames.
- Return type:
DataFrame
- gamma(*, curves=NoInput.blank, solver=NoInput.blank, fx=NoInput.blank, vol=NoInput.blank, base=NoInput.blank, settlement=NoInput.blank, forward=NoInput.blank)#
Calculate cross-gamma risk of an Instrument against the calibrating instruments of a
Solver.Examples
In [18]: curve = Curve({dt(2000, 1, 1): 1.0, dt(2002, 1, 1): 0.85, dt(2010, 1, 1): 0.75}) In [19]: solver = Solver( ....: curves=[curve], ....: instruments=[ ....: IRS(dt(2000, 1, 1), "2Y", spec="usd_irs", curves=[curve]), ....: IRS(dt(2000, 1, 1), "5Y", spec="usd_irs", curves=[curve]), ....: ], ....: s=[2.0, 2.25], ....: instrument_labels=["2Y", "5Y"], ....: id="US_RATES" ....: ) ....: SUCCESS: `func_tol` reached after 6 iterations (levenberg_marquardt), `f_val`: 8.499591036903249e-16, `time`: 0.0029s In [20]: irs = IRS(dt(2000, 1, 1), "3Y", spec="usd_irs", curves=[curve]) In [21]: irs.gamma(solver=solver) Out[21]: type instruments solver US_RATES label 2Y 5Y local_ccy display_ccy type solver label usd usd instruments US_RATES 2Y -0.029442 -0.038104 5Y -0.038104 -0.010190
- Parameters:
curves (_Curves, optional) – Pricing objects. See Pricing on each Instrument for details of allowed inputs.
solver (Solver, required) – A
Solverobject containing Curve, Smile, Surface, or Cube mappings for pricing.fx (FXForwards, optional) – The
FXForwardsobject used for forecasting FX rates, if necessary.vol (_Vol, optional) – Pricing objects. See Pricing on each Instrument for details of allowed inputs.
base (str, optional (set to settlement currency)) – The currency to convert the local settlement NPV to.
settlement (datetime, optional) – The assumed settlement date of the PV determination. Used only to evaluate ex-dividend status.
forward (datetime, optional) – The future date to project the PV to using the
disc_curve.
- Return type:
DataFrame
Notes
Gamma measures the second order cross-sensitivity of the PV to a change in any of the calibrating instruments of the given
Solver. Values are returned according to therate_scalarquantity at an Instrument level and according to themetricused to derive therate()method of each Instrument.
- local_analytic_rate_fixings(*, curves=NoInput.blank, solver=NoInput.blank, fx=NoInput.blank, vol=NoInput.blank, settlement=NoInput.blank, forward=NoInput.blank)#
Calculate the sensitivity to rate fixings of the Instrument, expressed in local settlement currency per basis point.
Examples
In [22]: curve1 = Curve({dt(2000, 1, 1): 1.0, dt(2010, 1, 1): 0.75}, id="Eur1mCurve") In [23]: curve3 = Curve({dt(2000, 1, 1): 1.0, dt(2010, 1, 1): 0.70}, id="Eur3mCurve") In [24]: irs = IRS(dt(2000, 1, 1), "20m", spec="eur_irs3", curves=[{"1m": curve1, "3m": curve3}, curve1]) In [25]: irs.local_analytic_rate_fixings() Out[25]: identifier Eur1mCurve Eur3mCurve local_ccy eur eur display_ccy eur eur frequency 1M 3M obs_dates 1999-12-30 8.81934 7.215824 2000-02-28 NaN 25.251470 2000-05-30 NaN 25.069179 2000-08-30 NaN 24.619619 2000-11-29 NaN 24.177105 2001-02-27 NaN 24.535960 2001-05-30 NaN 24.884455
- Parameters:
curves (_Curves, optional) – Pricing objects. See Pricing on each Instrument for details of allowed inputs.
solver (Solver, optional) – A
Solverobject containing Curve, Smile, Surface, or Cube mappings for pricing.fx (FXForwards, optional) – The
FXForwardsobject used for forecasting FX rates, if necessary.vol (_Vol, optional) – Pricing objects. See Pricing on each Instrument for details of allowed inputs.
settlement (datetime, optional) – The assumed settlement date of the PV determination. Used only to evaluate ex-dividend status.
forward (datetime, optional) – The future date to project the PV to using the
disc_curve.
- Return type:
DataFrame
Notes
This analytic method will index the sensitivities with series identifier according to the Curve id which has forecast the fixing.
- local_fixings(identifiers, scalars=NoInput.blank, curves=NoInput.blank, solver=NoInput.blank, fx=NoInput.blank, vol=NoInput.blank, settlement=NoInput.blank, forward=NoInput.blank)#
Calculate the sensitivity to fixings of the Instrument, expressed in local settlement currency.
- Parameters:
identifiers (Sequence of tuple[str, Series], required) – These are the series string identifiers and the data values that will be used in each Series to determine the sensitivity against.
scalars (Sequence of floats, optional (each set as 1.0)) – A sequence of scalars to multiply the sensitivities by for each on of the
identifiers.curves (_Curves, optional) – Pricing objects. See Pricing on each Instrument for details of allowed inputs.
solver (Solver, optional) – A
Solverobject containing Curve, Smile, Surface, or Cube mappings for pricing.fx (FXForwards, optional) – The
FXForwardsobject used for forecasting FX rates, if necessary.vol (_Vol, optional) – Pricing objects. See Pricing on each Instrument for details of allowed inputs.
settlement (datetime, optional) – The assumed settlement date of the PV determination. Used only to evaluate ex-dividend status.
forward (datetime, optional) – The future date to project the PV to using the
disc_curve.
- Return type:
DataFrame
- npv(*, curves=NoInput.blank, solver=NoInput.blank, fx=NoInput.blank, vol=NoInput.blank, base=NoInput.blank, local=False, settlement=NoInput.blank, forward=NoInput.blank)#
Calculate the NPV of the Instrument converted to any other base accounting currency.
Examples
In [1]: curve = Curve({dt(2000, 1, 1): 1.0, dt(2010, 1, 1): 0.75}) In [2]: irs = IRS(dt(2000, 1, 1), "3Y", spec="usd_irs", fixed_rate=1.0, curves=[curve]) In [3]: irs.npv() Out[3]: 53875.24237805192 In [4]: irs.npv(local=True) Out[4]: {'usd': 53875.24237805192}
- Parameters:
curves (_Curves, optional) – Pricing objects. See Pricing on each Instrument for details of allowed inputs.
solver (Solver, optional) – A
Solverobject containing Curve, Smile, Surface, or Cube mappings for pricing.fx (FXForwards, optional) – The
FXForwardsobject used for forecasting FX rates, if necessary.vol (_Vol, optional) – Pricing objects. See Pricing on each Instrument for details of allowed inputs.
base (str, optional (set to settlement currency)) – The currency to convert the local settlement NPV to.
local (bool, optional (set as False)) – An override flag to return a dict of NPV values indexed by string currency.
settlement (datetime, optional) – The assumed settlement date of the PV determination. Used only to evaluate ex-dividend status.
forward (datetime, optional) – The future date to project the PV to using the
disc_curve.
- Return type:
float, Dual, Dual2, Variable or dict of such indexed by string currency.
Notes
If
baseis not given then this function will return the value obtained from determining the PV in local settlement currency.If
baseis provided this then anFXForwardsobject may be required to perform conversions. AnFXRatesobject is also allowed for this conversion although best practice does not recommend it due to possible settlement date conflicts.
- rate(*, curves=NoInput.blank, solver=NoInput.blank, fx=NoInput.blank, vol=NoInput.blank, base=NoInput.blank, settlement=NoInput.blank, forward=NoInput.blank, metric=NoInput.blank)#
Calculate some pricing rate metric for the Instrument.
Examples
The default metric for an
IRSis its fixed ‘rate’.In [1]: curve = Curve({dt(2000, 1, 1): 1.0, dt(2010, 1, 1): 0.75}) In [2]: irs = IRS(dt(2000, 1, 1), "3Y", spec="usd_irs", curves=[curve], fixed_rate=2.0) In [3]: irs.rate() # <- `fixed_rate` on fixed leg to equate value with float leg Out[3]: 2.87622187684324
- Parameters:
curves (_Curves, optional) – Pricing objects. See Pricing on each Instrument for details of allowed inputs.
solver (Solver, optional) – A
Solverobject containing Curve, Smile, Surface, or Cube mappings for pricing.fx (FXForwards, optional) – The
FXForwardsobject used for forecasting FX rates, if necessary.vol (_Vol, optional) – Pricing objects. See Pricing on each Instrument for details of allowed inputs.
base (str, optional (set to settlement currency)) – The currency to convert the local settlement NPV to.
local (bool, optional (set as False)) – An override flag to return a dict of NPV values indexed by string currency.
settlement (datetime, optional) – The assumed settlement date of the PV determination. Used only to evaluate ex-dividend status.
forward (datetime, optional) – The future date to project the PV to using the
disc_curve.metric (str, optional) – The specific calculation to perform and the value to return. See Pricing on each Instrument for details of allowed inputs.
- Return type:
- reset_fixings(state=NoInput.blank)#
Resets any fixings values of the Instrument derived using the given data state.
- Parameters:
state (int, optional) – The state id of the data series that set the fixing. Only fixings determined by this data will be reset. If not given resets all fixings.
- Return type:
None
- spread(*, curves=NoInput.blank, solver=NoInput.blank, fx=NoInput.blank, vol=NoInput.blank, base=NoInput.blank, settlement=NoInput.blank, forward=NoInput.blank)#
Calculate some pricing spread metric for the Instrument.
This calculation may be an alias for
rate()with a specific metric and is designated at an Instrument level.Examples
The ‘spread’ on an
IRSis the float leg spread to equate value with the fixed leg.In [4]: curve = Curve({dt(2000, 1, 1): 1.0, dt(2010, 1, 1): 0.75}) In [5]: irs = IRS(dt(2000, 1, 1), "3Y", spec="usd_irs", curves=[curve], fixed_rate=2.0) In [6]: irs.spread() # <- `spread` on float leg to equate value with fixed leg Out[6]: -87.62218768432399
- Parameters:
curves (_Curves, optional) – Pricing objects. See Pricing on each Instrument for details of allowed inputs.
solver (Solver, optional) – A
Solverobject containing Curve, Smile, Surface, or Cube mappings for pricing.fx (FXForwards, optional) – The
FXForwardsobject used for forecasting FX rates, if necessary.vol (_Vol, optional) – Pricing objects. See Pricing on each Instrument for details of allowed inputs.
base (str, optional (set to settlement currency)) – The currency to convert the local settlement NPV to.
local (bool, optional (set as False)) – An override flag to return a dict of NPV values indexed by string currency.
settlement (datetime, optional) – The assumed settlement date of the PV determination. Used only to evaluate ex-dividend status.
forward (datetime, optional) – The future date to project the PV to using the
disc_curve.
- Return type: