Order
Overview
The Opinion CLOB implements two order execution types (Market, Limit) and two position directions (Buy, Sell). These primitives enable participation in binary prediction markets through standardized order mechanics.
Order Sides
BUY (Long Position)
Definition: Acquisition of outcome tokens representing a prediction that the specified event will occur.
Example - Binary Market: "Will BTC reach $100k in 2025?"
from opinion_clob_sdk.chain.py_order_utils.model.sides import OrderSide
# Buy YES tokens (betting it will happen)
side = OrderSide.BUYPayoff Structure:
Long 100 YES @ $0.60
$60
YES
$100
+$40 (66.7% ROI)
Long 100 YES @ $0.60
$60
NO
$0
-$60 (100% loss)
Risk Parameters:
Maximum Loss: Premium paid (position cost)
Maximum Gain: $1.00 per share minus premium
Breakeven: Event resolution matches position direction
SELL (Short Position or Position Exit)
Definition: Transfer of outcome tokens, either closing an existing long position or establishing a synthetic short position.
Two Use Cases:
Use Case 1: Close Position (Take Profit/Loss)
P&L Calculation:
Entry: 100 YES @ $0.50 = $50 cost basis
Exit: 100 YES @ $0.75 = $75 proceeds
Realized P&L: +$25 (50% return)
Use Case 2: Synthetic Short (Advanced)
Strategy: Split collateral into outcome token pairs, sell overpriced outcome, retain opposite side.
Order Types
Market Orders
Definition: Orders executing immediately at the best available counterparty price, prioritizing fill certainty over price control.
Execution Characteristics:
Fill guarantee (subject to liquidity availability)
Immediate execution (latency: 200-500ms)
Price discovery via orderbook matching
Slippage exposure in thin markets
Use Cases:
Urgent position entry/exit requirements
Markets with deep liquidity (tight spread)
Price movement urgency exceeds execution cost sensitivity
Closing positions under time constraints
Syntax:
Order Matching Mechanism:
Order transmitted to CLOB matching engine
Matching engine iterates best available limit orders
Fills sequentially until USDT allocation exhausted or orderbook cleared
Outcome tokens credited to multi_sig_addr
Execution report returned (average fill price, total quantity)
Slippage Example:
Limit Orders
Definition: Orders that only execute at your specified price or better.
Characteristics:
β Price control (you set maximum/minimum)
β No slippage (always your price or better)
β May not fill (if price never reached)
β Delayed execution (passive waiting)
When to Use:
You want a specific price
No urgency to execute
Market making strategies
Large orders (avoid slippage)
Syntax:
How Limit Orders Execute:
SDK sends order to CLOB
CLOB adds order to orderbook
Order waits for counterparty
Fills when matching order arrives (or immediate if crosses spread)
You receive tokens (partial fills possible)
Order Matching Example:
Price Mechanics
Price Range
Valid Prices: 0.01 to 0.99
Interpretation:
0.01= 1% probability = 1Β’ per $1 share0.50= 50% probability = 50Β’ per $1 share0.99= 99% probability = 99Β’ per $1 share
Invalid Prices:
Price Precision
Prices are strings with up to 4 decimal places:
Bid-Ask Spread
The difference between best buy and sell prices.
Spread Implications:
$0.01
Tight (liquid)
Market orders OK
$0.05
Moderate
Limit orders recommended
$0.10+
Wide (illiquid)
Limit orders essential
Amount Specifications
Quote Token Amount (USDT)
Specify how much USDT to spend (BUY) or receive (SELL).
When to Use:
You have a fixed budget (e.g., "spend $100")
Dollar-cost averaging
Portfolio allocation (e.g., "allocate 10% of portfolio")
Base Token Amount (Outcome Tokens)
Specify exact number of outcome tokens to buy/sell.
When to Use:
Closing a specific position (e.g., "sell all my 100 YES tokens")
Rebalancing to exact token counts
Arbitrage strategies
Conversion Between Amounts
Order Examples
Example 1: Simple Market Buy
Example 2: Limit Buy at Specific Price
Example 3: Take Profit Sell
Example 4: Limit Sell (Ask)
Order Lifecycle
1. Order Creation
2. Order States
Pending
Waiting in orderbook
Cancel or wait
Filled
Fully executed
View trade history
Cancelled
Manually cancelled / Cancelled by system default rules
None
Expired
Time limit reached
Place new order
3. Checking Order Status
4. Cancelling Orders
Best Practices
1. Check Orderbook Before Trading
2. Use Limit Orders for Large Sizes
3. Price Validation
Common Mistakes
Mistake 1: Wrong Amount Type
Mistake 2: Forgetting Price for Limit Orders
Next Steps
Gas Operations - Understanding when you need BNB
API Reference - Trading - Full method documentation
Last updated