I want to test some codes for placing short-open orders using pybit. My code is as follows.
from pybit import *
session = usdt_perpetual.HTTP(endpoint = "https://api-testnet.bybit.com",
api_key = 'yyyyy',
api_secret = 'xxxxxx')
symbol = "HIGHUSDT"
resp = session.place_active_order(
symbol=symbol,
side="Sell",
order_type="Market",
qty= 10,
time_in_force="GoodTillCancel",
reduce_only=False,
close_on_trigger=False
)
It makes the following Error.
InvalidRequestError: Position idx not match position mode (ErrCode: 130001) (ErrTime: 01:35:30).
Request → POST https://api-testnet.bybit.com/private/linear/order/create: {'api_key': 'xxxxxxxx', 'close_on_trigger': False, 'order_type': 'Market', 'qty': 10, 'recv_window': 5000, 'reduce_only': False, 'side': 'Buy', 'symbol': 'HIGHUSDT', 'time_in_force': 'GoodTillCancel', 'timestamp': 1679362530091, 'sign': '64632a4ed529118f8516eb01294deec4036289ae835326eb24abef6b1ab8b813'}.
What is wrong and how can I fix it? I changed qty and order_type, but it does not help.