An international ETF backtest can show excellent premium convergence even when the simulated ETF trades lose money. One common cause is a moving reference value. Another is using a quote or FX update that had occurred at the exchange but had not reached the strategy. A small regression fixture can catch both.
This article was drafted using an AI writing tool. The data below is synthetic, and the implementation covers one unhedged currency exposure with a single local-currency equity proxy.
- Define what can enter the replay For each observation, retain event_at and received_at. A strategy decision can see a record only when both timestamps are at or before its decision cutoff. Once the available set is known, select the latest event for each input series, with receipt time breaking a tie in this fixture. Then check age against the appropriate limit. A late older message should not overwrite a newer event that has already been received.
A production dataset should also preserve source sequence, the holdings or benchmark snapshot, market session, and proxy currency. Quoting FX as foreign currency per dollar gives the reciprocal of the rate needed to convert local portfolio values into dollars. A production parser should record the unit and normalize it explicitly.
Get the valuation convention from the source before choosing an initial reference. A screen may show a lagged NAV or an IIV based partly on old security quotes. Some funds fair-value the underlying holdings in official NAV. Store the source convention with the feature, and keep the source value distinct from the strategy's estimate. SEC discussion of intraday indicative values · iShares on international ETF fair-value adjustments
- Run a fixture that separates the estimate, the signal, and P&L The code uses a synthetic clock on a single date. The old basket is $50. The local-equity proxy gains 1.50% and the foreign currency gains 0.60% in dollar terms. A newer proxy observation arrives too late for the decision. A flat ETF quote at exit then tests whether a narrower displayed premium can coexist with a trading loss. from dataclasses import dataclass from datetime import datetime, timedelta, timezone from decimal import Decimal as D
@dataclass(frozen=True)
class Observation:
event_at: datetime
received_at: datetime
value: D
def latest_at(rows, cutoff, max_age):
eligible = [
row for row in rows
if row.event_at <= cutoff and row.received_at <= cutoff
]
if not eligible:
raise ValueError("No eligible observation at cutoff")
selected = max(eligible, key=lambda row: (row.event_at, row.received_at))
if cutoff - selected.event_at > max_age:
raise ValueError("Selected observation is stale")
return selected.value
def usd_per_foreign_return(foreign_per_usd_start, foreign_per_usd_end):
return foreign_per_usd_start / foreign_per_usd_end - 1
def premium(quote, reference):
return quote / reference - 1
def short_etf_pnl(entry_bid, exit_ask, shares, explicit_cost=D("0")):
return (entry_bid - exit_ask) * shares - explicit_cost
def verify():
cutoff = datetime(2026, 11, 23, 15, 30, 1, tzinfo=timezone.utc)
eligible = Observation(
cutoff - timedelta(seconds=4), cutoff - timedelta(seconds=3), D("0.015")
)
late = Observation(
cutoff - timedelta(seconds=1), cutoff + timedelta(seconds=1), D("0.045")
)
older = Observation(
cutoff - timedelta(seconds=8), cutoff, D("0.009")
)
fx = Observation(
cutoff - timedelta(seconds=2), cutoff - timedelta(seconds=1), D("0.006")
)
age_limit = timedelta(seconds=10)
equity_return = latest_at([late, older, eligible], cutoff, age_limit)
fx_return = latest_at([fx], cutoff, age_limit)
assert equity_return == D("0.015")
assert usd_per_foreign_return(D("100.6"), D("100")) == fx_return
old_reference = D("50.00")
bid, ask = D("51.10"), D("51.30")
midpoint = (bid + ask) / 2
fair_value = old_reference * (1 + equity_return) * (1 + fx_return)
assert fair_value == D("51.0545")
assert premium(midpoint, old_reference) == D("0.024")
assert bid - fair_value == D("0.0455")
assert premium(midpoint, D("51.15")) < D("0.001")
assert short_etf_pnl(bid, ask, D("1")) == D("-0.20")
assert short_etf_pnl(bid, ask, D("1"), D("0.02")) == D("-0.22")
try:
latest_at([older], cutoff, timedelta(seconds=5))
except ValueError as error:
assert str(error) == "Selected observation is stale"
else:
raise AssertionError("Stale observation was accepted")
print("Point-in-time, FX, premium, and P&L checks passed.")
if name == "main":
verify()
At the cutoff, the model uses the value that arrived in time. The estimated basket is $51.0545 and the sale-side gross gap is $0.0455. The mark-to-model gap and the short trade ledger are different outputs. The short was sold at the bid and covered at the ask, for a $0.20 loss per share before explicit costs. Including a fee in short_etf_pnl deducts that fee only. Crossing the ETF spread is reflected in the fill prices. SEC investor bulletin on ETF bid–ask spreads
- Keep the invariants when scaling up For a KAEL AI research implementation, I would attach a small audit record to every signal: decision timestamp, the IDs of the proxy and FX observations selected, estimated basket and its sensitivity range, quote side, quoted size, and intended hedge. A separate execution record should capture fills, borrow, hedge P&L, and fees.
Add the following cases before running a study on real feeds:
Input case Expected behavior
An update arrives after the cutoff The update is unavailable, even when its event time precedes the cutoff.
A newer event arrives before an older source event that was delayed The latest eligible source event remains selected.
A source reuses a timestamp Apply the documented tie-break, using sequence or revision identifiers where provided.
The local exchange is closed for a holiday Apply the stated calendar and stale-price policy to the local marks. Test proxy availability separately.
FX is already embedded in the proxy return Use an input policy that removes or avoids the duplicated exposure.
ETF top-of-book size is smaller than the simulated trade Constrain the fill or model deeper levels.
The next open is used for validation Keep it in the outcome table. The signal must reproduce without it.
Finally, run the signal twice, before and after you ingest later articles, prices, or holdings files. Recompute the same historical decision with the same snapshots and arrival rules. You should recover the same selected inputs, fair-value estimate, and modeled entry conditions. If the later run changes, compare observation IDs before investigating strategy returns.
Top comments (0)