Polymarket.Schemas.BestBidAskEvent (Polymarket v0.1.1)

Copy Markdown View Source

Best bid/ask event.

Summary

Functions

Builds a BestBidAskEvent from a decoded (atom-keyed) websocket message.

Types

t()

@type t() :: %Polymarket.Schemas.BestBidAskEvent{
  asset_id: String.t() | nil,
  best_ask: float() | nil,
  best_bid: float() | nil,
  event_type: String.t() | nil,
  market: String.t() | nil,
  spread: float() | nil,
  timestamp: integer() | nil
}

Functions

from_attrs(attrs)

@spec from_attrs(map()) :: {:ok, t()} | {:error, {:missing_fields, [atom()]}}

Builds a BestBidAskEvent from a decoded (atom-keyed) websocket message.

Constructs the struct directly — no Ecto.Changeset — for the websocket hot path. Numeric fields (delivered as JSON strings) are coerced via Polymarket.Schemas.Coerce. Returns {:error, {:missing_fields, fields}} when a required field is absent.