Skip to content

ScaleTrade/server-api-net

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

scaletrade-server-api-net

Ultra‑low latency .NET TCP client for ScaleTrade
Real‑time market data, trade execution, balance & user management via TCP.

NuGet .NET License Downloads

Server‑to‑Server (S2S) integration — perfect for brokers, CRMs, HFT bots, back‑office systems.

Documentation · Examples · Report Bug


Features

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

Installation

Clone:

git clone https://github.com/scaletrade/server-api-net
cd server-api-net
dotnet build

OR

dotnet add package ScaleTrade.ServerApi

Run example:

dotnet run --project examples/ConsoleExample

Quick Start

using 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();

Supported Events

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], ...]

Methods

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

Examples

Subscribe & Unsubscribe

await platform.SubscribeAsync("GBPUSD", "USDJPY");
await platform.UnsubscribeAsync("BTCUSD");

Get All Users

var users = await platform.Command.GetUsers(new { });
Console.WriteLine(users);

Listen to Balance Changes

platform.BalanceEvent += (s, e) =>
    Console.WriteLine($"User {e.Data["login"]}: Equity = {e.Data["equity"]}");

Full Example

See examples/ConsoleExample/Program.cs


Configuration

Option Type Default Description
autoSubscribe List<string> [] Auto‑subscribe on connect
ignoreEvents bool false Disable all event emission
mode string "live" Environment mode

Documentation


Requirements

  • .NET 8.0 or higher
  • Valid ScaleTrade JWT token

License

Distributed under the MIT License.
See LICENSE for more information.


Made with passion for high‑frequency trading

scaletrade.com · GitHub

About

Server API for #C

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages