verata-veritatis / pybit

Python3 API connector for Bybit's HTTP and Websockets APIs.
MIT License
114 stars 189 forks source link

USDT perpetual order creation fails with "Error sign!" in place_active_order #58

Closed RumiFlow closed 2 years ago

RumiFlow commented 2 years ago

System: macOS pybit version: 1.3.0

My code is working for for coin based perpetual contracts. Tried adapting for the ETCUSDT perpetual contract. Authentication and active order queries work fine. However, creating an order fails with an "Error sign!" exception

Traceback (most recent call last):
  File "/Users/user/Dropbox/Projects/PTrader/PTrader.py", line 237, in <module>
    close_on_trigger="False")
  File "/Users/user/Library/Python/3.7/lib/python/site-packages/pybit/__init__.py", line 492, in place_active_order
    auth=True
  File "/Users/user/Library/Python/3.7/lib/python/site-packages/pybit/__init__.py", line 1870, in _submit_request
    time=dt.utcnow().strftime("%H:%M:%S")
pybit.exceptions.InvalidRequestError: Error sign! origin_string[api_key=valid_api_key&close_on_trigger=false&order_type=limit&price=52.11&qty=0.1&recv_window=5000&reduce_only=true&side=sell&symbol=etcusdt&time_in_force=goodtillcancel&timestamp=1633520617145] (ErrCode: 10004) (ErrTime: 11:43:37).
Request → POST https://api.bybit.com/private/linear/order/create: {'api_key': 'valid_api_key', 'close_on_trigger': 'False', 'order_type': 'Limit', 'price': 52.11, 'qty': 0.1, 'recv_window': 5000, 'reduce_only': 'True', 'side': 'Sell', 'symbol': 'ETCUSDT', 'time_in_force': 'GoodTillCancel', 'timestamp': 1633520617145, 'sign': '1c52731c9926946bc22332592dd31abeba4bedc017caed64528c79facb2428f2'}.
dextertd commented 2 years ago

Hm the returned origin_str is all in lower case, very strange. Can you show the full pybit call please (traceroute only shows the last last close_on_trigger="False"))

RumiFlow commented 2 years ago

Here the full call:

                    resp = pad.session.place_active_order(side=side, symbol=COIN_PAIR, order_type="Limit",
                                                      qty=newQty,
                                                      price=newPrice,
                                                      time_in_force="GoodTillCancel",
                                                      reduce_only="True",
                                                      close_on_trigger="False")

I use exactly the same call for coin based perpetuals except for parameters: reduce_only="True" & close_on_trigger="False"

dextertd commented 2 years ago

Please do the following params as booleans as shown, rather than strings

reduce_only=True,
close_on_trigger=False
RumiFlow commented 2 years ago

Yep! That did the trick. Thanks!