Skip to content

Usage Guide

The Fivesight CLOB Client is designed primarily for Simulation, Paper Trading, and Backtesting. It connects to Fivesight's high-fidelity market replication engine rather than the live Polymarket exchange for matching, though it streams live market data.

IMPORTANT

Simulation Only: This client does not execute trades on the Polygon blockchain or Polymarket. All orders are matched internally by Fivesight for backtesting and paper trading.

1. Initialization

Initialize the client with your API Key (generated in the Fivesight Dashboard).

python
from fivesight_clob_client.client import ClobClient

client = ClobClient(
    env="prod",
    key="fs_live_YOUR_API_KEY",  # From Developer Dashboard
    simulation_mode=True         # REQUIRED for simulation
)

2. Session Management

Before placing orders, you must create a Simulation Session.

Paper Trading (Live Data)

Use PAPER mode to trade against real-time market moves with a simulated wallet.

python
# Create a session with $10,000 simulated USDC
client.create_simulation_session(mode="PAPER", initial_balance=10000)

Backtesting (Historical Data)

Use BACKTEST mode to replay history.

python
# Create a backtest session
client.create_simulation_session(mode="BACKTEST", initial_balance=50000)

# Set the Virtual Clock
client.set_simulation_clock("2024-01-01T12:00:00")

3. Market Data

Fetching the Order Book works the same in both modes. in BACKTEST mode, it returns the book as it existed at your Virtual Clock time.

python
token_id = "123..." # Asset ID
book = client.get_order_book(token_id)

print(f"Best Bid: {book.bids[0].price}")
print(f"Best Ask: {book.asks[0].price}")

4. Placing Orders

Orders are matched appropriately based on your session mode.

python
from fivesight_clob_client.clob_types import OrderArgs, OrderSide, OrderType

order = client.create_and_post_order(
    OrderArgs(
        price=0.50,
        size=100.0,
        side=OrderSide.BUY,
        token_id=token_id
    )
)
print(f"Order Placed: {order.id}")

5. Managing Orders

python
# List open orders
orders = client.get_orders()

# Cancel specific order
client.cancel(order_id="0x...")

# Cancel ALL orders
client.cancel_all()

6. Accessing Data API (Dev Pro+)

If you have a Dev Pro or Ultimate plan, you can access raw data endpoints via the client or HTTP.

See Data API Reference for details.

Released under the MIT License.