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

Test orders returning empty arrays/false booleans

Open CoinStacker opened this issue 4 years ago • 1 comments

Title

  • bug: buyTest/sellTest or order function don't seem to be working correctly.

Short Description:

  • When i run the /examples/orders_test.php file (having replaced the print_r's with var_dumps) I'm just getting false bools or empty arrays for the $order result. Things like get coins in wallet etc are working with the same api details I'm using to run these functions so that shouldn't be playing a factor.

code

require '../php-binance-api.php';

// @see home_directory_config.php
// use config from ~/.confg/jaggedsoft/php-binance-api.json
$api = new Binance\API();

// Place a LIMIT order
$quantity = 1000;
$price = 0.0005;
$order = $api->buyTest("BNBUSDT", $quantity, $price);

echo "<br><br>Limit order response: ";
var_dump($order);

// Place a MARKET order
$quantity = 1;
$order = $api->buyTest("BNBUSDT", $quantity, 0, "MARKET");
echo "<br><br>Market order response: ";
var_dump($order);

// Place a STOP LOSS order
// When the stop is reached, a stop order becomes a market order
$quantity = 1;
$price = 0.5; // Try to sell it for 0.5 btc
$stopPrice = 0.4; // Sell immediately if price goes below 0.4 btc
$order = $api->sellTest("BNBUSDT", $quantity, $price, "STOP_LOSS", ["stopPrice"=>$stopPrice]);
echo "<br><br>Stop Loss order response: ";
var_dump($order);

// Place a take profit order
// When the stop is reached, a stop order becomes a market order
$quantity = 1;
$price = 0.5; // Try to sell it for 0.5 btc
$stopPrice = 0.4; // Sell immediately if price goes below 0.4 btc
$order = $api->sellTest("TRXBTC", $quantity, $price, "TAKE_PROFIT", ["stopPrice"=>$stopPrice]);

echo "<br><br>Take profit order response: ";
var_dump($order);

// Place an ICEBERG order
// Iceberg orders are intended to conceal the true order quantity.
$quantity = 20;
$price = 0.5;
$icebergQty = 10;
$order = $api->sellTest("BNBBTC", $quantity, $price, "LIMIT", ["icebergQty"=>$icebergQty]);
echo "<br><br>Iceberg order response: ";
var_dump($order);

result

Limit order response: bool(false)

Market order response: array(0) { }

Stop Loss order response: bool(false)

Take profit order response: bool(false)

Iceberg order response: bool(false) 

thank you

CoinStacker avatar May 07 '21 00:05 CoinStacker

Hi Coinstacker,

both buyTest and Buy call Order()

from line 1301 onwards the endpoint is changed to either "v3/order" or "v3/order/test". If the test API is returning all bools, i would refer to the binance manual for further details. We're not responsible for what the API returns.

private function order(...................) { ............ $qstring = ($test === false) ? "v3/order" : "v3/order/test"; return $this->httpRequest($qstring, "POST", $opt, true); }

dmzoneill avatar May 10 '21 12:05 dmzoneill