FXCurveMarket#

class sigtech.framework.infra.analytics.fx.fx_market.FXCurveMarket

Class calculating yield curves used for forward rate calculation. It should only be used for USD-based FX forwards and implies forwards directly from the curves:

\[{FX}_t = {FX}_0 \frac{P_{for}(0, t)}{P_{dom}(0,t)}\]

where the domestic curve is the usual OIS discounting curve, and the foreign curve is bootstrapped to match the market FX forwards and cross-currency swaps.

dependencies(over: str, under: str, time: datetime.time, tz: <module 'pytz.tzinfo' from '/github/home/.cache/pypoetry/virtualenvs/sigtech-framework-GMC81NYz-py3.9/lib/python3.9/site-packages/pytz/tzinfo.py'>, start_dt: datetime.datetime, end_dt: datetime.datetime) list[sigtech.framework.internal.infra.mu.graph.registry.factory.Dependency]

Dependencies

day_count(currency, curve_day_count=None)

Return the day count given the currency.

Parameters
  • currency – Input currency.

  • curve_day_count – Curve day count (optional).

Returns

str.

calculate_forward_rate(over, under, quote_date, maturity, mode='mid', transaction_type=None, spot_date=None, data_point=None, spot_data_point=None)

Calculate the forward rate for a given currency pair and maturity.

Parameters
  • over – Over currency.

  • under – Under currency.

  • quote_date – Quote date.

  • maturity – Maturity date.

  • mode'bid', 'ask' or 'mid' ('mid' is default).

  • transaction_type – String identifier to indicate type of transaction, e.g. 'outright', 'roll' (optional).

  • spot_date – Spot date (optional).

  • data_point – Data point (optional).

  • spot_data_point – Data point for spot, if different from forward curves data point. Used only if quote_dates are dtm.date and data_point is present (optional).

Returns

Forward rate.

discount_factor(currency, quote_date, start_date, end_date, mode='mid', data_point=None)

Calculate a discount factor.

Parameters
  • currency – Input currency.

  • quote_date – Quote date.

  • start_date – Period start date.

  • end_date – Period end date.

  • mode'bid', 'ask' or 'mid' ('mid' is default).

  • data_point – Data point (optional).

Returns

Discount factor.

discount_factor_batch(currency, quote_dates, start_dates, end_dates, mode='mid', data_point=None)

Calculate a batch of discount factors.

Parameters
  • currency – Input currency.

  • quote_dates – List of quote dates.

  • start_dates – List of period start dates.

  • end_dates – List of period end dates.

  • mode'bid', 'ask' or 'mid' ('mid' is default).

  • data_point – Data point (optional).

Returns

list.

calculate_forward_rate_batch(over, under, quote_dates, maturities, mode='mid', transaction_type=None, spot_dates=None, data_point=None, spot_data_point=None)

Calculate the forward rates for a given currency pair and list of maturity dates.

Parameters
  • over – Over currency.

  • under – Under currency.

  • quote_dates – Quote dates. If datetimes are passed, the spot_data_point will be ignored, and latest available data, (and data_point if present) will be used.

  • maturities – Maturity dates.

  • mode'bid', 'ask' or 'mid' ('mid' is default).

  • transaction_type – String identifier to indicate type of transaction, e.g. 'outright', 'roll' (optional).

  • spot_dates – Spot dates (optional).

  • data_point – Data point (optional).

  • spot_data_point – Data point for spot, if different from forward curves data point. Used only if quote_dates are dtm.date and data_point is present (optional).

Returns

list.

implied_depo(currency, quote_date, tenor, spot_date=None, data_point=None)

Compute the implied depo rate given quote date and tenor.

Parameters
  • currency – Input currency.

  • quote_date – Quote date.

  • tenor – Tenor identifier.

  • spot_date – Spot date (optional).

  • data_point – Data point (optional).

Returns

float.

implied_depo_batch(currency, quote_dates, tenor, spot_dates=None, data_point=None)

Compute the implied depo rate batch given a list of quote dates and tenor.

Parameters
  • currency – Input currency.

  • quote_dates – Quote dates.

  • tenor – Tenor identifier.

  • spot_dates – Spot dates (optional).

  • data_point – Data point (optional).

Returns

list.

get_available_data_points()

Return the list of available data points.

generate_data_for_fx_curve_override(currency, quote_date, tenors=None, forward_dates=None, delivery_days=None, forward_points=None, forwards=None, data_point=None)

Output DataFrame consisting of two columns - delivery_days and depo_rates, used in FX curve creation. This function is useful only for overriding existing (or missing) FX curves in the framework FX Curve market. The inputs are flexible in terms of either tenors, forward dates, or delivery days (exactly one is required) and forward or forward points (exactly one is required).

Parameters
  • currency – Currency of the curve.

  • quote_date – Quote date.

  • tenors – List of tenors (e.g. ['ON', '1D', '1M']) (Optional).

  • forward_dates – List of delivery dates (Optional, instead of tenors, and delivery_days).

  • delivery_days – List of offsets from SpotDate (e.g. [-2, 7, 31]). (Optional instead of tenors or delivery_dates).

  • forward_points – List of (absolute) forward points (e.g. [0.0012, 0.0014, 0.0018]). (Optional instead of forwards).

  • forwards – List of FX Forwards corresponding to the delivery dates. (Optional instead of forward_points).

  • data_point – Data point (optional).

