簡體   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