Search code examples
pythonbinance-api-client

How can I get trade buy/sell data of Binance?


I want to get real time trade buy/sell data of BTC via binance websocket.

I use this method in following websocket module:

URL: https://python-binance.readthedocs.io/en/latest/binance.html#module-binance.streams

method:aggtrade_futures_socket(symbol: str, futures_type: binance.enums.FuturesType = <FuturesType.USD_M: 1>)

This method return following value:

data:
{
"e": "aggTrade", // Event type
"E": 123456789, // Event time
"s": "BTCUSDT", // Symbol
"a": 5933014, // Aggregate trade ID
"p": "0.001", // Price
"q": "100", // Quantity
"f": 100, // First trade ID
"l": 105, // Last trade ID
"T": 123456785, // Trade time
"m": true, // Is the buyer the market maker?
}

But,This data does not seem to be able to determine whether to sell or buy. How can I get the data for buy and sell transactions?


Solution

  • This thread helped me out to finally understand this concept of market maker/taker: https://money.stackexchange.com/questions/90686/what-does-buyer-is-maker-mean

    basically it is below:

    • isBuyerMaker = true -> SELL
    • isBuyerMaker = false -> BUY