Skip to main content
Kuest provides official SDKs for building automated trading bots in Python and Rust. These SDKs handle authentication, order management, and market data retrieval.
The SDKs are currently in beta and available for Polygon Amoy testnet. Mainnet support coming soon.

Available SDKs

Python SDK

High-level Python library for rapid development

Rust SDK

Low-latency Rust implementation for HFT strategies

Python SDK

Installation

pip install kuest-sdk

Quick start

from kuest import KuestClient

# Initialize client with API credentials
client = KuestClient(
    api_key="your-api-key",
    api_secret="your-api-secret",
    passphrase="your-passphrase",
    testnet=True  # Use Polygon Amoy
)

# Fetch available markets
markets = client.get_markets()

# Place a limit order
order = client.place_order(
    market_id="0x123...",
    outcome="YES",
    side="BUY",
    price=0.65,
    size=10.0
)

print(f"Order placed: {order.id}")

Advanced features

# Subscribe to real-time price updates
def on_price_update(market_id, price):
    print(f"Market {market_id} price: {price}")

client.subscribe_prices(["0x123...", "0x456..."], on_price_update)
# Get current positions
positions = client.get_positions()

for position in positions:
    print(f"{position.market}: {position.size} @ {position.avg_price}")
    print(f"Unrealized PnL: ${position.unrealized_pnl}")
# Fetch order book depth
orderbook = client.get_orderbook("0x123...")

best_bid = orderbook.bids[0]
best_ask = orderbook.asks[0]
spread = best_ask.price - best_bid.price

print(f"Spread: {spread:.4f}")

Rust SDK

Installation

Add to your Cargo.toml:
[dependencies]
kuest-sdk = "0.1"
tokio = { version = "1", features = ["full"] }

Quick start

use kuest_sdk::{KuestClient, OrderSide, OrderType};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Initialize client
    let client = KuestClient::new(
        "your-api-key",
        "your-api-secret",
        "your-passphrase",
        true, // testnet
    )?;

    // Fetch markets
    let markets = client.get_markets().await?;

    // Place order
    let order = client
        .place_order(
            "0x123...",
            OrderSide::Buy,
            OrderType::Limit,
            0.65,
            10.0,
        )
        .await?;

    println!("Order placed: {}", order.id);
    Ok(())
}

Performance features

The Rust SDK uses async/await for non-blocking I/O and supports connection pooling for minimal latency.
  • Zero-copy deserialization with serde
  • WebSocket support for real-time updates
  • Batch order submission
  • Custom retry policies

Common use cases

Market making bot

import time
from kuest import KuestClient

client = KuestClient(...)

def market_make(market_id, spread=0.02, size=5.0):
    """Place buy and sell orders around mid-price"""
    orderbook = client.get_orderbook(market_id)
    mid_price = (orderbook.best_bid + orderbook.best_ask) / 2
    
    # Place buy order
    client.place_order(
        market_id=market_id,
        side="BUY",
        price=mid_price - spread / 2,
        size=size
    )
    
    # Place sell order
    client.place_order(
        market_id=market_id,
        side="SELL",
        price=mid_price + spread / 2,
        size=size
    )

while True:
    market_make("0x123...")
    time.sleep(60)  # Update every minute

Arbitrage bot

def check_arbitrage(market_id):
    """Check for arbitrage opportunities"""
    orderbook = client.get_orderbook(market_id)
    
    yes_price = orderbook.asks[0].price  # Buy YES
    no_price = orderbook.asks[0].price   # Buy NO
    
    # YES + NO should equal 1.0
    # If sum < 1.0, arbitrage opportunity exists
    if yes_price + no_price < 0.98:
        print(f"Arbitrage detected! Sum: {yes_price + no_price}")
        # Execute arbitrage trade

Momentum trading bot

import pandas as pd

def momentum_strategy(market_id, lookback=60):
    """Trade based on recent price momentum"""
    # Fetch price history
    prices = client.get_price_history(
        market_id=market_id,
        interval="1m",
        limit=lookback
    )
    
    df = pd.DataFrame(prices)
    df['returns'] = df['price'].pct_change()
    
    # Calculate momentum
    momentum = df['returns'].tail(10).mean()
    
    if momentum > 0.01:  # Strong upward momentum
        client.place_order(market_id, "BUY", price=0.7, size=10)
    elif momentum < -0.01:  # Strong downward momentum
        client.place_order(market_id, "SELL", price=0.3, size=10)

Best practices

1

Use testnet first

Always test your bot on Polygon Amoy before deploying to mainnet.
2

Implement risk management

Set maximum position sizes, daily loss limits, and stop-loss orders.
3

Handle errors gracefully

Implement retry logic with exponential backoff for network errors.
4

Monitor performance

Track bot metrics: win rate, PnL, fill rate, and latency.
5

Secure credentials

Store API keys in environment variables, never hardcode them.

SDK reference

For complete API documentation, visit:

Python SDK docs

Full Python SDK reference

Rust SDK docs

Full Rust SDK reference

Next steps

Arbitrage strategies

Learn about cross-market arbitrage

API reference

Explore raw API endpoints

Build docs developers (and LLMs) love