Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

privates->postOrderCreate() signature issue #2

Closed
RobertGasch opened this issue Jan 1, 2021 · 4 comments
Closed

privates->postOrderCreate() signature issue #2

RobertGasch opened this issue Jan 1, 2021 · 4 comments

Comments

@RobertGasch
Copy link

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?

@RobertGasch
Copy link
Author

More info: if I remove the "reduce_only" parameter, the postOrderCreate() call works. So it is somehow related to how a boolean is treated/encoded.

I tried passing a string "true"/"false" as the reduce_only param, but this caused another error (but it made the underlying sign-issue) go away.

Maybe this helps in diagnosing what's wrong. Appreciate any hints you can offer ...

@zhouaini528
Copy link
Owner

Sorry to reply to you now. I just tested and have a problem like yours, I am now looking for the cause

@zhouaini528
Copy link
Owner

zhouaini528 commented Jan 4, 2021

Sorry to keep you waiting. I have found the problem and fixed it, you can use it. The parameters you pass in are as follows

$bybit->privates()->postOrderCreate([
	//'order_link_id'=>'xxxxxxxxxxxxxx',
	'side'=>'Sell',
	'symbol'=>'BTCUSDT',
	'order_type'=>'Limit',
	'qty'=>'0.25',
	'price'=>'40000',
	'time_in_force'=>'GoodTillCancel',

	//Both string type and boolean type are compatible
	'reduce_only'=>'false',
	'close_on_trigger'=>'false',
	//or set
	'reduce_only'=>false,
	'close_on_trigger'=>false
]);

Remember version composer update , current version 1.0.2

@RobertGasch
Copy link
Author

Confirmed as fixed, thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants