ZenQuant.Options.Snapshot (zen_quant v0.2.0)

Copy Markdown View Source

Structured options briefing over a pre-fetched chain.

to_report/2 is pure: it never fetches from an exchange. Callers supply a chain snapshot (optionally with spot and skew observations) and a source timestamp. Each section is independent — a failed or unavailable section is explicit and does not erase successful sections.

Sections

  • :oi_concentration — OI by strike/expiry, put/call totals, HHI-style concentration
  • :skewOptions.Skew.term_structure/1 over caller-supplied observations
  • :gamma_wallsOptions.GammaWalls.aggregate/3 (requires spot and greeks)
  • :pin_riskOptions.pin_risk/3 proximity heuristic (requires spot)

Every section records the inputs/assumptions it used.

API Functions

FunctionArityDescriptionParam Kinds
to_report2Compose a structured options briefing from a pre-fetched chain snapshot.snapshot: exchange_data

Summary

Types

Source timestamp for the briefing (caller-owned; not wall-clock)

Input validation failure

Pre-fetched option chain map

Structured options briefing

Independently named report section

Failed or unavailable section payload

Per-section inputs/assumptions echo

Successful section payload

Snapshot input for to_report/2

Functions

Build a structured briefing from a pre-fetched chain.

Types

as_of()

@type as_of() :: DateTime.t() | integer()

Source timestamp for the briefing (caller-owned; not wall-clock)

error_reason()

@type error_reason() ::
  :invalid_input
  | :missing_chain
  | :invalid_chain
  | :missing_as_of
  | :invalid_as_of
  | :invalid_opts

Input validation failure

option_chain()

@type option_chain() :: %{optional(String.t()) => map()}

Pre-fetched option chain map

report()

@type report() :: %{
  as_of: as_of(),
  oi_concentration: section(),
  skew: section(),
  gamma_walls: section(),
  pin_risk: section()
}

Structured options briefing

section()

@type section() :: section_ok() | section_error()

Independently named report section

section_error()

@type section_error() :: %{status: :error, reason: term(), inputs: section_inputs()}

Failed or unavailable section payload

section_inputs()

@type section_inputs() :: map()

Per-section inputs/assumptions echo

section_ok()

@type section_ok() :: %{status: :ok, value: term(), inputs: section_inputs()}

Successful section payload

snapshot_input()

@type snapshot_input() :: %{
  :chain => option_chain(),
  :as_of => as_of(),
  optional(:spot) => number(),
  optional(:skew_observations) => [map()]
}

Snapshot input for to_report/2

Functions

to_report(snapshot, opts \\ [])

@spec to_report(
  snapshot_input() | term(),
  keyword()
) :: {:ok, report()} | {:error, error_reason()}

Build a structured briefing from a pre-fetched chain.

Does not call any exchange. Section failures are isolated.