FXBrokerFly#
- class rateslib.instruments.FXBrokerFly(*args, strike=(NoInput.blank, NoInput.blank, NoInput.blank), premium=(NoInput.blank, NoInput.blank, NoInput.blank, NoInput.blank), notional=(NoInput.blank, NoInput.blank), metric='single_vol', **kwargs)#
Bases:
FXOptionStrat,FXOptionCreate an FX BrokerFly option strategy.
For additional arguments see
FXOption.- Parameters:
args (tuple) – Positional arguments to
FXOption.strike (3-element sequence) – The first element is applied to the lower strike put, the second element to the straddle strike and the third element to the higher strike call, e.g. [“-25d”, “atm_delta”, “25d”].
premium (4-element sequence, optional) – The premiums associated with each option of the strategy; lower strike put, straddle put, straddle call, higher strike call.
notional (2-element sequence, optional) – The first element is the notional associated with the Strangle. If the second element is None, it will be implied in a vega neutral sense.
metric (str, optional) – The default metric to apply in the method
rate()kwargs (tuple) – Keyword arguments to
FXOption.
Notes
When supplying
strikeas a string delta the strike will be determined at price time from the provided volatility.Buying a BrokerFly equates to buying an
FXStrangleand selling aFXStraddle, where the convention is to set the notional on the Straddle such that the entire strategy is vega neutral at inception.Warning
The default
metricfor an FXBrokerFly is ‘single_vol’, which requires an iterative algorithm to solve. For defined strikes it is usually very accurate but for strikes defined by delta it will return a solution within 0.1 pips. This means it is both slower than other instruments and inexact.Attributes Summary
Methods Summary
analytic_greeks([curves, solver, fx, base, ...])cashflows([curves, solver, fx, base, vol])Return the properties of all periods used in calculating cashflows.
cashflows_table([curves, solver, fx, base])Aggregate the values derived from a
cashflows()method on an Instrument.delta([curves, solver, fx, base, local])Calculate delta risk of an Instrument against the calibrating instruments in a
Solver.exo_delta(vars[, curves, solver, fx, base, ...])Calculate delta risk of an Instrument against some exogenous user created Variables.
gamma([curves, solver, fx, base, local])Calculate cross-gamma risk of an Instrument against the calibrating instruments of a
Solver.npv([curves, solver, fx, base, local, vol])Return the NPV of the Option.
plot_payoff([range, curves, solver, fx, ...])rate([curves, solver, fx, base, vol, metric])Return the mid-market rate of an option strategy.
Attributes Documentation
- rate_weight = [1.0, 1.0]#
- rate_weight_vol = [1.0, -1.0]#
- style = 'european'#
Methods Documentation
- analytic_greeks(curves=NoInput.blank, solver=NoInput.blank, fx=NoInput.blank, base=NoInput.blank, local=False, vol=NoInput.blank)#
- cashflows(curves=NoInput.blank, solver=NoInput.blank, fx=NoInput.blank, base=NoInput.blank, vol=NoInput.blank)#
Return the properties of all periods used in calculating cashflows.
- Parameters:
curves (list of Curve) – Curves for discounting cashflows. List follows the structure used by IRDs and should be given as: [None, Curve for domestic ccy, None, Curve for foreign ccy]
solver (Solver, optional) – The numerical
Solverthat constructsCurvesfrom calibrating instruments.fx (FXForwards) – The object to project the relevant forward and spot FX rates.
base (str, optional) – Not used by rate.
vol (float, Dual, Dual2 or FXDeltaVolSmile) – The volatility used in calculation.
- Return type:
DataFrame
- cashflows_table(curves=NoInput.blank, solver=NoInput.blank, fx=NoInput.blank, base=NoInput.blank, **kwargs)#
Aggregate the values derived from a
cashflows()method on an Instrument.- Parameters:
curves (CurveType, str or list of such, optional) – Argument input to the underlying
cashflowsmethod of the Instrument.solver (Solver, optional) – Argument input to the underlying
cashflowsmethod of the Instrument.fx (float, FXRates, FXForwards, optional) – Argument input to the underlying
cashflowsmethod of the Instrument.base (str, optional) – Argument input to the underlying
cashflowsmethod of the Instrument.kwargs (dict) – Additional arguments input the underlying
cashflowsmethod of the Instrument.
- Return type:
DataFrame
- delta(curves=NoInput.blank, solver=NoInput.blank, fx=NoInput.blank, base=NoInput.blank, local=False, **kwargs)#
Calculate delta risk of an Instrument against the calibrating instruments in a
Solver.- Parameters:
curves (Curve, str or list of such, optional) –
A single
Curveor id or a list of such. A list defines the following curves in the order:solver (Solver, optional) – The
Solverthat calibrates Curves from given Instruments.fx (float, FXRates, FXForwards, optional) – The immediate settlement FX rate that will be used to convert values into another currency. A given float is used directly. If giving a
FXRatesorFXForwardsobject, converts from local currency intobase.base (str, optional) – The base currency to convert cashflows into (3-digit code), set by default. Only used if
fx_rateis anFXRatesorFXForwardsobject.local (bool, optional) – If True will ignore
base- this is equivalent to settingbaseto None. Included only for argument signature consistent with npv.
- Return type:
DataFrame
- exo_delta(vars, curves=NoInput.blank, solver=NoInput.blank, fx=NoInput.blank, base=NoInput.blank, local=False, vars_scalar=NoInput.blank, vars_labels=NoInput.blank, **kwargs)#
Calculate delta risk of an Instrument against some exogenous user created Variables.
See What are exogenous variables? in the cookbook.
- Parameters:
vars (list[str]) – The variable tags which to determine sensitivities for.
curves (Curve, str or list of such, optional) –
A single
Curveor id or a list of such. A list defines the following curves in the order:solver (Solver, optional) – The
Solverthat calibrates Curves from given Instruments.fx (float, FXRates, FXForwards, optional) – The immediate settlement FX rate that will be used to convert values into another currency. A given float is used directly. If giving a
FXRatesorFXForwardsobject, converts from local currency intobase.base (str, optional) – The base currency to convert cashflows into (3-digit code), set by default. Only used if
fx_rateis anFXRatesorFXForwardsobject.local (bool, optional) – If True will ignore
base- this is equivalent to settingbaseto None. Included only for argument signature consistent with npv.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, base=NoInput.blank, local=False, **kwargs)#
Calculate cross-gamma risk of an Instrument against the calibrating instruments of a
Solver.- Parameters:
curves (Curve, str or list of such, optional) –
A single
Curveor id or a list of such. A list defines the following curves in the order:solver (Solver, optional) – The
Solverthat calibrates Curves from given Instruments.fx (float, FXRates, FXForwards, optional) – The immediate settlement FX rate that will be used to convert values into another currency. A given float is used directly. If giving a
FXRatesorFXForwardsobject, converts from local currency intobase.base (str, optional) – The base currency to convert cashflows into (3-digit code), set by default. Only used if
fx_rateis anFXRatesorFXForwardsobject.local (bool, optional) – If True will ignore
base. This is equivalent to settingbaseto None. Included only for argument signature consistent with npv.
- Return type:
DataFrame
- npv(curves=NoInput.blank, solver=NoInput.blank, fx=NoInput.blank, base=NoInput.blank, local=False, vol=NoInput.blank)#
Return the NPV of the Option.
- Parameters:
curves (list of Curve) – Curves for discounting cashflows. List follows the structure used by IRDs and should be given as: [None, Curve for domestic ccy, None, Curve for foreign ccy]
solver (Solver, optional) – The numerical
Solverthat constructs Curves, Smiles or Surfaces from calibrating instruments.fx (FXForwards) – The object to project the relevant forward and spot FX rates.
base (str, optional) – The base currency to convert cashflows into (3-digit code). If not given defaults to
fx.base.local (bool, optional) – If True will return a dict identifying NPV by local currencies on each period.
- Return type:
- plot_payoff(range=NoInput.blank, curves=NoInput.blank, solver=NoInput.blank, fx=NoInput.blank, base=NoInput.blank, local=False, vol=NoInput.blank)#
- rate(curves=NoInput.blank, solver=NoInput.blank, fx=NoInput.blank, base=NoInput.blank, vol=NoInput.blank, metric=NoInput.blank)#
Return the mid-market rate of an option strategy.
Notes
The different types of
metricreturn different quotation conventions.‘single_vol’: the default type for a
FXStrangle‘vol’: sums the mid-market volatilities of each option multiplied by their respective
rate_weight_volparameter. For example this is the default pricing convention for aFXRiskReversalwhere the price is the vol of the call minus the vol of the put and therate_weight_volparameters are [-1.0, 1.0].‘pips_or_%’: sums the mid-market pips or percent price of each option multiplied by their respective
rate_weightparameter. For example for aFXStraddlethe total premium is the sum of two premiums and therate_weightparameters are [1.0, 1.0].