Returns

pd.DataFrame

ROLL_OFFSET = {'12M': (1990-01-01 2 dtype: int64, {'months': 12}), '1M': (1990-01-01 2 dtype: int64, {'months': 1}), '1W': (1990-01-01 2 dtype: int64, {'weeks': 1}), '1Y': (1990-01-01 2 dtype: int64, {'years': 1}), '2M': (1990-01-01 2 dtype: int64, {'months': 2}), '3M': (1990-01-01 2 dtype: int64, {'months': 3}), '3M_IMM': (1990-01-01 5 2017-04-14 6 dtype: int64, None), '6M': (1990-01-01 2 dtype: int64, {'months': 6}), '9M': (1990-01-01 2 dtype: int64, {'months': 9}), 'ON': (1990-01-01 0 dtype: int64, {'BD': 1}), 'SN': (1990-01-01 2 dtype: int64, {'BD': 1}), 'TN': (1990-01-01 1 dtype: int64, {'BD': 1})}

Roll offset: how many business days are rolled before forward maturity.

property default_data_point

Return the default data point.

forward_ticker(over, under, tenor)

Return the FX forward ticker.

Parameters
  • over – Over currency.

  • under – Under currency.

  • tenor – Tenor identifier.

Returns

str.

fx_curve_name(currency)

Return the FX curve name given an input currency.

Parameters

currency – Input currency.

Returns

str.

static fx_forward_convention(over, under)

Return a tuple (over, under, notional multiplier) following the market notional convention for FX forward trading. It assumes the long is under.

Parameters
  • over – Over currency.

  • under – Under currency.

Returns

tuple.

fx_forward_date(over, under, spot_date, fwd_tenor=None)

Return the FX forward maturity date in line with the convention.

Parameters
  • over – Over currency.

  • under – Under currency.

  • spot_date – Spot date.

  • fwd_tenor – Tenor identifier (optional).

Returns

date.

static fx_forward_delta_cutoff(over, under)

Return the FX forward delta cutoff for a currency pair.

Parameters
  • over – Over currency.

  • under – Under currency.

Returns

str.

fx_holiday_calendar_and_fixing_delay(over, under)

Return the FX holiday calendar identifier and the fixing delay.

If none of the currency is the base currency USD, the max of the two fixing delays is used to define the spot date.

Parameters
  • over – Over currency.

  • under – Under currency.

Returns

tuple.

fx_schedule(over, under)

Return the trade schedule for a currency pair.

Parameters
  • over – Over currency.

  • under – Under currency.

Returns

Schedule object.

fx_spot_date(over, under, quote_date)

Return the FX spot date.

Parameters
  • over – Over currency.

  • under – Under currency.

  • quote_date – Quote date.

Returns

Spot date.

fx_spot_date_inverse(over, under, spot_date)

Return the date for which spot_date represents the FX spot date. If spot_date is not a valid spot date, the date for which the spot date does not exceed spot_date is returned.

Parameters
  • over – Over currency.

  • under – Under currency.

  • spot_date – Spot date.

Returns

date.

generate_forward_dates(over, under, spot_date, tenors)

Return the FX forward maturity dates given a list of tenor identifiers.

Parameters
  • over – Over currency.

  • under – Under currency.

  • spot_date – Spot date.

  • tenors – Tenor identifiers.

Returns

list.

generate_fwd_forward_dates(over, under, spot_date, tenor_lists)

Generate a list of forward tenor dates given a list of forward tenors, e.g. ('1W', '1W').

Parameters
  • over – Over currency.

  • under – Under currency.

  • spot_date – Spot date.

  • tenor_lists – Forward tenors.

Returns

list.

get_next_forward_maturity(d, strategy)

Return the next forward maturity date given a reference date and a strategy.

Parameters
  • d – Reference date.

  • strategy – Strategy object.

Returns

Date.

hedge_schedule(start_date, end_date, over, under, forward_tenor)

Return the schedule given a currency pair, period and forward tenor.

Parameters
  • start_date – Period start date.

  • end_date – Period end date.

  • over – Over currency.

  • under – Under currency.

  • forward_tenor – Forward tenor.

Returns

Schedule.

classmethod instance(universe_name=None)

Return the singleton instance of this class. If one for the given universe does not exist, create it.

is_forward_deliverable(over, under)

Check if the forward is deliverable.

Parameters
  • over – Over currency.

  • under – Under currency.

Returns

bool.

schedule_stub(over, under, group_name=None)

Return the schedule stub for a currency pair.

Parameters
  • over – Over currency.

  • under – Under currency.

  • group_name – Group name (optional).

Returns

ScheduleStub object.

static spot_ticker(over, under)

Return the FX spot ticker.

Parameters
  • over – Over currency.

  • under – Under currency.

Returns

str.