JKorf / Binance.Net

A C# .netstandard client library for the Binance REST and Websocket Spot and Futures API focusing on clear usage and models
https://jkorf.github.io/Binance.Net/
MIT License
1.03k stars 425 forks source link

Binance Futures trade stream #1218

Closed CodeForAlex closed 1 year ago

CodeForAlex commented 1 year ago

Hello and thanks for taking time to develop such a great project.

Recently I was wondering why Binance spot streams have raw trade option and Futures have only aggregated trades. After some searching it turned out Binance actually have raw trade streams and it is confirmed by checking their market data archive.

For example, here is daily trades data for BTCUSDT futures pair: https://data.binance.vision/?prefix=data/futures/um/daily/trades/BTCUSDT/ And it is obvious that data is more detailed than for aggregated streams: https://data.binance.vision/?prefix=data/futures/um/daily/aggTrades/BTCUSDT/

I understand that official API docs don't describe how to get raw trades stream, but my tests shown that it is very easy to do. Basically all I've done is used BinanceSocketClient.SpotStreams.SubscribeToTradeUpdatesAsync() Then replaced websocket base url from "wss://stream.binance.com:9443/" to "wss://fstream.binance.com/" And all data comming to handler was from futures pair.

Data format is similar:

{
  "e":"trade",
  "E":1679851564490,
  "T":1679851564486,
  "s":"BTCUSDT",
  "t":3493102749,
  "p":"27785.00",
  "q":"0.014",
  "X":"MARKET",
  "m":true
}

Just not sure what "X" means here, because it is usually referred as "Order Status" in docs.

All this info leads me to conclusion that raw futures trade handling can be added to library. Is it something that potentially will be added with next releases?

Thanks.

JKorf commented 1 year ago

I've added it in with a notice that it is not officially documented