zhouaini528 / bybit-php

Bybit API Like the official document interface, Support for arbitrary extension.
MIT License
24 stars 12 forks source link

ByBit API returns error: Param validation for 'symbol' failed on the 'linear_symbol' tag #4

Closed kadnan closed 3 years ago

kadnan commented 3 years ago

I am trying to fetch the BTCUSD data but it returns the following:

(
    [ret_code] => 10001
    [ret_msg] => Param validation for 'symbol' failed on the 'linear_symbol' tag
    [ext_code] => 
    [ext_info] => 
    [result] => 
    [time_now] => 1612508984.802319
    [token] => 
)

The code I am using is:

$bybit = new BybitLinear();
$pair = 'BTCUSD';
$interbal_in_action = '1d';
$result = $bybit->publics()->getKline( [
            'symbol'   => $pair,
            'interval' => $interval_in_action,
            'limit'    => 10,
            'from'     => $from,
        ] );
        print_r($result);

Update

It seems that BybitAPI Does support for BTCUSD but in Inverse but your API does not support it

https://bybit-exchange.github.io/docs/inverse/?php#t-querykline
zhouaini528 commented 3 years ago

Thank you for your discovery, let me first see how to solve it

zhouaini528 commented 3 years ago

You try this

$bybit=new BybitInverse();
try {
    $result=$bybit->publics()->getKlineList([
        'symbol'=>'BTCUSD',
        'interval'=>'15',
        'from'=>time()-3600,
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r($e->getMessage());
}

https://github.com/zhouaini528/bybit-php/blob/master/tests/inverse/publics.php#L40