Giter Site home page Giter Site logo

bybit-php's Introduction

Anurag's github stats

bybit-php's People

Contributors

anrisovich avatar llomgui avatar prooksius avatar zhouaini528 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

bybit-php's Issues

429 error

<?php
/**
 * @author lin <[email protected]>
 * */
use \Lin\Bybit\BybitSpot;

require __DIR__ .'../../../vendor/autoload.php';

include __DIR__ .'../../../vendor/key_secret.php';

$bybit=new BybitSpot($key,$secret);

//You can set special needs
$bybit->setOptions([
    //Set the request timeout to 60 seconds by default
    'timeout'=>10,
]);

try {
    $result=$bybit->privates()->getAccount();
    print_r($result);
}catch (\Exception $e){
    print_r($e->getMessage());
}

I get error {"_message":"Client error: GET https:\/\/api.bybit.com\/spot\/v1\/account? resulted in a 429 Too Many Requests response","_httpcode":429}

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

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

How to connect to testnet ?

Hi, I'm trying to connect to testnet api but it doesn't work. Also I've tried to setOptions testnet => true, but no success

$bybit = new BybitLinear($user_api->api_key,$user_api->api_secret,'https://api.bybit.com'); $bybit->setOptions( ['testnet' => true] );

Do you have any suggestion ?

Thanks

error sign! with position_idx

try {
$result=$bybit->privates()->postOrderCreate([
//'order_link_id'=>'xxxxxxxxxxxxxx',
'side'=>'Buy',
'symbol'=>'DOGEUSDT',
'order_type'=>'Market',
'qty'=>'250',
'time_in_force'=>'GoodTillCancel',

    'reduce_only'=>false,
    'close_on_trigger'=>false,
    'position_idx'=>0
]);

}catch (\Exception $e){
print_r($e->getMessage());
}

Error I get
[ret_code] => 10004
[ret_msg] => error sign!

without position idx it works but only in hedge-mode, one way needs position idx 0

Connectivity issue

Hello i currently cloned the repo and ran composer require linwj/bybit

in my VPS when i go to run the test to see even public data endpoints i get errors. This is how i load in my URL

myurl.com/bybit-php/tests/inverse/publics.php

invalid signature for boolean values

when you pass a real boolean value into an endpoint which expects one, the resulting signature is incorrect and generates an "error sign!" result from the ByBit API

example:

$bybit->privates()->postPositionSwitchIsolated([
      'symbol' => $symbol,
      'is_isolated' => false,
      'buy_leverage' => $leverage,
      'sell_leverage' => $leverage
    ]);

however, if you pass the boolean value as a string instead, everything works correctly:

$bybit->privates()->postPositionSwitchIsolated([
      'symbol' => $symbol,
      'is_isolated' => 'false',
      'buy_leverage' => $leverage,
      'sell_leverage' => $leverage
    ]);

I think this should be either documented somewhere or fixed, as it took me a while to realize what's going on and why my valid requests come back with an invalid signature error.

Problems during postOrderCreate - body not json

Hello
I'm using $bybit->privates()->postOrderCreate with necessary parameters
[body] => {"0":{"side":"Sell","symbol":"ETHUSDT","qty":0.2,"price":1261.15},"api_key":"...","timestamp":16730...,"sign":"..."}

but getting the answer:
[ret_msg] => body not json
Help plese
Thank you

BybitSpot

Hi!
I'll try post order on Spot, my code:

$key = 'xxxx';
$secret = 'xxxx';

$bybit = new \Lin\Bybit\BybitSpot($key, $secret);
    
$result=$bybit->privates()->postOrder([
            'side'=>'Buy',
            'symbol'=>'BTCUSDT',
            'type'=>'MARKET',
            'qty'=>0.1,
        ]);
        
print_r($result);

But i get error
Array ( [ret_code] => -1001 [ret_msg] => Internal error. [ext_code] => [ext_info] => [result] => )

could you tell me please what the mistake is?
Thanks :)

Too many visits. Exceeded the API Rate Limit.

`
Route::get('/bybit', function () {
$key = env('BYBIT_KEY');
$secret = env('BYBIT_SECRET');

$bybit = new \Lin\Bybit\BybitLinear($key, $secret);
// dd($bybit);

try {
    $result = $bybit->privates()->getPositionList([
        'symbol' => 'BTCUSDT',
    ]);
    // $result = $bybit->privates()->postOrderCreate([
    //     //'order_link_id'=>'xxxxxxxxxxxxxx',
    //     'side' => 'Buy',
    //     'symbol' => 'BTCUSDT',
    //     'order_type' => 'Limit',
    //     'qty' => '1',
    //     'price' => '49000',
    //     'time_in_force' => 'GoodTillCancel',
    //     'reduce_only' => 'false',
    //     'close_on_trigger' => 'false',
    // ]);

    dump($result);
} catch (\Exception $e) {
    dd($e->getMessage());
}

});
`

why am i getting rate limited, is there something wrong with what im doing?

privates->postOrderCreate() signature issue

I am working with your API and things generally seem to work well. GET requests I had no problem with (getPositionList, getTradingRecords, getWalletBalance, etc.). However, postOrderCreate always returns this:

"ret_code" => 10004 "ret_msg" => "error sign! origin_string[api_key=xxxxxxxxxxxxxx&order_type=Market&qty=1&reduce_only=true&side=Sell&symbol=BTCUSD&time_in_force=GoodTillCancel&timestamp=1609525189785]" "ext_code" => "" "ext_info" => "" "result" => null "time_now" => "1609525190.137879"

At first I thought that it might be a problem with POST requests, but postOrderCancel() passes the sign check (it returns an error because I'm supplying an invalid order-id but the signature check passes OK) ...

For the postOrderCreate request which fails, the params passed to your API are:

"side" => "Sell" "symbol" => "BTCUSD" "order_type" => "Market" "qty" => 1 "reduce_only" => true "time_in_force" => "GoodTillCancel"

and the full request which is sent to bybit is this:

"body" => "{"api_key":"xxxxxxxxxxxxxx","order_type":"Market","qty":1,"reduce_only":true,"side":"Sell","symbol":"BTCUSD","time_in_force":"GoodTillCancel","timestamp":1609525189785,"sign":"7c12c29a413c401e8c8bdf9a740c40d3974e699c07c22bd05b8eee1d2d7d5878"}

As the signature is constructed in Request.php in a generic manner, I'm not sure what could be causing this. Can you offer any suggestions?

Inverse Perpetual wrong.

The Inverse Perpetual replace order url is wrong..

it must change from "/open-api/order/replace" to "/v2/private/order/replace"

I have fixed it on my side.

[retCode] => 10002. invalid request, please check your server timestamp

Hi i kept getting this error. Synching my comp time didn't help or helped for short time.

To solve this problem i've modified \vendor\linwj\bybit\src\RequestV5.php

There you will find function called nonce()
It need to be changed to this:

 protected function nonce() {
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            curl_setopt($ch, CURLOPT_URL, 'https://api.bybit.com/v5/market/time');
            $output = curl_exec($ch);
            curl_close($ch);
	    $data = json_decode($output, true);
            $this->nonce=$data['time'];
    }

Now i always have server time in my request, so this error never appeared ever again.

P.S. hope this will be fixed in further updates.

how to calling the api

您好,不好意思,请问能提供postman吗,或者能麻烦您教学如何在您的project里call api吗?麻烦您了,非常感谢

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.