Types

All data types are Python dataclasses defined in turbine_client.types. They are returned by TurbineClient methods and can be imported directly.

from turbine_client import Side, Outcome, OrderArgs, SignedOrder
from turbine_client.types import (
    Market, MarketStats, OrderBookSnapshot, PriceLevel, Trade, Position,
    QuickMarket, Resolution, Order, AssetPrice, UserActivity, UserStats,
    PermitSignature, Holder, PlatformStats, ChainStats,
    FailedTrade, PendingTrade, FailedClaim, PendingClaim, SettlementStatus,
    WSMessage, OrderBookUpdate, TradeUpdate, QuickMarketUpdate,
)

Enums

Side

Order side. Used in OrderArgs and order filtering.

class Side(IntEnum):
    BUY = 0
    SELL = 1

Outcome

Market outcome. Used in OrderArgs and orderbook filtering.

class Outcome(IntEnum):
    YES = 0
    NO = 1

Order Types

OrderArgs

Arguments for creating a new order. Passed to client.create_order().

FieldTypeDescription
market_idstrMarket ID (hex string)
sideSideSide.BUY or Side.SELL
outcomeOutcomeOutcome.YES or Outcome.NO
priceintPrice scaled by 1e6 (1–999999; 500000 = $0.50)
sizeintSize with 6 decimals (1000000 = 1 share)
expirationintUnix timestamp for order expiry
nonceintAuto-generated if 0 (default)
maker_fee_recipientstrFee recipient address (default: zero address)

Validation runs on construction. Raises ValueError if price is outside 1–999999 or size is not positive.

SignedOrder

A signed order ready for submission via client.post_order().

FieldTypeDescription
market_idstrMarket ID
traderstrSigner's wallet address
sideint0 (buy) or 1 (sell)
outcomeint0 (YES) or 1 (NO)
priceintPrice (6 decimals)
sizeintSize (6 decimals)
nonceintOrder nonce
expirationintExpiration timestamp
maker_fee_recipientstrFee recipient address
signaturestrEIP-712 signature (hex)
order_hashstrComputed order hash (hex)
permit_signaturePermitSignature | NoneOptional attached USDC permit

Created by client.create_order(), client.create_limit_buy(), or client.create_limit_sell(). Call signed.to_dict() for the API-ready JSON payload.

PermitSignature

EIP-2612 permit signature for gasless USDC approval. Returned by client.sign_usdc_permit().

FieldTypeDescription
nonceintPermit nonce (must match on-chain)
valueintApproved amount (6 decimals)
deadlineintExpiration timestamp
vintSignature v component
rstrSignature r component (hex, 0x-prefixed)
sstrSignature s component (hex, 0x-prefixed)

Order

An order on the orderbook. Returned by client.get_orders(), client.get_order(), client.get_user_orders().

FieldTypeDescription
order_hashstrOrder hash
market_idstrMarket ID
traderstrTrader address
sideint0 = buy, 1 = sell
outcomeint0 = YES, 1 = NO
priceintPrice (6 decimals)
sizeintOriginal size (6 decimals)
filled_sizeintAmount filled (6 decimals)
remaining_sizeintAmount remaining (6 decimals)
nonceintOrder nonce
expirationintExpiration timestamp
statusstr"open", "filled", or "cancelled"
created_atintCreation timestamp

Market Types

Market

A prediction market. Returned by client.get_markets().

FieldTypeDescription
idstrMarket ID (hex, used for API calls)
chain_idintChain ID
contract_addressstrMarket contract address (used for claiming)
settlement_addressstrSettlement contract address
questionstrMarket question text
descriptionstrMarket description
categorystrMarket category
expirationintExpiration timestamp
makerstrMarket creator address
resolvedboolWhether the market is resolved
winning_outcomeint | None0 (YES) or 1 (NO) if resolved
volumeintTotal volume (6 decimals)
created_atintCreation timestamp
updated_atintLast update timestamp

