bybit-market-maker
bybit-market-maker copied to clipboard
InvalidRequestError: Errcode 34040
I first get a fill, then moments later I get this error:
2021-07-03 01:28:11.796893 - INFO - Awaiting position.
Traceback (most recent call last):
File "mm.py", line 191, in
It used to work good with me but for now it has same error
I first get a fill, then moments later I get this error:
2021-07-03 01:28:11.796893 - INFO - Awaiting position. Traceback (most recent call last): File "mm.py", line 191, in s.set_trading_stop( File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pybit/init.py", line 909, in set_trading_stop return self._submit_request( File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pybit/init.py", line 1497, in _submit_request raise InvalidRequestError( pybit.exceptions.InvalidRequestError: Not modified (ErrCode: 34040) (ErrTime: 01:28:14). Request → POST https://api.bybit.com/v2/private/position/trading-stop: {'api_key': '', 'recv_window': 5000, 'stop_loss': 2194, 'symbol': 'ETHUSD', 'timestamp': 1625275694488, 'sign': ''}.
This suggests that you've already placed a stop and are trying to modify your trading stop, but the stop loss hasn't changed. For example, if you place a limit order with a stop of 2194, then after filling try to modify the trading stop to the same price (2194), you will get this error. Is this your situation?
This suggests that you've already placed a stop and are trying to modify your trading stop, but the stop loss hasn't changed. For example, if you place a limit order with a stop of 2194, then after filling try to modify the trading stop to the same price (2194), you will get this error. Is this your situation?
No I had actually not placed any stops at all.
Oh No!!! It used to work good with me but for now it has same error now! Besides, it is ignored by the bybit support. Dose anyone know a solution ErrCode: 34040?
Hi guys here's a solution.
Let's say you opened a 'Buy' position (the position must be already open), here's a simple function to add then a SL.
from pybit import HTTP # version: pybit==1.3.6 USE THIS VERSION
def STOP_LOSS_for_LONG_POSITION():
session = HTTP('https://api-testnet.bybit.com', api_key=KEY, api_secret=SECRET)
session.set_trading_stop(
symbol="SOLUSDT",
side="Buy", # I opened a position at 38.70
stop_loss = 38.00) # I set the stop at 38.00
STOP_LOSS_for_LONG_POSITION() # Execute it.
@Jessika-Art thank you for your response but it doesn't work.
Any another idea?
@Kamkuczpol my friend, I just created a simple repo just for you so you can copy the code that works. To make easier your research the functions you need are in lines 163 and 177 for stop loss for buy and sell and both are called in lines 199 for buy and 210 for sell. I make them easy to read and highly customizable.
https://github.com/Jessika-Art/ByBit-useful-functions/blob/aff18bcbf3d0d81ebad2efcdaffdbbc5ec30d957/ByBit%20usefull%20functions.py