Documentation v1.0.4

Documentation

Master the SDKTrader ecosystem. From HFT adapters to global deployment — we've got you covered.

Introduction

SDKTrader is a performance-first trading infrastructure built for professional quant teams. We provide the building blocks for elite trading bots: unified exchange connectivity, deterministic backtesting, and production-grade monitoring.

Modular

Pick only the services you need.

Unified

One API for 10+ exchanges.

Fast

Native Rust & Python cores.

Supported Exchanges

SDKTrader provides native, high-performance connectivity to a wide range of exchanges and data providers.

binance
bingx
bitget
bybit
gate
hyperliquid
mexc
mod
okx
private_ws
xt

Use these strings as the `exchange` parameter when initializing the SDK or specific adapters. For example: `exchange="binance"`.

Getting Started

SDKTrader is available as a native package for both Python and Rust. Choose your weapon and install our core library.

Installation

Bash (Python)
pip install sdktrader
Bash (Rust)
cargo add sdktrader

SDKTrader Core

The `SDKTrader` class is your unified entry point. It manages exchange authentication, rate limits, and provides access to all sub-services.

Python
from sdktrader import SDKTrader

# Initialize the unified SDK
sdk = SDKTrader(
    api_key="...",
    api_secret="...",
    exchange="binance"
)

# Shared accounting access
balance = sdk.accounting.get_balance()
print(f"Current Balance: {balance.total} USDT")

HFT Adapters

For latency-sensitive strategies, use our native HFT adapters. These are written in Rust and exposed with zero-cost abstractions for maximum performance.

Rust
use sdktrader::prelude::*;

#[tokio::main]
async fn main() -> Result<()> {
    // Ultra-low latency engine initialization
    let mut engine = HFTEngine::new(Exchange::Bybit)?;
    
    // Direct WebSocket feed handler
    engine.subscribe(Channel::Tickers("BTCUSDT")).await?;
    
    while let Some(tick) = engine.next_tick().await {
        println!("New Tick: {} @ {}", tick.symbol, tick.price);
    }
    
    Ok(())
}

History data API

Query billions of normalized market data points. Our API handles all the heavy lifting, including data normalization across different exchange formats.

Python
history = sdk.history()

# Get tick-by-tick data for the last hour
ticks = history.get_ticks(
    symbol="BTC/USDT",
    limit=1000,
    normalized=True
)

for tick in ticks:
    print(f"{tick.timestamp}: {tick.price}")

Realtime data API

Subscribe to unified real-time streams for market depth, trades, and account events. Our WebSocket gateway handles reconnection and state recovery automatically.

Python
# Subscribe to multiple symbols
@sdk.realtime.on_tick("BTC/USDT", "ETH/USDT")
def on_price_update(tick):
    print(f"Update: {tick.symbol} is now {tick.price}")

# Listen for private account events
@sdk.realtime.on_order_update
def on_order(order):
    print(f"Order {order.id} status: {order.status}")

sdk.realtime.start()

Backtesting Engine

High-fidelity event-driven simulation. Test your strategies using tick-accurate historical data with realistic slippage and fee models.

Python
from sdktrader.backtest import Backtest

# Define your strategy
class MyStrategy(Strategy):
    def on_tick(self, tick):
        if self.position.none:
            self.buy(amount=0.1)

# Run simulation
bt = Backtest(
    strategy=MyStrategy(),
    feed="history_tick_data",
    fee_rate=0.0001,
    slippage=0.05
)

results = bt.run(start="2024-01-01", end="2024-02-01")
print(f"Final PnL: {results.total_pnl}%")

SDKProxy scaling

Scalable proxy infrastructure for high-concurrency requests. Automatically handles rotation, retries, and geographic targeting.

Python
from sdktrader import SDKProxy

# Initialize proxy scaler
proxy = SDKProxy(
    rotation="sticky",
    region="us-east",
    concurrency=100
)

# Use with any request library
proxies = proxy.get_config()
response = requests.get("https://api.exchange.com", proxies=proxies)

SDKRouter AI

Unified interface for 300+ AI models. Native Pydantic integration for structured data extraction and browser-based research.

Python
from pydantic import BaseModel, Field
from sdkrouter import SDKRouter

class MathSolution(BaseModel):
    steps: list[dict] = Field(description="Solution steps")
    final_answer: float = Field(description="The final answer")

client = SDKRouter()
result = client.parse(
    model="openai/gpt-4o",
    messages=[
        {"role": "system", "content": "You are a math tutor."},
        {"role": "user", "content": "Solve: 3x + 7 = 22"},
    ],
    response_format=MathSolution,
)

solution = result.choices[0].message.parsed
print(f"Answer: x = {solution.final_answer}")
AI Search & Research

Use `client.search()` to perform deep research across the web with LLM-based ranking and entity extraction for your trading signals.

Bot Examples

Kickstart your development with these simple, production-ready bot templates.

Example 1: Simple Market Maker (Python)

Places buy/sell orders around the mid-price to capture the spread.

Python
from sdktrader import SDKTrader
import time

sdk = SDKTrader(exchange="binance")

def run_mm():
    while True:
        ticker = sdk.markets.get_ticker("BTC/USDT")
        mid = (ticker.bid + ticker.ask) / 2
        
        # Place orders 0.1% away from mid
        sdk.orders.create_limit_buy("BTC/USDT", price=mid * 0.999, amount=0.001)
        sdk.orders.create_limit_sell("BTC/USDT", price=mid * 1.001, amount=0.001)
        
        time.sleep(10)

Example 2: SMA Crossover (Rust)

Executes trades based on simple moving average intersections.

Rust
use sdktrader::prelude::*;

async fn strategy_loop() -> Result<()> {
    let sdk = SDKTrader::new(Exchange::Binance).await?;
    let mut history = sdk.history();

    loop {
        let candles = history.get_candles("BTCUSDT", "1h", 100);
        let sma50 = candles.sma(50);
        let sma20 = candles.sma(20);

        if sma20 > sma50 {
            sdk.orders.market_buy("BTCUSDT", 0.1).await?;
        } else if sma20 < sma50 {
            sdk.orders.market_sell("BTCUSDT", 0.1).await?;
        }
        
        tokio::time::sleep(Duration::from_secs(3600)).await;
    }
}

UnrealON Monitoring

Register your running bots with UnrealON to get real-time health checks, performance metrics, and remote control capabilities.

Remote Registration

UnrealON automatically detects your bot's environment and performance metrics, sending them to your private dashboard.

Python
from sdktrader.unrealon import Agent

# Auto-register this instance
agent = Agent(name="MarketMaker-1")
agent.start_heartbeat()

# Log custom performance metrics
agent.log_metric("latency_ms", 12.5)
agent.log_status("TRADING_ACTIVE")

Next Section

Getting Started

Still need help?

Contact Support