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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

quoteOrderQty formatted wrong in binance_build_query function

nattila1 opened this issue · comments

quoteOrderQty formatted wrong in binance_build_query function

Short Description:
If quoteOrderQty is set in a new MARKET order in binance_build_query() function http_build_query() replace the word "quot" with a quotation mark ("eorderQTY). So the query URL will be something like this: symbol=BTCBUSD&side=BUY&type=MARKET&recvWindow=60000"eOrderQty=1001&newClientOrderId=f4ab2acbdc0aabcf0f7c875c87a129

Sorry but I don't know how it should be fixed on a proper way.

thank you

&quot is an HTML notation for "
But it will not be so easy to find the solution I suppose.

@nattila1 Can you give me the function and parameters that you used in your script so I can simulate? Thanks.

Hi @ePascalC ,

I am simply trying to place a new MARKET order on test environment with following parameters:

$flags = []; $flags['isQuoteOrder'] = true; $new_order = $api->order('BUY', 'BTCBUSD', 1000, '', 'MARKET', $flags, false );

Maybe if & would be URL encoded, this wouldn't happen, no?

Hi @nattila1, I tried to reproduce your issue without success, is it still bugged when you calls the function ?

Tried to reproduce with

function binance_build_query($params = [])
{
    $new_arr = array();
    $query_add = '';
    foreach ($params as $label=>$item) {
        if ( gettype($item) == 'array' ) {
            foreach ($item as $arritem) {
                $query_add = $label . '=' . $arritem . '&' . $query_add;
            }
        } else {
            $new_arr[$label] = $item;
        }
    }
    $query = http_build_query($new_arr, '', '&');
    $query = $query_add . $query;

    return $query;
}

$opt = [
    "symbol" => "BTCBUSD",
    "side" => "BUY",
    "type" => "MARKET",
    "quoteOrderQty" => 1000,
    "recvWindow" => 60000,
];
echo binance_build_query($opt);

And getting as result : symbol=BTCBUSD&side=BUY&type=MARKET&quoteOrderQty=1000&recvWindow=60000