qis.FxRatesData¶
- class qis.FxRatesData(fx_spots, domestic_rates)[source]¶
Bases:
objectFX spot rates and domestic short rates, aligned on a common index.
Spots are quoted as USD per one unit of the local currency, so a cross rate is a ratio of two columns; callers supply USD identically one. Construction sorts each source calendar before time-directed filling and retains off-grid rate updates before reindexing rates onto the spot dates. A rate quote between two spot dates becomes available on the later spot date. A weekend boundary uses the last stored spot-date quote; it does not expose intervening rate updates early. Upstream backfill is not undone.
- Variables:
fx_spots (pandas.DataFrame) – USD per 1 unit of each currency, one column per currency
domestic_rates (pandas.DataFrame) – annualised short rate per currency, on the same columns
cash_day_count (ClassVar[str]) – Fixed ACT/365F analytical cash convention; not a stored panel.
- Parameters:
- __init__(fx_spots, domestic_rates)¶
Methods
__init__(fx_spots, domestic_rates)build_cross_fx_cash_nav(local_ccy, reference_ccy)Synthetic cash-account NAV for
local_ccycash held by areference_ccyinvestor, unhedged.build_local_cash_nav(local_ccy[, freq])Build a money-market cash NAV for
local_ccy.fetch_local_rates(local_ccys[, freq, annualise])Per-asset domestic short-rate panel.
get_forward_rate_for_local_ccy([local_ccy, ...])Price dated synthetic forwards with opening-rate ACT/365 Fixed accrual.
get_local_rate([freq, local_ccy, annualise])Domestic short rate for
local_ccysampled atfreq.get_local_to_reference_fx_rate([local_ccy, ...])Cross FX rate between two currencies.
get_period_cash_returns(dates, local_ccy[, ...])Accrue ACT/365 Fixed cash on supplied boundaries using QIS funding's primitive.
load(local_path[, time_period])Load FX rates universe from CSV files.
Attributes
- classmethod load(local_path, time_period=None)[source]¶
Load FX rates universe from CSV files.
- Parameters:
local_path (str)
time_period (TimePeriod)
- Return type:
- get_local_to_reference_fx_rate(local_ccy='USD', reference_ccy='CHF')[source]¶
Cross FX rate between two currencies.
Computed as
fx_spots[local_ccy] / fx_spots[reference_ccy]. Because eachfx_spotscolumn is USD per 1 unit of that currency, the ratio is units of reference currency per 1 unit of the local currency (e.g.get_local_to_reference_fx_rate('EUR', 'CHF')returns EUR/CHF — CHF per EUR).
- get_local_rate(freq='ME', local_ccy='USD', annualise=False)[source]¶
Domestic short rate for
local_ccysampled atfreq.domestic_ratesare stored as annualised decimals. Withannualise=False(default) returns earned ACT/365F cash on the existing grid, using the preceding grid date’s as-of quote. The first date accrues zero. Withannualise=Trueannual quotes are unchanged.
- get_forward_rate_for_local_ccy(local_ccy='USD', reference_ccy='CHF', freq='ME', verbose=False, is_log_returns=False, period_dates=None)[source]¶
Price dated synthetic forwards with opening-rate ACT/365 Fixed accrual.
The premium remains local cash growth / reference cash growth - 1. For reference-per-local spot, F/S is its reciprocal gross factor. Values are labelled at the opening, for the next date in period_dates. Thus the existing payoff kernel applies its single opening-quote lag.
- Parameters:
local_ccy (str) – Currency delivered by the short forward.
reference_ccy (str) – Currency received at delivery.
freq (str) – Existing reset cadence when period_dates is omitted.
verbose (bool) – Print the calculated opening premiums.
is_log_returns (bool) – Return the log cash-growth ratio instead of ratio minus one.
period_dates (DatetimeIndex | None) – Complete actual interval boundaries. No rate after an opening is read for its forward. The final boundary has no subsequent maturity, so its premium is missing. When omitted, use the regular reset calendar through the last source period and one additional known maturity; retain the final usable opening quote. Off-grid source quotes are aligned as-of.
- Returns:
Opening-labelled forward premiums in the unchanged quote direction. The default output follows the reset grid, rather than the raw quote grid.
- Raises:
ValueError – Boundaries are missing, repeated or unordered, or either cash gross growth factor is nonpositive.
- Return type:
Build a money-market cash NAV for
local_ccy.Compounds the local-currency short rate at the given frequency starting from 1.0 at the first date. Used as the building block for
build_cross_fx_cash_navand as a synthetic JPM-style cash-account series for any currency where a native cash index is not available.Returns a Series of NAV levels in the local currency.
Synthetic cash-account NAV for
local_ccycash held by areference_ccyinvestor, unhedged.Used to feed the isolated cross-FX MATF regression that produces betas for cash assets viewed in non-native reference currencies. The synthetic NAV combines:
A local-currency cash NAV (compounded at local short rate).
Spot translation to reference currency, no hedging applied.
The resulting series captures the full FX exposure of the
local_ccy/reference_ccypair plus the local-currency rf carry. Regressed against MATF factors in isolation, this delivers Fx β ≈ +1 for the foreign cash leg, plus small Carry/ Rates loadings — without contaminating the main asset-universe factor model.- Parameters:
local_ccy (str) – foreign-leg currency, e.g.
'EUR'reference_ccy (str) – reference / reporting currency, e.g.
'USD'freq (str) – construction frequency of the underlying cash NAV. Daily is the safe default: the NAV is compounded at this cadence and downsampled at the end
output_freq (str) – reporting frequency of the returned NAV
- Returns:
NAV levels in the reference currency, indexed at
output_freq. Empty whenlocal_ccy == reference_ccy, since the cross-FX construction is meaningful only for a non-native reference frame- Return type:
- get_period_cash_returns(dates, local_ccy, quote_lag=1, is_log_returns=False)[source]¶
Accrue ACT/365 Fixed cash on supplied boundaries using QIS funding’s primitive.
Quotes are sampled as-of from
domestic_rates, already projected onto the spot calendar by construction. An off-grid rate update is retained at the next spot observation; a boundary before that observation (for example a weekend month-end) still sees the previous stored quote. No raw rate calendar is restored. This is accrual on the supplied reset grid, not a sampled monthly cash index.- Parameters:
dates (DatetimeIndex) – Unique nonmissing timestamp boundaries, interpreted chronologically. Unsorted boundaries are supported; output retains the supplied order. Elapsed calendar days, not a frequency label, determine each accrual.
local_ccy (str) – Existing currency ID in the stored annual decimal rate panel.
quote_lag (int) – Nonnegative integer lag in target-grid observations, applied after as-of alignment. One uses opening quotes; zero uses closing quotes and is descriptive. Larger lags retain missing unsupported intervals.
is_log_returns (bool) – Return log1p of cash accrual instead of simple cash returns.
- Returns:
Currency-named Series on
dates. The first chronological boundary earns zero, including before rate inception; subsequent unknown cash stays missing. Empty boundaries return an empty Series. Inputs are not modified.- Raises:
ValueError – The quote lag is invalid or a cash gross factor is nonpositive.
KeyError – The currency is absent from
domestic_rates.
- Return type:
- fetch_local_rates(local_ccys, freq='ME', annualise=False)[source]¶
Per-asset domestic short-rate panel.
Builds a DataFrame of domestic short rates aligned to the assets in
local_ccysby mapping each asset to its currency’sget_local_rateseries.- Parameters:
- Returns:
DataFrame of short rates, columns are the assets in
local_ccys.- Return type: