Ultra‑low latency .NET TCP client for ScaleTrade
Real‑time market data, trade execution, balance & user management via TCP.
Server‑to‑Server (S2S) integration — perfect for brokers, CRMs, HFT bots, back‑office systems.
| Feature | Description |
|---|---|
| TCP S2S | Direct TCP – no HTTP overhead |
| Real‑time Events | Quotes, trades, balance, user & symbol updates |
| Optimized Subscribe | platform.SubscribeAsync(...) / UnsubscribeAsync(...) |
| Dynamic Commands | platform.Command.AddUser(...), platform.Command.GetTrades() |
| Auto‑reconnect | Robust reconnection with back‑off |
| Event Filtering | ignoreEvents, per‑symbol listeners |
| extID Tracking | Reliable command responses |
| JSON Repair | Handles malformed packets gracefully |
Clone:
git clone https://github.com/scaletrade/server-api-net
cd server-api-net
dotnet buildOR
dotnet add package ScaleTrade.ServerApiRun example:
dotnet run --project examples/ConsoleExampleusing ScaleTrade;
var platform = new STPlatform(
"broker.scaletrade.com:8080",
"my-trading-bot",
new() { ["autoSubscribe"] = new List<string> { "EURUSD", "BTCUSD" } },
token: "your-jwt-auth-token"
);
// Real‑time quotes
platform.Quote += (s, q) => Console.WriteLine($"{q.Symbol}: {q.Bid}/{q.Ask}");
// Trade events
platform.TradeEvent += (s, e) =>
{
var d = e.Data;
Console.WriteLine($"#{d["order"]} {(d["cmd"].Value<int>() == 0 ? "BUY" : "SELL")} {d["volume"]} {d["symbol"]}");
};
// Subscribe to a new symbol
await platform.SubscribeAsync("XAUUSD");
// Create user (dynamic proxy)
dynamic cmd = platform.Command;
await cmd.AddUser(new { name = "John Doe", group = "VIP", leverage = 500, email = "john@example.com" });
// Graceful shutdown
platform.Dispose();| Event | Description | Example |
|---|---|---|
Quote |
Real‑time tick | { Symbol: "EURUSD", Bid: 1.085, Ask: 1.086 } |
Quote (per‑symbol) |
Filter via if (q.Symbol == "EURUSD") |
— |
Notify |
System alerts | Notify:20 (warning) |
TradeEvent |
Order open/close/modify | Data.order, Data.profit |
BalanceEvent |
Balance & margin update | Data.equity, Data.margin_level |
UserEvent |
User profile change | Data.leverage, Data.group |
SymbolsReindex |
Symbol index map | [[symbol, sym_index, sort_index], ...] |
SecurityReindex |
Security group map | [[sec_index, sort_index], ...] |
| Method | Description |
|---|---|
SubscribeAsync(params string[] channels) |
Fast subscribe |
UnsubscribeAsync(params string[] channels) |
Fast unsubscribe |
platform.Command.CommandName(data) |
Dynamic command |
SendAsync(payload) |
Legacy format { command, data } |
Dispose() |
Close connection |
await platform.SubscribeAsync("GBPUSD", "USDJPY");
await platform.UnsubscribeAsync("BTCUSD");var users = await platform.Command.GetUsers(new { });
Console.WriteLine(users);platform.BalanceEvent += (s, e) =>
Console.WriteLine($"User {e.Data["login"]}: Equity = {e.Data["equity"]}");See examples/ConsoleExample/Program.cs
| Option | Type | Default | Description |
|---|---|---|---|
autoSubscribe |
List<string> |
[] |
Auto‑subscribe on connect |
ignoreEvents |
bool |
false |
Disable all event emission |
mode |
string |
"live" |
Environment mode |
- TCP API: https://scaletrade.com/tcp
- Client API: https://scaletrade.com/client-api
- FIX API: https://scaletrade.com/fix-api
- .NET 8.0 or higher
- Valid ScaleTrade JWT token
Distributed under the MIT License.
See LICENSE for more information.
Made with passion for high‑frequency trading