bybit-exchange / pybit

Official Python3 API connector for Bybit's HTTP and WebSockets APIs.
Other
340 stars 113 forks source link

Can't Set SL/TP With Spot Market Order #200

Closed sumobull closed 2 months ago

sumobull commented 3 months ago

Hi, when I attempt to sumbit a Testnet spot market order and specifiy SL and TP levels, I receive the following error:

pybit.exceptions.InvalidRequestError: Data sent for paramter '' is not valid. (ErrCode: 170130) (ErrTime: 07:53:49). Request → POST https://api-testnet.bybit.com/v5/order/create: {"category": "spot", "symbol": "BTCUSDT", "side": "Buy", "orderType": "Market", "qty": "50", "orderLinkId": "spot-test-postonly_5", "isLeverage": 0, "marketUnit": "quoteCoin", "takeProfit": "70000", "stopLoss": "50000", "tpOrderType": "Market", "slOrderType": "Market", "tpslMode": "Full"}.

I have retyped my code to confirm no random characters in it. If I omit the SL and TP items, goes through fine. Any idea what I am doing wrong? Code below. Thx in advance.

` result = session.place_order( category="spot", symbol="BTCUSDT", side="Buy", orderType="Market", qty="50", orderLinkId="spot-test-postonly_5", isLeverage=0, marketUnit="quoteCoin", takeProfit="70000", stopLoss="50000", tpOrderType="Market", slOrderType="Market", tpslMode="Full", )

`

Kamsby commented 2 months ago

Market SPOT order doesn't support takeProfit and stopLoss