bybit: sign error for conditional market orders when stop/base price is a round number
See original GitHub issue- OS: Ubuntu 20.04
- Programming Language version: Python 3.9
- CCXT version: 1.40.94
Hey Igor,
This seems pretty crazy to have gone by without being reported so I’m hoping this is either an incoming API change or an unexpected dependency upgrade that’s suddenly causing. But in either case, this is what I’m seeing:
import ccxt
bybit = ccxt.bybit()
bybit.apiKey = "cox"
bybit.secret = "dix"
bybit.urls["api"] = bybit.urls["test"]
bybit.create_order("BTC/USD", "Market", "buy", 16,
params={
'order_link_id': "peen",
'stop_px': 31320.0,
'base_price': 31319.0,
'trigger_by': 'LastPrice'
})
Error:
ExchangeError: bybit {"ret_code":10004,"ret_msg":"error sign! origin_string[api_key=<redacted>\u0026base_price=31319.0\u0026order_link_id=peen\u0026order_type=Market\u0026qty=16\u0026recv_window=5000\u0026side=Buy\u0026stop_px=31320.0\u0026symbol=BTCUSD\u0026time_in_force=GoodTillCancel\u0026timestamp=1611516960917\u0026trigger_by=LastPrice]","ext_code":"","ext_info":"","result":null,"time_now":"1611516961.337532"}
What’s bizarre is that this is only happening if the stopPx/base_price is a round number (no decimal). So in the example above, it should succeed if the prices are 31320.5
and 31319.5
. I dug into the py source code, and tried casting the params to ints beforehand, and that seems to fix it:
Adding this after L1293 in bybit.py (sorry don’t have time to find it in the JS source):
if request["stop_px"] == round(request["stop_px"]):
request["stop_px"] = int(request["stop_px"])
if request["base_price"] == round(request["base_price"]):
request["base_price"] = int(request["base_price"])
Is this an edge case in the signing algo? Or one of my params throwing the system off? New weirdness on testnet? It was certainly not happening before (I upgrade ccxt recently). Happy to file a PR if you (or anyone else) can confirm there is a bug here.
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (5 by maintainers)
@daikts Bybit’s API wasn’t too good at first, which is why we had to add a workaround, but now they have fixed it, apparently, and the workaround is not necessary anymore, so they’re making progress towards a better API. I’ll push the fix in a few minutes. Thx for your feedback!
That seemed to work! Just tested both on testnet and realnet. Massive ups for that response / resolution time @kroitor! Is Bybit API particularly shitty like this is or is this the average experience?