Polymarket.Schemas.Market (Polymarket v0.1.1)

Copy Markdown View Source

A market returned by the Gamma REST API (e.g. GET /markets/:id).

The Gamma API delivers its keys in camelCase; from_attrs/1 normalises them to the snake_case fields below. A handful of fields are delivered as JSON-encoded strings (e.g. outcomes arrives as "[\"Up\", \"Down\"]"); from_attrs/1 decodes these via Polymarket.Schemas.Coerce.

Field coverage follows the Gamma OpenAPI Market schema. The remaining nested relational objects (events, categories, imageOptimized, iconOptimized) are intentionally omitted: GET /markets/:id does not return them, and events is a large, self-referential Market <-> Event graph.

Summary

Functions

Builds a Market from the raw (JSON-decoded) Gamma attributes. Keys may be in camelCase (atom or string); they are normalised to the snake_case fields and each value is coerced to its field type. Returns {:error, {:missing_fields, fields}} when a required field is absent.

Types

t()

@type t() :: %Polymarket.Schemas.Market{
  accepting_orders: boolean() | nil,
  accepting_orders_timestamp: DateTime.t() | nil,
  active: boolean() | nil,
  amm_type: String.t() | nil,
  approved: boolean() | nil,
  archived: boolean() | nil,
  automatically_active: boolean() | nil,
  automatically_resolved: boolean() | nil,
  best_ask: float() | nil,
  best_bid: float() | nil,
  category: String.t() | nil,
  category_mailchimp_tag: String.t() | nil,
  chart_color: String.t() | nil,
  clear_book_on_start: boolean() | nil,
  clob_rewards: [Polymarket.Schemas.ClobReward.t()],
  clob_token_ids: [String.t()] | nil,
  closed: boolean() | nil,
  closed_time: DateTime.t() | nil,
  combo_status: String.t() | nil,
  comments_enabled: boolean() | nil,
  competitive: float() | nil,
  condition_id: String.t() | nil,
  created_at: DateTime.t() | nil,
  created_by: integer() | nil,
  creator: String.t() | nil,
  curation_order: integer() | nil,
  custom_liveness: integer() | nil,
  cyom: boolean() | nil,
  denomination_token: String.t() | nil,
  deploying: boolean() | nil,
  deploying_timestamp: DateTime.t() | nil,
  description: String.t() | nil,
  disqus_thread: String.t() | nil,
  enable_order_book: boolean() | nil,
  end_date: DateTime.t() | nil,
  end_date_iso: Date.t() | nil,
  event_start_time: DateTime.t() | nil,
  featured: boolean() | nil,
  fee: String.t() | nil,
  fee_schedule: Polymarket.Schemas.FeeSchedule.t() | nil,
  fee_type: String.t() | nil,
  fees_enabled: boolean() | nil,
  format_type: String.t() | nil,
  fpmm_live: boolean() | nil,
  funded: boolean() | nil,
  funded_timestamp: DateTime.t() | nil,
  game_id: String.t() | nil,
  game_start_time: DateTime.t() | nil,
  group_item_range: String.t() | nil,
  group_item_threshold: String.t() | nil,
  group_item_title: String.t() | nil,
  has_reviewed_dates: boolean() | nil,
  holding_rewards_enabled: boolean() | nil,
  icon: String.t() | nil,
  id: String.t() | nil,
  image: String.t() | nil,
  last_trade_price: float() | nil,
  line: float() | nil,
  liquidity: String.t() | nil,
  liquidity_amm: float() | nil,
  liquidity_clob: float() | nil,
  liquidity_num: float() | nil,
  lower_bound: String.t() | nil,
  lower_bound_date: String.t() | nil,
  mailchimp_tag: String.t() | nil,
  maker_base_fee: integer() | nil,
  maker_rebates_fee_share_bps: integer() | nil,
  manual_activation: boolean() | nil,
  market_group: integer() | nil,
  market_maker_address: String.t() | nil,
  market_metadata: Polymarket.Schemas.MarketMetadata.t() | nil,
  market_type: String.t() | nil,
  neg_risk: boolean() | nil,
  neg_risk_market_id: String.t() | nil,
  neg_risk_other: boolean() | nil,
  neg_risk_request_id: String.t() | nil,
  new: boolean() | nil,
  notifications_enabled: boolean() | nil,
  one_day_price_change: float() | nil,
  one_hour_price_change: float() | nil,
  one_month_price_change: float() | nil,
  one_week_price_change: float() | nil,
  one_year_price_change: float() | nil,
  order_min_size: integer() | nil,
  order_price_min_tick_size: float() | nil,
  outcome_prices: [float()] | nil,
  outcomes: [String.t()] | nil,
  pager_duty_notification_enabled: boolean() | nil,
  past_slugs: String.t() | nil,
  pending_deployment: boolean() | nil,
  position_ids: [String.t()] | nil,
  question: String.t() | nil,
  question_id: String.t() | nil,
  ready: boolean() | nil,
  ready_for_cron: boolean() | nil,
  ready_timestamp: DateTime.t() | nil,
  requires_translation: boolean() | nil,
  resolution_source: String.t() | nil,
  resolved_by: String.t() | nil,
  restricted: boolean() | nil,
  rewards_max_spread: float() | nil,
  rewards_min_size: integer() | nil,
  rfq_enabled: boolean() | nil,
  scheduled_deployment_timestamp: DateTime.t() | nil,
  score: integer() | nil,
  seconds_delay: integer() | nil,
  sent_discord: boolean() | nil,
  series_color: String.t() | nil,
  short_outcomes: [String.t()] | nil,
  show_gmp_outcome: boolean() | nil,
  show_gmp_series: boolean() | nil,
  slug: String.t() | nil,
  sponsor_image: String.t() | nil,
  sponsor_name: String.t() | nil,
  sports_market_type: String.t() | nil,
  spread: float() | nil,
  start_date: DateTime.t() | nil,
  start_date_iso: Date.t() | nil,
  subcategory: String.t() | nil,
  submitted_by: String.t() | nil,
  tags: [Polymarket.Schemas.Tag.t()],
  taker_base_fee: integer() | nil,
  team_aid: String.t() | nil,
  team_bid: String.t() | nil,
  twitter_card_image: String.t() | nil,
  twitter_card_last_refreshed: String.t() | nil,
  twitter_card_last_validated: String.t() | nil,
  twitter_card_location: String.t() | nil,
  uma_bond: String.t() | nil,
  uma_end_date: String.t() | nil,
  uma_end_date_iso: String.t() | nil,
  uma_resolution_status: String.t() | nil,
  uma_resolution_statuses: [String.t()] | nil,
  uma_reward: String.t() | nil,
  updated_at: DateTime.t() | nil,
  updated_by: integer() | nil,
  upper_bound: String.t() | nil,
  upper_bound_date: String.t() | nil,
  volume: String.t() | nil,
  volume1mo: float() | nil,
  volume1mo_amm: float() | nil,
  volume1mo_clob: float() | nil,
  volume1wk: float() | nil,
  volume1wk_amm: float() | nil,
  volume1wk_clob: float() | nil,
  volume1yr: float() | nil,
  volume1yr_amm: float() | nil,
  volume1yr_clob: float() | nil,
  volume24hr: float() | nil,
  volume24hr_amm: float() | nil,
  volume24hr_clob: float() | nil,
  volume_amm: float() | nil,
  volume_clob: float() | nil,
  volume_num: float() | nil,
  wide_format: boolean() | nil,
  x_axis_value: String.t() | nil,
  y_axis_value: String.t() | nil
}

Functions

from_attrs(attrs)

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

Builds a Market from the raw (JSON-decoded) Gamma attributes. Keys may be in camelCase (atom or string); they are normalised to the snake_case fields and each value is coerced to its field type. Returns {:error, {:missing_fields, fields}} when a required field is absent.