Bourse.OptionReadiness.VenueRow (bourse v0.1.0)

Copy Markdown View Source

One venue's readiness row: environment, cells, derived status and judgment.

Buy-side fill readiness remains a single scalar status (:fill_ready, :order_lifecycle_ready, …). Short-side sell → margin → buyback readiness is an orthogonal capability (capabilities.short_fill_ready / side_status.short) so a venue may be both buy-fill-ready and short-fill-ready without collapsing the two into one precedence winner.

Summary

Functions

Derives status from evidence without inventing client_broken/venue_degraded.

True when the observed option book is empty / one-sided and recorded.

True when every required fill-cycle artifact is timestamped and present.

Builds a row from injected cell evidence (offline / report replay).

Builds a row from already-collected cells and optional metadata.

True when create/fetch/cancel succeeded and a market/account limitation is recorded.

True when short-side sell → margin → buyback → baseline-relative cleanup is complete.

JSON-safe map representation with linked evidence per cell.

Types

t()

@type t() :: %Bourse.OptionReadiness.VenueRow{
  book: map() | nil,
  capabilities: %{optional(atom()) => boolean()},
  cells: %{required(atom()) => Bourse.OptionReadiness.Cell.t()},
  environment: String.t() | nil,
  fill_evidence: map() | nil,
  host: String.t() | nil,
  judgment: map() | nil,
  limitation: map() | nil,
  observed_at: integer(),
  short_evidence: map() | nil,
  side_status: %{optional(atom()) => atom()},
  status: atom() | nil,
  status_reason: String.t() | nil,
  venue: String.t()
}

Functions

classify_status(row)

@spec classify_status(t() | map()) :: {:ok, atom()} | {:pending_judgment, String.t()}

Derives status from evidence without inventing client_broken/venue_degraded.

empty_book?(venue_row)

@spec empty_book?(t()) :: boolean()

True when the observed option book is empty / one-sided and recorded.

fill_ready_evidence?(venue_row)

@spec fill_ready_evidence?(t()) :: boolean()

True when every required fill-cycle artifact is timestamped and present.

from_injected(venue, evidence, opts \\ [])

@spec from_injected(String.t(), map(), keyword()) :: {:ok, t()}

Builds a row from injected cell evidence (offline / report replay).

new(venue, cells, opts \\ [])

@spec new(
  String.t(),
  %{required(atom()) => Bourse.OptionReadiness.Cell.t()},
  keyword()
) :: {:ok, t()}

Builds a row from already-collected cells and optional metadata.

order_lifecycle_ready?(row)

@spec order_lifecycle_ready?(t()) :: boolean()

True when create/fetch/cancel succeeded and a market/account limitation is recorded.

short_fill_ready_evidence?(row)

@spec short_fill_ready_evidence?(t()) :: boolean()

True when short-side sell → margin → buyback → baseline-relative cleanup is complete.

Orthogonal to scalar status / buy-side fill_ready. Incomplete or non-ok short evidence never returns true.

to_map(row)

@spec to_map(t()) :: map()

JSON-safe map representation with linked evidence per cell.