Closed BenBao93 closed 6 years ago
Yes this is a good use of the websocket trades
endpoint;
require 'vendor/autoload.php';
$api = new Binance\API('','');
$api->trades(["BTCUSDT"], function($api, $symbol, $trades) {
echo "{$symbol} trades update".PHP_EOL;
print_r($trades);
});
I think what you have to do is sort it by "maker/taker" volume. This may be actual "buy/sell" volume but I can't tell for sure. I suspect when "maker: false" that someone has taken someone elses order, such as a market buy, or buying from someone elses sell wall.
To do what you want, you would need to add the volume for each currency every time you see the trade
event, and reset the total count once per minute.
Thanks, I will have a look at the details for this method!
Just to confirm that is by symbol right? So for all I would need to wrap it in a loop going over all symbols and subscribe to each individual websocket?
Yes you can grab all symbols using exchangeInfo method or prevDay
$prevDay = $api->prevDay("BNBBTC");
print_r($prevDay);
echo "BNB price change since yesterday: ".$prevDay['priceChangePercent']."%".PHP_EOL;
I believe you can just call $api->prevDay()
to get the 24 hour volume change for all symbols. Now one thing which might be easier is watching how this number changes every minute. This might be a lot less work
True but that would be trailing 24h, so basically the same like the websocket pushes. Since every reading would not include the first minute of the previous reading anymore you can not just subtract the old value from the new one as they include different, non overlapping time frames :(
So as far as I see the options it really would boil down to reading specific klines from the REST API or subscribing to the websocket. Both for each symbol individually.
Yes you are correct, it would include volume fluctuations from over 24 hours ago. Hmm I'll think on this some more, let me know if you come up with any ideas and I will try to work on something
I am having a similar issue. Were you able to come up with a solution on how to get minute by minute volume data of each symbol
Hello,
I am using the library on Ubuntu with PHP7.2 and would like to read trade volumes for all symbols ideally by minute. The websocket has both quote and asset volume but that seems to be trailing 24h, so if I read it from there I can not calculate the volume for let's say the previous minute since every value will not include the first minute of the previous value anymore.
The kline websocket/API can give me these information as far as I can see but only for a specific symbol, which would take up a lot of resources via websockets for each and every symbol and the REST api would probably be subject to rate limiting (and it isn't very performant either).
Is there a more simple way that works without huge server resources to import the trade volume for every minute for all symbols?
Thanks a lot in advance!