Skip to content

API Reference

A complete reference of methods available in ClobClient.

Client Initialization

ClobClient

python
class ClobClient(
    host: str,
    key: str = None,
    chain_id: int = 137,
    creds: ApiCreds = None,
    signature_type: int = 2,
    funder: str = None,
    env: str = "prod",
    simulation_mode: bool = False
)

Initializes the Fivesight CLOB client.

  • host: Base URL of the API.
  • key: (Optional) Your API Key for authentication.
  • chain_id: Chain ID (default 137 for Polygon).
  • simulation_mode: Set to True for paper trading or backtesting.

Session Management (Simulation)

create_simulation_session

python
def create_simulation_session(self, mode: str, initial_balance: float = 10000.0)

Starts or resets a simulation session.

  • mode: 'PAPER' (Real-time data) or 'BACKTEST' (Historical data).
  • initial_balance: Starting collateral in USD.

set_simulation_clock

python
def set_simulation_clock(self, iso_time: str)

Sets the virtual clock for backtesting.

  • iso_time: ISO 8601 formatted string (e.g., 2023-12-01T12:00:00).

Market Data

get_order_book

python
def get_order_book(self, token_id: str) -> OrderBookSummary

Fetches the current Level 2 Order Book for a token.

  • token_id: The asset ID.
  • Returns: OrderBookSummary containing bids and asks.

get_midpoint

python
def get_midpoint(self, token_id: str) -> float

Calculates the midpoint price between the best bid and best ask.

get_ticker

python
def get_ticker(self, token_id: str) -> Ticker

Fetches the latest ticker information (price, volume, etc.).

Trading

create_and_post_order

python
def create_and_post_order(self, order_args: OrderArgs) -> OrderResponse

Creates an order, signs it (if live), and posts it to the exchange.

OrderArgs:

  • price: Limit price.
  • size: Amount to trade.
  • side: OrderSide.BUY or OrderSide.SELL.
  • token_id: Market token ID.
  • order_type: OrderType.LIMIT or OrderType.MARKET (defaults to Limit).

cancel

python
def cancel(self, order_id: str)

Cancels a specific open order by its ID.

cancel_all

python
def cancel_all(self)

Cancels all open orders associated with the account.

Account Data

get_orders

python
def get_orders(self) -> List[Order]

Retrieves a list of open orders.

get_trades

python
def get_trades(self) -> List[Trade]

Retrieves a list of recent executions (fills).

Released under the MIT License.