Skip to content

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.

FieldTypeDescription
symbolArc<str>Underlying symbol (interned).
datei32Trading-session date (YYYYMMDD) at emission time.
ms_of_dayi32Milliseconds since midnight at emission time.
expirationi32Resolved expiration. 0 when every expiration was rolled into the chain-wide ratio.
call_oii64Total call-side open interest summed across the admitted chain.
put_oii64Total put-side open interest summed across the admitted chain.
pcr_oif64put_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_imbalancef64(call_oi - put_oi) / (call_oi + put_oi). In [-1, +1]; +1 = pure call OI, -1 = pure put OI.
contracts_usedi32Number of contracts contributing to the ratio.

Configuration (PcOiRatioParams)

Regenerated from the PcOiRatioParams Rust source — see the note above.

FieldTypeDescription
contractsSecurityFilterUnderlying symbols the subscription tracks.
conditionsConditionPolicyTrade-condition admission policy.
venuesExchangeFilterExchange / venue admission policy.
oi_cacheArc<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_expirationi32Target 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(())
# }

Proprietary. All rights reserved.