Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/neo4j/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python二进制检测是否处于活动状态_Python_Binance - Fatal编程技术网

Python二进制检测是否处于活动状态

Python二进制检测是否处于活动状态,python,binance,Python,Binance,我使用图书馆 当我连接binance客户端时,如果我尝试进行短期订购,如果Hedge模式未激活(),我会出现以下错误: 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, a

我使用图书馆

当我连接binance客户端时,如果我尝试进行短期订购,如果Hedge模式未激活(),我会出现以下错误:

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,
    )
从binance.client导入客户端
客户端=客户端(
api_密钥,
阿皮尤秘密,
)
#这里:我想知道客户账户是否启用了对冲模式:

#hedge_mode=客户端。get_hedge_mode_active()
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的文档:


您好,谢谢您的回答,但我已经找到了通过空头或多头仓位的方法。在下订单之前,我想知道账户是否激活了对冲模式。这是因为有些人会给我他们的API凭据,我需要在检查之前检查一下。请参阅我的编辑,这是python binance中的一个函数,谢谢!这个新功能(v0.7.9)没有出现在我的0.7.5版本中。不客气,祝你以后好运(玩一玩;)