Appearance
P/C OI Ratio
Family: Flow surveillance
What it computes
Emits PcOiRatioTick ticks carrying call_oi, put_oi, pcr_oi, signed_imbalance, contracts_used off chain snapshot + OI.
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
Chain-level put / call open-interest ratio sum oi_put / sum oi_call plus signed-imbalance twin — CBOE put / call ratio methodology in standing-positioning form.
See the methodology overview for the citation index.
Inputs
Chain snapshot + OI.
Key outputs
Call_oi, put_oi, pcr_oi, signed_imbalance, contracts_used. The full field set is in the tick table below.
Output schema (PcOiRatioTick)
The field / type / description table below is regenerated from the PcOiRatioTick 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 | Resolved expiration. 0 when every expiration was rolled into the chain-wide ratio. |
call_oi | i64 | Total call-side open interest summed across the admitted chain. |
put_oi | i64 | Total put-side open interest summed across the admitted chain. |
pcr_oi | f64 | put_oi / call_oi. Always finite: the ratio is undefined when the chain carries zero call-side open interest, and the kernel reports that state as an error instead of publishing a placeholder value. |
signed_imbalance | f64 | (call_oi - put_oi) / (call_oi + put_oi). In [-1, +1]; +1 = pure call OI, -1 = pure put OI. |
contracts_used | i32 | Number of contracts contributing to the ratio. |
Configuration (PcOiRatioParams)
Regenerated from the PcOiRatioParams Rust source — see the note above.
| Field | Type | Description |
|---|---|---|
contracts | SecurityFilter | Underlying symbols the subscription tracks. |
conditions | ConditionPolicy | Trade-condition admission policy. |
venues | ExchangeFilter | Exchange / venue admission policy. |
oi_cache | Arc<OpenInterestCache> | Engine-wide option open-interest cache. The empty default is a placeholder — the analytic's kernel reads (expiration, right, strike) OI off the cache; the cache slot is retained so the DefaultSpec hook can fail closed with the documented cache-dependency error. |
target_expiration | i32 | Target expiration YYYYMMDD. 0 rolls every expiration on the supplied chain into the single chain-wide ratio. |
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().pc_oi_ratio(["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()
.pcOiRatio(["SPX"])
.onEvent((tick) => {
console.log(tick);
});Rust
rust
// Cargo.toml:
// kairos = "0.1"
use kairos::{Client, PcOiRatioRow};
# fn run() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::connect(("me@example.com", "secret"))?;
let sub = client
.live()
.pc_oi_ratio(["SPX"])
.on_event(|row: &PcOiRatioRow| println!("call_oi={} put_oi={}", row.call_oi, row.put_oi))?;
// ... later, to stop delivery ...
sub.unsubscribe();
# Ok(())
# }