php-binance-api icon indicating copy to clipboard operation
php-binance-api copied to clipboard

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

Open staywithdream opened this issue 4 years ago • 2 comments

Title

  • bug: can not query the new order
  • enhancement: please add method about cancel all orders of one symbol

Short Description:

  • can not query the new order
  • how to cancel all open orders of one symbol
  • In the spot transaction, you can query immediately after the order is created. If you cannot query, it will take a few seconds. In addition, how to query all pending orders of a certain trading pair

Platform:

  • macos

php version:

  • 7.4.16

Long descrption

  • image

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 avatar May 18 '21 14:05 staywithdream

is this is websocket? it's so weired image

staywithdream avatar May 18 '21 17:05 staywithdream

@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.

ePascalC avatar Jun 29 '21 07:06 ePascalC