zhouaini528 / binance-php

Binance API Like the official document interface, Support for arbitrary extension.
MIT License
107 stars 43 forks source link

BatchOrders does not work #29

Open husmen73 opened 2 years ago

husmen73 commented 2 years ago

Hi,

postBatchOrders method does not work due guzzle url encode. Is there any options for urlencoding to disable?

Should be

[%7B%22symbol%22:%22BTCUSDT%22,%22side%22:%22BUY%22,%22positionSide%22:%22LONG%22,%22type%22:%22MARKET%22,%22quantity%22:%220.01%22%7D]

But guzzle converting when sending like this

%5B%257B%2522symbol%2522%3A%2522BTCUSDT%2522%2C%2522side%2522%3A%2522BUY%2522%2C%2522positionSide%2522%3A%2522LONG%2522%2C%2522type%2522%3A%2522MARKET%2522%2C%2522quantity%2522%3A%25220.01%2522%257D%5D

zhouaini528 commented 2 years ago

Thank you for your discovery, I will fix it

zhouaini528 commented 2 years ago

@husmen73 Hi , I have solved it.

$result=$binance->trade()->postBatchOrders([
        'batchOrders'=>[
            [
                'symbol'=>'BTCUSDT',
                'side'=>'BUY',
                'type'=>'LIMIT',
                'quantity'=>'1',
                'price'=>'60000',
                'timeInForce'=>'GTC',
                //'newClientOrderId'=>'xxxxxxx'
            ],
            [
                'symbol'=>'BTCUSDT',
                'side'=>'BUY',
                'type'=>'LIMIT',
                'quantity'=>'2',
                'price'=>'60000',
                'timeInForce'=>'GTC',
                //'newClientOrderId'=>'xxxxxxx'
            ],
        ]
    ]);

https://github.com/zhouaini528/binance-php/blob/master/tests/future/trade.php#L52