在 Python 币安参数'price'中发现非法字符



我无法下以下订单:

symbolTicker = 'SHIBUSDT'
orderPriceBuy = 0.00002650
orderPriceSell = 0.00002700

代码:

buyOrder = client.create_order(
symbol=symbolTicker,
side=SIDE_BUY,
type=ORDER_TYPE_LIMIT,
timeInForce=TIME_IN_FORCE_GTC,
quantity=orderQuantityBuy,
price=orderPriceBuy)

错误:

raise BinanceAPIException(response, response.status_code, response.text)
binance.exceptions.BinanceAPIException: APIError(code=-1100): Illegal characters found in parameter 'price'; legal range is '^([0-9]{1,20})(.[0-9]{1,20})?$'.

似乎出了什么问题?

正如错误所述,订单价格需要以字符串而不是数字的形式给出。它还向您展示了合法范围的RegEx(这很好(。注意:您不能在RegEx中使用数字,因为包确实进行RegEx检查,所以它还需要一个字符串。此外,您还可以查看包的文档,其中肯定有文档。

最新更新