php-binance-api
php-binance-api copied to clipboard
cannot query the new order and how to cancel all open orders of one symbol
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
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

thank you
is this is websocket? it's so weired

@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.
- BUG: could it be that you are doing that too fast? What if you wait 2 seconds after buying and then check?
- Enhancement: function cancelOpenOrders is probably what you are looking for?
- 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.
