jaggedsoft / php-binance-api

PHP Binance API is an asynchronous PHP library for the Binance API designed to be easy to use. https://github.com/binance-exchange/php-binance-api
MIT License
604 stars 496 forks source link

depthCache websocket error #44

Closed mrsantran closed 6 years ago

mrsantran commented 6 years ago

Bid price great than Ask price

screen shot 2018-01-28 at 8 54 40 pm

jaggedsoft commented 6 years ago

Having trouble seeing what is going wrong here

mrsantran commented 6 years ago

Many times return bids price great than asks price

jaggedsoft commented 6 years ago

I cannot reproduce this problem Try using this code, this will display the order book like on their webpage. More importantly, the depth cache gets sorted before display

$api->depthCache("ETHBTC", function($api, $symbol, $depth) {
    echo "{$symbol} depth cache update".PHP_EOL;
    //print_r($depth); // Print all depth data
    $limit = 11; // Show only the closest asks/bids
    $sorted = $api->sortDepth($symbol, $limit);
    $bid = $api->first($sorted['bids']);
    $ask = $api->first($sorted['asks']);
    echo $api->displayDepth($sorted);
    echo "ask: {$ask}".PHP_EOL;
    echo "bid: {$bid}".PHP_EOL;
});
jaggedsoft commented 6 years ago

image