sgcWebSockets .NET Exchange Feeds
Twenty-five components that speak the WebSocket feed of a trading venue, one per
exchange. They handle the venue's own subscribe grammar, its authentication and
its reconnect replay, so the application deals in typed events instead of JSON.
Like every protocol component in this library, none of them owns a socket. Each
attaches to a TsgcWebSocketClient through Client, and the client is what
connects. Read sgcwebsockets-dotnet first for that and for the threading rule.
When to use this skill
- Stream tickers, trades, candles or an order book from a crypto exchange
- Subscribe to a private user stream: balances, orders, fills
- Place or cancel orders through an exchange REST API alongside the feed
- Stream forex prices
Components in this skill
| Venue |
Component |
| Binance |
TsgcWSAPI_Binance, TsgcWSAPI_Binance_Futures |
| Kraken |
TsgcWSAPI_Kraken, TsgcWSAPI_Kraken_Futures |
| Coinbase |
TsgcWSAPI_Coinbase |
| Bybit, OKX, Bitget, GateIO |
TsgcWSAPI_Bybit, TsgcWSAPI_OKX, TsgcWSAPI_Bitget, TsgcWSAPI_GateIO |
| Kucoin |
TsgcWSAPI_Kucoin, TsgcWSAPI_Kucoin_Futures |
| MEXC |
TsgcWSAPI_MEXC, TsgcWSAPI_MEXC_Futures |
| Huobi and HTX |
TsgcWSAPI_Huobi, TsgcWSAPI_HTX |
| Bitfinex, Bitstamp, Bitmex |
TsgcWSAPI_Bitfinex, TsgcWSAPI_Bitstamp, TsgcWSAPI_Bitmex |
| Crypto.com, Deribit, Cex |
TsgcWSAPI_CryptoCom, TsgcWSAPI_Deribit, TsgcWSAPI_Cex, TsgcWSAPI_CexPlus |
| 3Commas, XTB, Forex |
TsgcWSAPI_ThreeCommas, TsgcWSAPI_XTB, TsgcWSAPI_Forex |
Before you start, ask the developer
Use a structured question tool if your host has one, for example Claude Code's
AskUserQuestion. Otherwise ask in chat:
- Public data or private account data? Public feeds need nothing. Private
streams need an API key, and that changes what you build and what you must
not write into source.
- Spot or futures? They are separate components against separate endpoints.
TsgcWSAPI_Binance will not carry a futures stream.
- Which streams, and how many symbols? Every venue caps subscriptions per
connection. A watchlist of five hundred symbols is a design question, not a
loop.
- What happens on reconnect? The component replays subscriptions, but the
application still has to decide whether a gap in the book matters and
whether to resynchronise from the REST snapshot.
Quickstart, Binance
using esegece.sgcWebSockets;
var client = new TsgcWebSocketClient();
var binance = new TsgcWSAPI_Binance();
binance.Client = client; // the socket lives on the client
client.OnConnect += (TsgcWSConnection connection) =>
{
binance.SubscribeTicker("BTCUSDT");
binance.SubscribeKLine("BTCUSDT", TsgcWSBinanceChartIntervals.bci1m);
};
client.Active = true;
The subscribe methods return an int, the subscription id the venue assigned.
Keep it if you intend to unsubscribe later.
The candle interval is an enum, and its members are short: bci1m, bci5m,
bci1h, bci1d, bci1w, bci1Mo and the rest. There is no binance_1m. The
full list is on reference/types/TsgcWSBinanceChartIntervals.md, and it is
worth reading rather than guessing, because a wrong member is a compile error
and a plausible-looking wrong string is a silent empty stream.
Keys belong outside the source
A private stream needs an API key and secret. Put them in configuration, an
environment variable or a secret store, and read them at startup:
binance.Binance.ApiKey = Environment.GetEnvironmentVariable("BINANCE_API_KEY");
Never write a key into a source file, an example or a commit. A key in a
repository is a key that has to be rotated, and on an exchange account that is
not a theoretical cost.
Things that catch people out
Active exists on the API component and on the client. The client's is the
one that opens the socket.
- Symbols are venue-specific.
BTCUSDT on Binance, XBT/USD on Kraken,
BTC-USD on Coinbase. Passing one venue's spelling to another gets silence,
not an error.
- Most venues rate-limit subscriptions and disconnect on a burst. Subscribing
inside
OnConnect in a tight loop over a large watchlist is the usual way to
be disconnected immediately after connecting.
- The REST side lives on
REST_API, a separate object with its own
authentication. The WebSocket key is not automatically the REST key.
- A venue changing its API is normal.
reference/history.md in the
sgcwebsockets-dotnet skill records which release followed which change, and
it is the first place to look when a feed stops matching the documentation.
- Exchange components move faster than most of the library. If a venue has
shipped a v2 protocol, check the components index before assuming the
existing component covers it.
Routing
- API detail:
reference/api/<Component>.md has the properties, events and methods, each with its C# signature.
- Option / enum / delegate types: property and event types link to
reference/types/<TypeName>.md.
- Examples:
examples/<Component>.md is a trimmed snippet from the shipped demo; examples/index.md maps every component to its demo.
- Getting started:
concepts/overview.md covers the single using, the target frameworks and the naming.
What is documented
Public instance properties, events and methods declared anywhere in the
library's own class chain. Members inherited from the .NET base classes are
left out, as are internals, so a page shows the surface a caller writes
against and nothing else.
If a component you need is not here, read concepts/coverage.md in the
sgcwebsockets-dotnet skill before assuming a different name for it.
This assembly carries fewer components than the Delphi library, and saying
so is more useful than guessing an API that does not exist.
1---2name: sgcwebsockets-dotnet-exchanges3description: sgcWebSockets .NET Exchange Feeds4---56# sgcWebSockets .NET Exchange Feeds78Twenty-five components that speak the WebSocket feed of a trading venue, one per9exchange. They handle the venue's own subscribe grammar, its authentication and10its reconnect replay, so the application deals in typed events instead of JSON.1112Like every protocol component in this library, none of them owns a socket. Each13attaches to a `TsgcWebSocketClient` through `Client`, and the client is what14connects. Read `sgcwebsockets-dotnet` first for that and for the threading rule.1516## When to use this skill1718- Stream tickers, trades, candles or an order book from a crypto exchange19- Subscribe to a private user stream: balances, orders, fills20- Place or cancel orders through an exchange REST API alongside the feed21- Stream forex prices2223## Components in this skill2425| Venue | Component |26| --- | --- |27| Binance | `TsgcWSAPI_Binance`, `TsgcWSAPI_Binance_Futures` |28| Kraken | `TsgcWSAPI_Kraken`, `TsgcWSAPI_Kraken_Futures` |29| Coinbase | `TsgcWSAPI_Coinbase` |30| Bybit, OKX, Bitget, GateIO | `TsgcWSAPI_Bybit`, `TsgcWSAPI_OKX`, `TsgcWSAPI_Bitget`, `TsgcWSAPI_GateIO` |31| Kucoin | `TsgcWSAPI_Kucoin`, `TsgcWSAPI_Kucoin_Futures` |32| MEXC | `TsgcWSAPI_MEXC`, `TsgcWSAPI_MEXC_Futures` |33| Huobi and HTX | `TsgcWSAPI_Huobi`, `TsgcWSAPI_HTX` |34| Bitfinex, Bitstamp, Bitmex | `TsgcWSAPI_Bitfinex`, `TsgcWSAPI_Bitstamp`, `TsgcWSAPI_Bitmex` |35| Crypto.com, Deribit, Cex | `TsgcWSAPI_CryptoCom`, `TsgcWSAPI_Deribit`, `TsgcWSAPI_Cex`, `TsgcWSAPI_CexPlus` |36| 3Commas, XTB, Forex | `TsgcWSAPI_ThreeCommas`, `TsgcWSAPI_XTB`, `TsgcWSAPI_Forex` |3738## Before you start, ask the developer3940Use a structured question tool if your host has one, for example Claude Code's41`AskUserQuestion`. Otherwise ask in chat:42431. **Public data or private account data?** Public feeds need nothing. Private44 streams need an API key, and that changes what you build and what you must45 not write into source.462. **Spot or futures?** They are separate components against separate endpoints.47 `TsgcWSAPI_Binance` will not carry a futures stream.483. **Which streams, and how many symbols?** Every venue caps subscriptions per49 connection. A watchlist of five hundred symbols is a design question, not a50 loop.514. **What happens on reconnect?** The component replays subscriptions, but the52 application still has to decide whether a gap in the book matters and53 whether to resynchronise from the REST snapshot.5455## Quickstart, Binance5657```csharp58using esegece.sgcWebSockets;5960var client = new TsgcWebSocketClient();6162var binance = new TsgcWSAPI_Binance();63binance.Client = client; // the socket lives on the client6465client.OnConnect += (TsgcWSConnection connection) =>66{67 binance.SubscribeTicker("BTCUSDT");68 binance.SubscribeKLine("BTCUSDT", TsgcWSBinanceChartIntervals.bci1m);69};7071client.Active = true;72```7374The subscribe methods return an int, the subscription id the venue assigned.75Keep it if you intend to unsubscribe later.7677The candle interval is an enum, and its members are short: `bci1m`, `bci5m`,78`bci1h`, `bci1d`, `bci1w`, `bci1Mo` and the rest. There is no `binance_1m`. The79full list is on `reference/types/TsgcWSBinanceChartIntervals.md`, and it is80worth reading rather than guessing, because a wrong member is a compile error81and a plausible-looking wrong string is a silent empty stream.8283## Keys belong outside the source8485A private stream needs an API key and secret. Put them in configuration, an86environment variable or a secret store, and read them at startup:8788```csharp89binance.Binance.ApiKey = Environment.GetEnvironmentVariable("BINANCE_API_KEY");90```9192Never write a key into a source file, an example or a commit. A key in a93repository is a key that has to be rotated, and on an exchange account that is94not a theoretical cost.9596## Things that catch people out9798- `Active` exists on the API component and on the client. The client's is the99 one that opens the socket.100- Symbols are venue-specific. `BTCUSDT` on Binance, `XBT/USD` on Kraken,101 `BTC-USD` on Coinbase. Passing one venue's spelling to another gets silence,102 not an error.103- Most venues rate-limit subscriptions and disconnect on a burst. Subscribing104 inside `OnConnect` in a tight loop over a large watchlist is the usual way to105 be disconnected immediately after connecting.106- The REST side lives on `REST_API`, a separate object with its own107 authentication. The WebSocket key is not automatically the REST key.108- A venue changing its API is normal. `reference/history.md` in the109 `sgcwebsockets-dotnet` skill records which release followed which change, and110 it is the first place to look when a feed stops matching the documentation.111- Exchange components move faster than most of the library. If a venue has112 shipped a v2 protocol, check the components index before assuming the113 existing component covers it.114115## Routing116117- **API detail**: `reference/api/<Component>.md` has the properties, events and methods, each with its C# signature.118- **Option / enum / delegate types**: property and event types link to `reference/types/<TypeName>.md`.119- **Examples**: `examples/<Component>.md` is a trimmed snippet from the shipped demo; `examples/index.md` maps every component to its demo.120- **Getting started**: `concepts/overview.md` covers the single `using`, the target frameworks and the naming.121122## What is documented123124Public instance properties, events and methods declared anywhere in the125library's own class chain. Members inherited from the .NET base classes are126left out, as are internals, so a page shows the surface a caller writes127against and nothing else.128129If a component you need is not here, read `concepts/coverage.md` in the130`sgcwebsockets-dotnet` skill before assuming a different name for it.131This assembly carries fewer components than the Delphi library, and saying132so is more useful than guessing an API that does not exist.