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

cannot query the new order and how to cancel all open orders of one symbol #394

Open staywithdream opened 3 years ago

staywithdream commented 3 years ago

Title

Short Description:

Platform:

php version:

Long descrption

code

$order = $api->buy($symbol, $quantity, $price);
dump($order);
$order_id   = $order['orderId'] ?? null;
$order_time = $order['transactTime'] ?? null;

$openorders = $api->openOrders($symbol);
dump($openorders);
// 查询是否成交
$orderstatus = $api->orderStatus($symbol, $order_id);
$status      = $orderstatus['status'];
dump($orderstatus);
if ($status == 'NEW') {
    $response = $api->cancel($symbol, $order_id);
    dump($response);
}

plese add this method image

thank you

staywithdream commented 3 years ago

is this is websocket? it's so weired image

ePascalC commented 3 years ago

@staywithdream please do not mix bugs, enhancements and questions into 1 thread, better to open multiple issues so we can work (and close) where needed.

  1. BUG: could it be that you are doing that too fast? What if you wait 2 seconds after buying and then check?
  2. Enhancement: function cancelOpenOrders is probably what you are looking for?
  3. Websocket timeout: I suggest to check the keepAlive function (listenKey) and read about Binance timeouts. From the official docs: Every 3 minutes, active WebSocket connections will receive a ping. If you do not respond with a properly framed pong, your connection will be terminated. For user data streams, if a keep-alive is not received at least once every 60 minutes, the listen key will expire.