使用 python-binance 包装器下达币安期货订单。错误:APIError(代码=-1102):未发送强制参数“5e-05”

问题描述 投票:0回答:3

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

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.

Binance-Doc 链接:https://binance-docs.github.io/apidocs/futures/en/#new-order-trade

python bots binance binance-api-client
3个回答
1
投票

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

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)

0
投票

也许您应该在参数中尝试“做多”而不是“买入”

futures_create_order()

功能。


0
投票

您的代码解决了我的一些疑问,但我的问题是,鉴于币安现在随时更改任何代币的杠杆率,您如何实时读取允许的最大杠杆率,以便根据所述执行订单杠杆作用? .

© www.soinside.com 2019 - 2024. All rights reserved.