Appearance
Butterfly Arb Residual
Family: Stat-arb
What it computes
Emits ButterflyArbResidualTick ticks carrying strikes_used, violations, min_residual, per_strike (strike, residual_value, residual_pct) off chain snapshot.
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
Carr-Madan (2001) discrete butterfly no-arbitrage residual C(K-h) − 2·C(K) + C(K+h) at every interior strike on the listed call-mid strip — chain-convexity screen the desk runs before the Breeden-Litzenberger density recovery.
See the methodology overview for the citation index.
Inputs
Chain snapshot.
Key outputs
Strikes_used, violations, min_residual, per_strike (strike, residual_value, residual_pct). The full field set is in the tick table below.
Output schema (ButterflyArbResidualTick)
The field / type / description table below is regenerated from the ButterflyArbResidualTick 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. |
expiration | i32 | Expiration YYYYMMDD for which the residuals were recovered. |
strikes_used | i32 | Count of interior strikes the residual sweep admitted. |
violations | i32 | Count of admitted interior strikes whose residual is strictly negative — the chain's butterfly-arbitrage violation count. |
min_residual | f64 | Minimum recovered residual across the admitted interior strikes; negative values flag a butterfly violation. |
per_strike | Vec<ButterflyResidualPoint> | Per-strike residual points, oldest-strike first. |
Configuration (ButterflyArbResidualParams)
Regenerated from the ButterflyArbResidualParams 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 with the other no-arbitrage analytics; the residual kernel operates on the chain snapshot, not the live trade tape. |
venues | ExchangeFilter | Exchange / venue admission policy. Retained for surface consistency with the other no-arbitrage analytics. |
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 the other chain-driven analytics surface. |
min_strikes | i32 | Minimum number of admitted strikes for the residual sweep. Defaults to [DEFAULT_MIN_STRIKES] (3). |
target_expiration | i32 | Target expiration YYYYMMDD. 0 selects the front expiration on the supplied chain snapshot (the per-symbol nearest-dated expiration with at least min_strikes admitted strikes). |
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().butterfly_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()
.butterflyArbResidual(["SPX"])
.onEvent((tick) => {
console.log(tick);
});Rust
rust
// Cargo.toml:
// kairos = "0.1"
use kairos::{Client, ButterflyArbResidualRow};
# fn run() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::connect(("me@example.com", "secret"))?;
let sub = client
.live()
.butterfly_arb_residual(["SPX"])
.on_event(|row: &ButterflyArbResidualRow| {
println!("min_residual={} violations={}", row.min_residual, row.violations)
})?;
// ... later ...
sub.unsubscribe();
# Ok(())
# }