Overview

Opinion CLOB SDK

Welcome to the official documentation for the Opinion CLOB SDK - a Python library for interacting with Opinion Labs' prediction markets via the Central Limit Order Book (CLOB) API.

πŸ”¬ Technical Preview: Version 0.2.3 features BNB Chain support. While fully functional and tested, we recommend thorough testing before production use.

What is Opinion CLOB SDK?

The Opinion CLOB SDK provides a Python interface for building applications on top of Opinion prediction market infrastructure. It enables developers to:

  • Query market data - Access real-time market information, prices, and orderbooks

  • Execute trades - Place market and limit orders with EIP712 signing

  • Manage positions - Track balances, positions, and trading history

  • Interact with smart contracts - Split, merge, and redeem tokens on BNB Chain blockchain

Key Features

πŸš€ Production-Ready

  • Type-safe - Full type hints and Pythonic naming conventions

  • Well-tested - test suite with 95%+ coverage

  • Reliable - Built on industry-standard libraries (Web3.py, eth-account)

  • Documented - Extensive documentation with examples

⚑ Performance Optimized

  • Smart caching - Configurable TTL for market data and quote tokens

  • Batch operations - Place or cancel multiple orders efficiently

  • Gas optimization - Minimal on-chain transactions

πŸ”’ Secure by Design

  • EIP712 signing - Industry-standard typed data signatures

  • Multi-sig support - Gnosis Safe integration for institutional users

  • Private key safety - Keys never leave your environment

🌐 Blockchain Support

  • BNB Chain Mainnet (Chain ID: 56)

Use Cases

Trading Applications

Build automated trading bots, market-making applications, or custom trading interfaces.

from opinion_clob_sdk import Client
from opinion_clob_sdk.chain.py_order_utils.model.order import PlaceOrderDataInput
from opinion_clob_sdk.chain.py_order_utils.model.sides import OrderSide

client = Client(host='https://proxy.opinion.trade:8443', apikey='your_key', ...)

# Place a limit order
order = PlaceOrderDataInput(
    marketId=123,
    tokenId='token_yes',
    side=OrderSide.BUY,
    orderType=LIMIT_ORDER,
    price='0.55',
    makerAmountInQuoteToken=100
)
result = client.place_order(order)

Market Analytics

Aggregate and analyze market data for research or monitoring dashboards.

# Get all active markets
markets = client.get_markets(status=TopicStatusFilter.ACTIVATED, limit=100)

# Analyze orderbook depth
orderbook = client.get_orderbook(token_id='token_123')
print(f"Best bid: {orderbook.bids[0]['price']}")
print(f"Best ask: {orderbook.asks[0]['price']}")

Portfolio Management

Track positions and balances across multiple markets.

# Get user positions
positions = client.get_my_positions(limit=50)

# Get balances
balances = client.get_my_balances()

# Get trade history
trades = client.get_my_trades(market_id=123)

Architecture

The Opinion CLOB SDK is built with a modular architecture:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚          Application Layer                  β”‚
β”‚         (Your Python Code)                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
               β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚         Opinion CLOB SDK                    β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”‚
β”‚  β”‚ Client API   β”‚   β”‚ Contract Caller β”‚     β”‚
β”‚  β”‚ (REST)       β”‚   β”‚ (Blockchain)    β”‚     β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
          β”‚                      β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€-▼───────────┐
β”‚  Opinion API       β”‚  β”‚     Blockchain     β”‚
β”‚  (CLOB Exchange)   β”‚  β”‚  (Smart Contracts) β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜


Ready to get started? Head to the Installation Guide to begin building with Opinion CLOB SDK!

Last updated