我使用库python-binance。
当我连接我的binance客户端时,如果我尝试进行短订单,如果对冲模式未激活(more about Hedge mode activation),我得到以下错误:
binance.exceptions.BinanceAPIException: APIError(code=-4061): Order's position side does not match user's setting.
代码:
from binance.client import Client
client = Client(
api_key,
api_secret,
)
# Here : I want to get if client accoutn has hedge mode enable or not like :
# hedge_mode = client.get_hedge_mode_active() <--- This method does not exists on library
order = client.futures_create_order(
symbol = "XRPUSDT",
side = SIDE_BUY,
positionSide = "SHORT",
type = ORDER_TYPE_MARKET,
quantity = 500,
)
发布于 2021-01-16 09:42:28
positionSide
特别适用于对冲模式。激活它允许您同时持有同一符号的多头和空头头寸。
因此,如果你想要单向模式(而不是对冲模式),那么你只需要:
response = client.futures_create_order(
timeInForce="GTC",
symbol="BTCUSDT",
side="BUY",
type="LIMIT",
quantity=1,
price=1.00
)
要检查是否激活了对冲模式,只需使用:
client.futures_get_position_mode() #This in python-binance
响应:
{
"dualSidePosition": true // "true": Hedge Mode mode; "false": One-way Mode
}
来自binance API的文档:
https://binance-docs.github.io/apidocs/futures/en/#get-current-position-mode-user_data
https://stackoverflow.com/questions/65745678
复制相似问题