gateio / gateapi-php

25 stars 30 forks source link

listMyTrades - Currency Pair Exception #9

Closed geethpw closed 2 years ago

geethpw commented 2 years ago

For the spot account sync:

// $associate_array['currency_pair'] = null; // string | Retrieve results with specified currency pair. It is required for open orders, but optional for finished ones.
$associate_array['limit'] = 100; // int | Maximum number of records to be returned in a single list
$associate_array['page'] = 1; // int | Page number
$associate_array['order_id'] = '12345'; // string | Filter trades with specified order ID. `currency_pair` is also required if this field is present
$associate_array['account'] = 'spot'; // string | Specify operation account. Default to spot and margin account if not specified. Set to `cross_margin` to operate against margin account
$associate_array['from'] = 56; // int | Time range beginning, default to 7 days before current time
$associate_array['to'] = 56; // int | Time range ending, default to current time

try {
    $result = $apiInstance->listMyTrades($associate_array);
    print_r($result);
} catch (GateApi\GateApiException $e) {
    echo "Gate API Exception: label: {$e->getLabel()}, message: {$e->getMessage()}" . PHP_EOL;
} catch (Exception $e) {
    echo 'Exception when calling SpotApi->listMyTrades: ', $e->getMessage(), PHP_EOL;
}

If I comment out $associate_array['currency_pair'] there is an exception thrown from the code. It does not allow to call the API without passing the currency param. The exception is:

'Missing the required parameter $currency_pair when calling listMyTrades'

I commented on the exception and the spot data returned successfully. Otherwise, we have to loops for every trading pair which takes a very long time.

IMO, this exception should be removed if the account is 'spot'.

revilwang commented 2 years ago

You can try to set currency_pair to an empty string to circumvent this exception.

geethpw commented 2 years ago

@revilwang Thanks.