这个错误通常是由于数量的格式不正确而引起的。请确保将数量转换为正确的字符串形式,例如:
quantity = Decimal('0.001')
quantity_str = '{0:f}'.format(quantity)
如果您的数量已经是字符串形式,请确保它是有效的数字字符串,例如:
quantity_str = '0.001'
if not quantity_str.replace('.', '').isdigit():
raise ValueError('Invalid quantity: {}'.format(quantity_str))
此外,在使用API时还应始终检查交易对的数量限制,并确保输入数量在此范围内。