ByBit Exchange Spot Conditional Order

2.9k views Asked by At

I'm trying to place a conditional order using pybit

The purpose is to sell my current spot.

The code is taken from the example from official website:

from pybit import HTTP
session = HTTP("https://api.bybit.com",
               api_key= apikey, api_secret= apisecret)
print(session.place_conditional_order(
    symbol="BTCUSDT",
    order_type="Limit",
    side="Sell",
    qty=1,
    price=54100,
    base_price=54192,
    stop_px=54150,
    time_in_force="GoodTillCancel"
))

But I got this error:

InvalidRequestError: Param validation for 'reduce_only' failed on the 'exists' tag (ErrCode: 10001) (ErrTime: 20:11:57).
Request → POST https://api.bybit.com/private/linear/stop-order/create: {'api_key': 'RByxmjeixs1q19mw8E', 'base_price': 54192, 'order_type': 'Limit', 'price': 54100, 'qty': 1, 'recv_window': 5000, 'side': 'Sell', 'stop_px': 54150, 'symbol': 'BTCUSDT', 'time_in_force': 'GoodTillCancel', 'timestamp': 1651695117335, 'sign': '52782a7eaf5c69ca161b070c5a67e45d3ea9e3c0839bdff624fc6249a3cddee6'}.

How do I solve this?

2

There are 2 answers

0
Melodicfish On

I think your problem might be that you are using USDT (USDT Perpetual) but the code you are using is for Inverse Perpetual try this

print(session.place_active_order(
    symbol="BTCUSDT",
    side="Sell",
    order_type="Limit",
    qty=0.01,
    price=8083,
    time_in_force="GoodTillCancel",
    reduce_only=False,
    close_on_trigger=False
))

It is from the USDT Perpetual docs you might be missing the last 2 parameters

0
ailmcm On

first of all: what kind of trading You are using? Stock, USDT perpetual or something else? If USDT perpetual, here is working peace of code:

from pybit.usdt_perpetual import HTTP
session = HTTP("https://api.bybit.com",
               api_key="YOUR_API_KEY", api_secret="YOUR_API_SECRET")

print(session.place_active_order(
    symbol="BTCUSDT",
    side="Sell", # direction, Sell - short, Buy - long
    order_type="Limit",
    qty=0.001, #qty in btc!!!, min step is 0.001, so at lease abot 35 USDT must be on Your account
    price=31100, # limit order price
    time_in_force="GoodTillCancel",
    reduce_only=False,
    close_on_trigger=False
))

Also make sure You have minimum balance on USDT perpetual trading area to make any actions.