MarketStats

Statistics for a market. Returned by client.get_market(), client.get_stats().

FieldTypeDescription
market_idstrMarket ID
contract_addressstrMarket contract address
last_priceintLast trade price (6 decimals; 500000 = $0.50)
total_volumeintTotal volume (6 decimals)
volume_24hint24-hour volume (6 decimals)

QuickMarket

A 15-minute quick market. Returned by client.get_quick_market(), client.get_quick_market_history().

FieldTypeDescription
idintAuto-increment ID
market_idstrMarket ID (hex)
assetstrAsset symbol ("BTC", "ETH")
interval_minutesintDuration in minutes (15)
start_priceintStrike price (8 decimals; divide by 1e8 for dollars)
end_priceint | NoneFinal price at resolution
start_timeintStart timestamp
end_timeintExpiration timestamp
resolvedboolWhether resolved
outcomeint | None0 (YES) or 1 (NO) if resolved
price_sourcestrOracle source (e.g., "pyth")
created_atintCreation timestamp
contract_addressstrMarket contract address

Resolution

Market resolution status. Returned by client.get_resolution().

FieldTypeDescription
market_idstrMarket ID
assertion_idstrUMA assertion ID
outcomeintWinning outcome (0 = YES, 1 = NO)
resolvedboolWhether resolved
timestampintResolution timestamp

Orderbook Types

OrderBookSnapshot

Orderbook state for a market. Returned by client.get_orderbook().

FieldTypeDescription
market_idstrMarket ID
bidslist[PriceLevel]Bid levels (sorted best-first)
askslist[PriceLevel]Ask levels (sorted best-first)
last_updateintLast update timestamp

PriceLevel

A single price level in the orderbook.

FieldTypeDescription
priceintPrice (6 decimals; 500000 = $0.50)
sizeintTotal size at this level (6 decimals; 1000000 = 1 share)

Trade Types

Trade

A trade execution. Returned by client.get_trades().

FieldTypeDescription
idintTrade ID
market_idstrMarket ID
buyerstrBuyer address
sellerstrSeller address
priceintExecution price (6 decimals)
sizeintExecution size (6 decimals)
outcomeint0 = YES, 1 = NO
timestampintExecution timestamp
tx_hashstrSettlement transaction hash

Position Types

Position

A user's position in a market.

FieldTypeDescription
idintPosition ID
market_idstrMarket ID
user_addressstrUser address
yes_sharesintYES token balance (6 decimals)
no_sharesintNO token balance (6 decimals)
yes_costintUSDC spent on YES (6 decimals)
no_costintUSDC spent on NO (6 decimals)
yes_revenueintUSDC received from YES sales (6 decimals)
no_revenueintUSDC received from NO sales (6 decimals)
total_investedintTotal USDC invested (6 decimals)
total_costintTotal USDC cost (6 decimals)
total_revenueintTotal USDC revenue (6 decimals)
last_updatedintLast sync timestamp

Holder

A top holder in a market. Returned by client.get_holders().

FieldTypeDescription
user_addressstrHolder address
yes_sharesintYES token balance (6 decimals)
no_sharesintNO token balance (6 decimals)
total_investedintTotal USDC invested (6 decimals)

User Types

UserActivity

Trading activity summary. Returned by client.get_user_activity().

FieldTypeDescription
addressstrUser address
total_tradesintTotal number of trades
total_volumeintTotal volume (6 decimals)
pnlintProfit/Loss (6 decimals)
markets_tradedintNumber of markets traded

UserStats

User portfolio statistics. Returned by client.get_user_stats().

FieldTypeDescription
user_addressstrUser address
total_costintTotal USDC spent (6 decimals)
total_investedintTotal USDC invested (6 decimals)
position_valueintCurrent position value (6 decimals)
pnlintProfit/Loss (6 decimals)
pnl_percentagefloatPNL as a percentage

Platform Types

PlatformStats

