Appearance
Calendar Arb Residual
Family: Stat-arb
What it computes
Emits CalendarArbResidualTick ticks carrying strikes_used, violations, min_residual, per_strike (strike, near_mid, far_mid, residual_value) off chain snapshot (multi-expiration).
Available on the live and replay drives. The historical drive fails closed with KAIROS_ERR_HISTORICAL_UNWIRED until the relevant cache is hydrated externally.
Methodology
Merton (1973) Theorem 5 calendar-spread time-monotonicity residual C(K, T_far) − C(K, T_near) at every shared strike across two listed expirations on a multi-expiration chain snapshot.
See the methodology overview for the citation index.
Inputs
Chain snapshot (multi-expiration).
Key outputs
Strikes_used, violations, min_residual, per_strike (strike, near_mid, far_mid, residual_value). The full field set is in the tick table below.
Output schema (CalendarArbResidualTick)
The field / type / description table below is regenerated from the CalendarArbResidualTick 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 |
|---|---|---|
symbol | Arc<str> | Underlying symbol (interned). |
date | i32 | Trading-session date (YYYYMMDD) at emission time. |
ms_of_day | i32 | Milliseconds since midnight at emission time. |
near_expiration | i32 | Near expiration YYYYMMDD anchoring C(K, T_near). |
far_expiration | i32 | Far expiration YYYYMMDD anchoring C(K, T_far). |
strikes_used | i32 | Count of shared strikes the residual sweep admitted. |
violations | i32 | Count of admitted strikes whose residual is strictly negative — the chain's calendar-spread arbitrage violation count. |
min_residual | f64 | Minimum recovered residual across the admitted strikes; negative values flag a calendar violation. |
per_strike | Vec<CalendarResidualPoint> | Per-strike residual points. |
Configuration (CalendarArbResidualParams)
Regenerated from the CalendarArbResidualParams Rust source — see the note above.
| Field | Type | Description |
|---|---|---|
contracts | SecurityFilter | Underlying symbols the subscription tracks. |
conditions | ConditionPolicy | Trade-condition admission policy. Retained for surface consistency. |
venues | ExchangeFilter | Exchange / venue admission policy. Retained for surface consistency. |
daily_close | Arc<DailyCloseCache> | Boot-time hydrated daily-close history. The empty default is a placeholder — the kernel consumes a chain snapshot rather than the daily-close history, but the cache slot is retained so the DefaultSpec hook can fail closed with the same documented cache-dependency error. |
min_shared_strikes | i32 | Minimum number of strikes shared by both legs. Defaults to [DEFAULT_MIN_SHARED_STRIKES] (1). |
near_expiration | i32 | Near expiration target YYYYMMDD. 0 selects the front expiration on the supplied chain snapshot. |
far_expiration | i32 | Far expiration target YYYYMMDD. 0 selects the second-nearest expiration after near_expiration. |
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().calendar_arb_residual(["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()
.calendarArbResidual(["SPX"])
.onEvent((tick) => {
console.log(tick);
});Rust
rust
// Cargo.toml:
// kairos = "0.1"
use kairos::{Client, CalendarArbResidualRow};
# fn run() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::connect(("me@example.com", "secret"))?;
let sub = client
.live()
.calendar_arb_residual(["SPX"])
.on_event(|row: &CalendarArbResidualRow| {
println!("min_residual={} violations={}", row.min_residual, row.violations)
})?;
// ... later ...
sub.unsubscribe();
# Ok(())
# }