Overview
Turbine is a gasless prediction markets platform where you trade on whether BTC will go up or down in the next 15 minutes. Every 15 minutes, a new market opens with a simple question like: “Will BTC be above $97,250 at 3:15 PM?” You buy shares representing your prediction:- YES shares pay $1.00 if BTC finishes above the strike price
- NO shares pay $1.00 if BTC finishes below the strike price
Prerequisites
- Python 3.9 or higher
- An Ethereum-compatible wallet
- USDC on Polygon mainnet (~$10 minimum)
git clone https://github.com/ojo-network/turbine-py-client.git
cd turbine-py-client
python3 -m venv .venv && source .venv/bin/activate
pip install -e .
from eth_account import Account
acct = Account.create()
print(f"Address: {acct.address}")
print(f"Private Key: {acct.key.hex()}")
# SAVE THESE SECURELY!
No native gas tokens (MATIC) are needed! Turbine is fully gasless - all operations are routed through the API’s relayer.
API credentials (
TURBINE_API_KEY_ID and TURBINE_API_PRIVATE_KEY) are generated automatically on first run.import os
import time
from dotenv import load_dotenv
from turbine_client import TurbineClient, Outcome, Side
# Load environment variables
load_dotenv()
# Initialize client
client = TurbineClient(
host="https://api.turbinefi.com",
chain_id=137, # Polygon mainnet
private_key=os.getenv("TURBINE_PRIVATE_KEY"),
)
print(f"Connected as: {client.address}")
# Get the current BTC quick market
market = client.get_quick_market("BTC")
print(f"\nMarket: {market.question}")
print(f"Strike Price: ${market.start_price / 1e6:,.2f}")
print(f"Expires: {time.strftime('%H:%M:%S', time.localtime(market.end_time))}")
# Check the current orderbook
orderbook = client.get_orderbook(market.market_id)
if orderbook.bids:
best_bid = orderbook.bids[0].price / 10000
print(f"\nBest YES bid: {best_bid:.2f}%")
if orderbook.asks:
best_ask = orderbook.asks[0].price / 10000
print(f"Best YES ask: {best_ask:.2f}%")
# Place a limit buy order for YES shares at 45%
order = client.create_limit_buy(
market_id=market.market_id,
outcome=Outcome.YES,
price=450000, # 45% (price scaled by 1e6)
size=2_000_000, # 2 shares (6 decimals)
)
print(f"\nOrder created: {order.order_hash}")
# Submit the order
result = client.post_order(order)
print(f"Order submitted!")
print(f" Order hash: {result['orderHash']}")
print(f" Status: {result.get('status', 'pending')}")
# Clean up
client.close()
Connected as: 0x1234...
Market: Will BTC be above $97,250 at 15:15:00?
Strike Price: $97,250.00
Expires: 15:15:00
Best YES bid: 48.50%
Best YES ask: 51.20%
Order created: 0xabcd...
Order submitted!
Order hash: 0xabcd...
Status: pending
from turbine_client import TurbineClient
import os
from dotenv import load_dotenv
load_dotenv()
client = TurbineClient(
host="https://api.turbinefi.com",
chain_id=137,
private_key=os.getenv("TURBINE_PRIVATE_KEY"),
)
# Get your open orders
orders = client.get_orders(trader=client.address)
print(f"Open orders for {client.address}:")
for order in orders:
price_pct = order.price / 10000
shares = order.size / 1_000_000
filled = order.filled_size / 1_000_000
side = "BUY" if order.side == 0 else "SELL"
outcome = "YES" if order.outcome == 0 else "NO"
print(f"\n {order.order_hash[:10]}...")
print(f" {side} {shares:.2f} {outcome} @ {price_pct:.2f}%")
print(f" Filled: {filled:.2f} / {shares:.2f}")
print(f" Status: {order.status}")
client.close()
Understanding Price and Size
Price Representation
Prices in Turbine are scaled by 1,000,000 (1e6):500000= 50% (even odds)250000= 25%750000= 75%- Range: 1 to 999,999
Size (Shares)
Sizes are also scaled by 1,000,000 (6 decimals):1_000_000= 1 share10_000_000= 10 shares
Order Cost
The cost of an order in USDC is:- Buying 2 shares at 45% =
(2_000_000 × 450000) / 1e12= $0.90 USDC
Canceling Orders
If you want to cancel an order before it fills:Next Steps
Congratulations! You’ve placed your first trade on Turbine. Here’s what to explore next:Build a Trading Bot
Learn how to automate your trading with a bot
Market Data
Access orderbooks, trades, and statistics
WebSocket Streams
Get real-time market updates via WebSocket
Claim Winnings
Learn how to claim from resolved markets
Troubleshooting
”Insufficient allowance” Error
You need to approve USDC for the settlement contract. This is a one-time gasless operation:“Order rejected” Error
Check these common issues:- Order size too small (minimum $1 for taker orders)
- Insufficient USDC balance
- Price outside valid range (1 to 999,999)
- Market has expired
”Invalid signature” Error
Make sure yourTURBINE_PRIVATE_KEY is correctly formatted:
- Must start with
0x - Must be 64 hexadecimal characters long (66 total with
0x)
Reference
API Reference
Complete SDK documentation
Example Code
Browse example scripts on GitHub