Polymarket.Schemas.LastTradePriceEvent (Polymarket v0.1.1)

Copy Markdown View Source

Last trade price event. Reports the price, size and side of the most recent trade executed against an asset.

Summary

Functions

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

Types

t()

@type t() :: %Polymarket.Schemas.LastTradePriceEvent{
  asset_id: String.t() | nil,
  event_type: String.t() | nil,
  fee_rate_bps: integer() | nil,
  market: String.t() | nil,
  price: float() | nil,
  side: String.t() | nil,
  size: float() | nil,
  timestamp: integer() | nil,
  transaction_hash: String.t() | nil
}

Functions

from_attrs(attrs)

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

Builds a LastTradePriceEvent 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.