Appearance
Box Spread
Family: Stat-arb
What it computes
Emits BoxSpreadTick ticks carrying r_box, box_width off chain.
Available on the live, historical, and replay drives.
Methodology
4-leg synthetic funding rate (Boyarchenko / Eisenbach).
See the methodology overview for the citation index.
Inputs
Chain.
Key outputs
R_box, box_width. The full field set is in the tick table below.
Output schema (BoxSpreadTick)
The field / type / description table below is regenerated from the BoxSpreadTick Rust source by docs-site/scripts/inject-doc-tables.ts on every npm run docs:build. Do not hand-edit between the sentinels.
| Field | Type | Description |
|---|---|---|
root | Arc<str> | Underlying symbol (e.g. "SPX"). |
date | i32 | Trading session date (YYYYMMDD). |
ms_of_day | i32 | Milliseconds since midnight at emission time. |
expiration | i32 | Box-expiration date (YYYYMMDD). |
dte | i32 | Calendar days from date to expiration. |
k_lower | f64 | Lower strike leg (long call + short put). |
k_upper | f64 | Upper strike leg (short call + long put). |
box_width | f64 | Box width — k_upper - k_lower. Equals the guaranteed payoff at expiry. |
box_price | f64 | Net debit / credit to enter the box: (C_low - C_high) + (P_high - P_low). Discounted at r_box reproduces box_width. |
r_box | f64 | Implied risk-free rate: -ln(box_price / box_width) / t_years (annualised continuous compounding). f64::NAN when the position is not a valid debit / the log term is undefined. |
t_years | f64 | Year-fraction time-to-expiry used in r_box. |
Configuration (BoxSpreadParams)
Regenerated from the BoxSpreadParams Rust source — see the note above.
| Field | Type | Description |
|---|---|---|
contracts | SecurityFilter | Contracts the subscription tracks. |
rate | Arc<dyn RateService> | Risk-free rate provider. Kept on the spec for symmetry with sibling chain analytics (implied_spot, iv_term_structure, …) — the box arithmetic itself reads the implied rate out of the four-leg position rather than consuming this input. |
venues | ExchangeFilter | Exchange / venue admission policy. |
emit | EmitPolicy | Emission policy. Defaults to [EmitPolicy::OnExchangeInterval] at one row per second per (symbol, expiration): the box rate is a property of the whole chain snapshot, so the per-second event-time cadence carries the full signal without paying a chain sweep per inbound quote. OnEveryTick fires per admitted Quote; OnClose accumulates and fires on watermark. |
spot_cache | SpotPriceCache | Shared spot price cache. Not consumed by the box arithmetic itself (the box payoff is spot-independent) but kept on the spec so the analytic shares the engine-level cache with sibling chain analytics on the same subscription. |
calendar | Arc<dyn MarketCalendar> | Market calendar provider. |
Example
Python
python
import kairos_thetadata as kt
client = kt.Client.connect(kt.Credentials.from_env())
def on_event(row):
print(row)
sub = client.live().box_spread(["SPX"]).on_event(on_event)
sub.wait(timeout_seconds=60.0)TypeScript
typescript
import { Client, Credentials } from "kairos-thetadata";
const client = await Client.connect(Credentials.fromEnv());
await client
.live()
.boxSpread(["SPX"])
.onEvent((tick) => {
console.log(tick);
});Rust
rust
// Cargo.toml:
// kairos = "0.1"
use kairos::{Client, BoxSpreadRow};
# fn run() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::connect(("me@example.com", "secret"))?;
let sub = client
.live()
.box_spread(["SPX"])
.on_event(|row: &BoxSpreadRow| {
println!("box_price={} r_box={}", row.box_price, row.r_box)
})?;
// ... later ...
sub.unsubscribe();
# Ok(())
# }