如何获取币安的交易 buy/sell 数据?
How can I get trade buy/sell data of Binance?
我想通过 binance websocket 获取 BTC 的实时交易 buy/sell 数据。
我在以下 websocket 模块中使用此方法:
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>)
此方法return以下值:
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?
}
但是,这个数据好像不能判断是卖还是买。如何获取买卖交易的数据?
这篇文章帮助我最终理解了市场的概念 maker/taker:
https://money.stackexchange.com/questions/90686/what-does-buyer-is-maker-mean
基本如下:
- isBuyerMaker = true -> 卖出
- isBuyerMaker = false -> 购买
我想通过 binance websocket 获取 BTC 的实时交易 buy/sell 数据。
我在以下 websocket 模块中使用此方法:
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>)
此方法return以下值:
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?
}
但是,这个数据好像不能判断是卖还是买。如何获取买卖交易的数据?
这篇文章帮助我最终理解了市场的概念 maker/taker: https://money.stackexchange.com/questions/90686/what-does-buyer-is-maker-mean
基本如下:
- isBuyerMaker = true -> 卖出
- isBuyerMaker = false -> 购买