qis.backtest_fx_account

qis.backtest_fx_account(local_prices, local_ccys, target_weights, fx_data, *, spec, local_settlement_dates, spot_is_observed, forwards=None)[source]

Run a self-financed cash ledger for signed cash equities and cash-settled FX forwards.

Parameters:
  • local_prices (DataFrame) – Local total-return levels on the valuation/cash-reset grid. Units are held between target dates; these are funded levels, never excess indices. An empty asset-column panel supports a pure forward/cash account.

  • local_ccys (Series) – Exact static asset-to-quote-currency map. Resolve subunits, ADRs and currency changes upstream; a currency-spell DataFrame is deliberately rejected.

  • target_weights (DataFrame) – Signed asset notionals divided by the chosen capital base at each trade. Rows must be actual valuation dates; include the opening date explicitly. A zero row closes assets. Weights need not sum to zero or one.

  • fx_data (FxRatesData) – Supplied USD-per-currency spots and annual rate benchmarks. FxRatesData spots are USD per currency; cross rates divide by reference spot.

  • spec (FxAccountSpec) – Explicit capital, local/reference financing, sizing and cash policy.

  • local_settlement_dates (DatetimeIndex) – Dates on which local asset-plus-financing P&L is swept to reference cash and financing reset to minus the held local asset value. Required explicitly, even when empty. Reference financing requires an empty schedule.

  • spot_is_observed (DataFrame) – Explicit boolean quote-availability panel on the valuation grid, covering every used currency. FxRatesData has already forward-filled spots; it cannot recover original missing-quote provenance. False permits valuation carry only under the selected policy, never execution or fixing.

  • forwards (DataFrame | None) – Optional contract table with columns trade_date, fixing_date, settlement_date, currency, notional_weight, notional_basis, and unique contract IDs. Positive weight buys local currency forward; negative hedges it. Capital sizing uses spec.notional_rule; asset_currency_value sizes on net marked equity exposure in that currency after same-date equity trades. Fixing/payment dates can differ. A new row is an explicit roll; no implicit early termination.

Returns:

Owned FxAccountData with cash, financing, unsettled marks, units, monetary P&L, cash transfers, contract receipts and exact reconciliation diagnostics.

Raises:

ValueError – On invalid labels/dates, unavailable execution/fixing quotes, missing rates, nonpositive discount factors or nonpositive capital at NAV-sized resets.

Return type:

FxAccountData

The model permits symmetric borrowing/lending at supplied benchmarks and unrestricted reference collateral cash, without costs, haircuts, basis, external flows or margin calls. Before fixing, forwards use current flat simple CIP curves to fixing and reference discounting to payment. At fixing q*(spot-strike) becomes a nominal reference receivable; it earns no cash interest before payment. Event order is accrual, marking/fixing/payment, local settlement, equity trade, new forward. Reporting resampling never resets a contract.