PolymarketClob.Order.Builder (PolymarketClob v0.2.0)

Copy Markdown View Source

Local order amount calculation and signed order construction.

This module mirrors the current official Python order builder for CLOB exchange orders, but it does not post orders to the API.

Summary

Functions

Builds and signs a limit order without posting it.

Builds and signs a market order without posting it.

Calculates maker/taker amounts for a limit order.

Calculates maker/taker amounts for a market order.

Builds an unsigned order map from already calculated maker/taker amounts.

Types

amount_result()

@type amount_result() :: %{
  side: 0 | 1,
  maker_amount: String.t(),
  taker_amount: String.t()
}

side()

@type side() :: :buy | :sell | String.t() | 0 | 1

Functions

build_limit_order(client, token_id, size, price, side, opts)

@spec build_limit_order(
  PolymarketClob.Client.t(),
  String.t(),
  number(),
  number(),
  side(),
  keyword()
) ::
  map()

Builds and signs a limit order without posting it.

build_market_order(client, token_id, amount, price, side, opts)

@spec build_market_order(
  PolymarketClob.Client.t(),
  String.t(),
  number(),
  number(),
  side(),
  keyword()
) ::
  map()

Builds and signs a market order without posting it.

limit_amounts(side, size, price, tick_size)

@spec limit_amounts(side(), number(), number(), String.t()) :: amount_result()

Calculates maker/taker amounts for a limit order.

market_amounts(side, amount, price, tick_size)

@spec market_amounts(side(), number(), number(), String.t()) :: amount_result()

Calculates maker/taker amounts for a market order.

The current Python client uses round_down for the market order price.

unsigned_order(client, token_id, amounts, opts)

@spec unsigned_order(
  PolymarketClob.Client.t(),
  String.t(),
  amount_result(),
  keyword()
) :: map()

Builds an unsigned order map from already calculated maker/taker amounts.