繁体   English   中英

使用 python-binance 包装器放置 Binance 未来订单。 错误:APIError(代码=-1102):未发送强制参数“5e-05”

[英]Place Binance Future Order using python-binance wrapper. Error: APIError(code=-1102): Mandatory parameter '5e-05' was not sent

我使用强制参数创建未来订单

import datetime
from binance.client import Client

client = Client(API_KEY, API_SECRET)
timestamp = datetime.datetime.now().timestamp()

trade = client.futures_create_order(symbol='BTCUSDT', type='LIMIT', timeInForce='GTC', price=48000, side='BUY', quantity=0.00005, timestamp=timestamp )

此代码给出错误:

binance.exceptions.BinanceAPIException: APIError(code=-1102): Mandatory parameter '5e-05' was not sent, was empty/null, or malformed.

币安文档链接: https://binance-docs.github.io/apidocs/futures/en/#new-order-trade

也许你应该在参数中尝试“LONG”而不是“BUY”

futures_create_order()

function。

我的问题是我没有将价格和数量设置为支持的精度值。 所以首先我得到价格精度和数量精度数据,然后根据该精度转换我的价格和数量

symbol = 'FTMUSDT'
price = 1.38
quantity = 4.5

for info in info['symbols']:
    if info['pair'] == symbol:
        pricePrecision = info['pricePrecision']
        quantityPrecision = info['quantityPrecision']

final_price = "{:0.0{}f}".format(price, pricePrecision)
final_quantity = "{:0.0{}f}".format(quantity, quantityPrecision)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM