Automation / API
Python & Rust SDKs for live trading, streaming data, and order workflows.
Build strategies with a feature‑rich yet simple API. Initialize a client, subscribe to symbols and topics like trades and BBO, and implement your logic via callbacks. Order routing, heartbeats, auto‑reconnects, and consistent models are all handled for you.
Python
from insticryp import InstiCryp as ic, Topic
client = ic(
api_key="YOUR_API_KEY",
http_url="https://api.insticryp.com",
ws_url="wss://ws.insticryp.com",
)
def on_trade(trade):
# trade: { symbol, venue, px, qty, ts }
print(f"TRADE {trade['symbol']} @ {trade['px']} x {trade['qty']}")
def on_bbo(bbo):
# bbo: { symbol, venue, bid_px, ask_px, ts }
mid = (float(bbo['bid_px']) + float(bbo['ask_px'])) / 2
print(f"BBO {bbo['symbol']} bid={bbo['bid_px']} ask={bbo['ask_px']} mid={mid:.2f}")
# Init + subscribe
client.subscribe(
symbol="BTCUSDT",
topics=[Topic.TRADES, Topic.BBO],
on_trade=on_trade,
on_bbo=on_bbo,
)
# Simple strategy: route market order on mid-cross
def on_signal(side: str, qty: float):
client.place_order(
venue="BINANCE_SPOT",
symbol="BTCUSDT",
side=side,
qty=str(qty),
order_type="Market",
destination="SOR",
)
client.run() # blocks; handles reconnects & heartbeats
Rust
use insticryp::{Client, Subscribe, Topic, OrderType};
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let mut client = Client::new(
std::env::var("API_KEY")?,
"https://api.insticryp.com",
"wss://ws.insticryp.com",
);
client.on_trade(|t| {
println!("TRADE {} @ {} x {}", t.symbol, t.px, t.qty);
});
client.on_bbo(|q| {
let mid = (q.bid_px + q.ask_px) / 2.0;
println!("BBO {} bid={} ask={} mid={}", q.symbol, q.bid_px, q.ask_px, mid);
});
client.subscribe(Subscribe::new()
.symbol("BTCUSDT")
.topics(&[Topic::Trades, Topic::Bbo]));
// Example: place a market order
client.place_order()
.venue("BINANCE_SPOT")
.symbol("BTCUSDT")
.side("B")
.qty("0.002")
.order_type(OrderType::Market)
.destination("SOR")
.send()
.await?;
client.run().await
}
Python — Basket Trading (CSV)
# Basket from CSV using place_baset (bulk submit)
import csv
from insticryp import InstiCryp as ic
client = ic(api_key="YOUR_API_KEY",
http_url="https://api.insticryp.com",
ws_url="wss://ws.insticryp.com")
with open("basket.csv") as f:
rows = list(csv.DictReader(f))
# Build a list of order dicts and submit once
orders = [
{
"venue": r.get("venue", "BINANCE_SPOT"),
"symbol": r["symbol"],
"side": r["side"], # "B" or "S"
"qty": r["qty"], # string
"order_type": r.get("type", "Market"),
"destination": r.get("destination", "SOR"),
}
for r in rows
]
client.place_baset(orders=orders)
client.run()
Rust — Basket Trading
// Basket using place_baset (bulk submit)
use insticryp::{Client, OrderType};
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let client = Client::new(
std::env::var("API_KEY")?,
"https://api.insticryp.com",
"wss://ws.insticryp.com",
);
// Each order: (venue, symbol, side, qty, order_type, destination)
let orders = vec![
("BINANCE_SPOT", "BTCUSDT", "B", "0.005", OrderType::Market, "SOR"),
("BINANCE_SPOT", "ETHUSDT", "S", "0.10", OrderType::Market, "SOR"),
];
client.place_baset(orders).await?;
Ok(())
}
Want early access to the SDKs and full docs? Email us at contact@insticryp.com