Platform-wide statistics. Returned by client.get_platform_stats().

FieldTypeDescription
chainslist[ChainStats]Per-chain statistics
total_volumeintTotal volume across all chains (6 decimals)
total_tradesintTotal trades across all chains

ChainStats

FieldTypeDescription
chain_idintChain ID
total_volumeintTotal volume (6 decimals)
total_tradesintTotal trades
updated_atintLast update timestamp

AssetPrice

Current price for an asset. Returned by client.get_quick_market_price().

FieldTypeDescription
pricefloatPrice in smallest units (divide by 1e8 for dollars)
timestampintPrice timestamp

Settlement Tracking Types

FailedTrade

FieldTypeDescription
market_idstrMarket ID
tx_hashstrTransaction hash
buyer_addressstrBuyer address
seller_addressstrSeller address
fill_sizeintFill size (6 decimals)
fill_priceintFill price (6 decimals)
reasonstrFailure reason
timestampstrFailure timestamp
batch_indexintBatch index

PendingTrade

FieldTypeDescription
market_idstrMarket ID
tx_hashstrTransaction hash
buyer_addressstrBuyer address
seller_addressstrSeller address
fill_sizeintFill size (6 decimals)
fill_priceintFill price (6 decimals)
timestampstrSubmission timestamp
is_batchboolWhether part of a batch
batch_indexintBatch index

FailedClaim / PendingClaim

FieldTypeDescription
tx_hashstrTransaction hash
user_addressstrUser address
market_addressstrMarket contract address
market_idstrMarket ID
payoutintExpected payout (6 decimals)
winning_outcomeintWinning outcome
submitted_atintSubmission timestamp

SettlementStatus

FieldTypeDescription
foundboolWhether the transaction was found
tx_hashstrTransaction hash
statusstrSettlement status
errorstrError message (empty if successful)
market_idstrMarket ID
buyer_addressstrBuyer address
seller_addressstrSeller address
fill_sizeintFill size (6 decimals)
fill_priceintFill price (6 decimals)
timestampstrTimestamp
is_batchboolWhether part of a batch
batch_indexintBatch index

WebSocket Message Types

WSMessage

Base WebSocket message. All other message types inherit from this.

FieldTypeDescription
typestrMessage type ("orderbook", "trade", "quick_market", "order_cancelled")
market_idstr | NoneAssociated market ID
dataAnyRaw message data

OrderBookUpdate

Extends WSMessage. Has an orderbook property that returns OrderBookSnapshot or None.

TradeUpdate

Extends WSMessage. Has a trade property that returns Trade or None.

QuickMarketUpdate

Extends WSMessage. Has a quick_market property that returns QuickMarket or None.

Helper Functions

Available from turbine_client.order_builder.helpers:

from turbine_client.order_builder.helpers import (
    price_to_decimal,   # 500000 → Decimal('0.5')
    decimal_to_price,   # 0.5 → 500000
    size_to_shares,     # 1000000 → Decimal('1')
    shares_to_size,     # 1.5 → 1500000
    calculate_cost,     # cost = price * size / 1e6
    calculate_payout,   # payout = size (winners get 1:1)
    calculate_profit,   # profit = payout - cost
    validate_price,     # raises OrderValidationError
    validate_size,      # raises OrderValidationError
    round_price_down,   # round to tick size
    round_price_up,     # round to tick size
    round_size_down,    # round to minimum increment
)

Examples

from turbine_client.order_builder.helpers import (
    calculate_cost, calculate_profit, price_to_decimal, decimal_to_price
)

# Cost of buying 10 shares at $0.45
cost = calculate_cost(450000, 10000000)  # 4500000 = $4.50 USDC

# Profit if the bet wins
profit = calculate_profit(450000, 10000000)  # 5500000 = $5.50 USDC

# Price conversions
price_to_decimal(750000)   # Decimal('0.75')
decimal_to_price(0.33)     # 330000