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

Cancel order not working

Open whitesiroi opened this issue 7 years ago • 4 comments

Title

  • bug: $api->cancel($symbol, $orderId); stops working

Platform:

  • macos High Sierra 10.13.6

php version:

  • 7.1.9

code

require 'vendor/autoload.php';
$api = new Binance\API("<api key>","<secret>");

$response = $api->cancel("MFTETH", 8654008);
var_dump($response); die();

array(2) {
  'code' =>
  int(-2011)
  'msg' =>
  string(13) "UNKNOWN_ORDER"
}

but if I execute orderStatus() it shows that order does exist and I can still see it here https://www.binance.com/userCenter/openOrders.html?lang=en

$response = $api->orderStatus("MFTETH", 8654008);
var_dump($response); die();

array(16) {
  'symbol' =>
  string(6) "MFTETH"
  'orderId' =>
  int(8654008)
  'clientOrderId' =>
  string(22) "XXXXX"
  'price' =>
  string(10) "0.00001159"
  'origQty' =>
  string(14) "25843.00000000"
  'executedQty' =>
  string(10) "0.00000000"
  'cummulativeQuoteQty' =>
  string(10) "0.00000000"
  'status' =>
  string(8) "CANCELED"
  'timeInForce' =>
  string(3) "GTC"
  'type' =>
  string(5) "LIMIT"
  'side' =>
  string(3) "BUY"
  'stopPrice' =>
  string(10) "0.00000000"
  'icebergQty' =>
  string(10) "0.00000000"
  'time' =>
  int(1545897979461)
  'updateTime' =>
  int(1545898002342)
  'isWorking' =>
  bool(true)
}

thank you

whitesiroi avatar Dec 28 '18 03:12 whitesiroi

I think this bug has a relation with #99 (cancel method uses POST method for httpRequest) I solved it and now you can test the new code: #216 I tested it and orders have been cancelled without any problem.

afsharsafavi avatar Jan 18 '19 13:01 afsharsafavi

@afsharsafavi thank you, I found a bug but not sure how to commit/push to official repo. https://github.com/jaggedsoft/php-binance-api/blob/master/php-binance-api.php line 908 instead of $curlch should be $curl

thank you

whitesiroi avatar Jan 21 '19 03:01 whitesiroi

@whitesiroi thank you For using POSTFIELDS, I used last code of php-binance-api that has been commented before, but it seems from before it's variable was $curlch and in other lines, curl variable is $curl. I sent a pull request again #218 and we should wait for approving it by @jaggedsoft

afsharsafavi avatar Jan 21 '19 05:01 afsharsafavi

thank you very much

whitesiroi avatar Jan 21 '19 06:01 whitesiroi