0

我正在使用 Python、Binance 和 CCXT API 库在 Binance 上创建买入订单。执行下面的代码时出现错误。

错误:ccxt.base.errors.InvalidOrder:币安订单将立即触发。

我还添加了输入。

为什么我会收到此错误?

TIA

代码

def ccxt_create_buy_order( self, symbol: str, amount: float, price: float, stop_price: float ):
    try:
        print(" ======= BUY ORDER : ccxt_create_buy_order ================================== ")
        results = {}
        params  = { 'stopPrice': stop_price , 'timeInForce':'GTC'  }
        print("inputs symbo " + symbol + " amount/quantity " + str(amount) + " price " + str(price) )
        print( params )

        output  = self.ccxt_binance.createOrder(symbol, 'STOP_LOSS_LIMIT', amount=amount, side="buy", \
                    price=price, params=params)

输入

 ======= BUY ORDER : ccxt_create_buy_order ==================================
    symbol      BTC/USDT 
    amount/quantity 0.0015 
    price       9872.49
    params      {'stopPrice': 9773.77, 'timeInForce': 'GTC'}

日志文件

ERR-3A59F2841 Traceback(最近一次调用最后):文件“/usr/local/lib/python3.7/dist-packages/ccxt/base/exchange.py”,第 568 行,在 fetch response.raise_for_status() 文件中“/ usr/lib/python3/dist-packages/requests/models.py”,第 940 行,在 raise_for_status 中引发 HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https:// api.binance.com/api/v3/order

在处理上述异常的过程中,又出现了一个异常:

回溯(最后一次调用):文件“../trade_binance/trade_binance.py”,第 660 行,在 ccxt_create_buy_order 价格=价格,参数=参数)文件“/usr/local/lib/python3.7/dist-packages/ ccxt/binance.py”,第 1223 行,在 create_order response = getattr(self, method)(self.extend(request, params)) 文件“/usr/local/lib/python3.7/dist-packages/ccxt/base /exchange.py”,第 452 行,内部返回条目(_self,**inner_kwargs)文件“/usr/local/lib/python3.7/dist-packages/ccxt/binance.py”,第 1954 行,在请求响应中= self.fetch2(path, api, method, params, headers, body) File "/usr/local/lib/python3.7/dist-packages/ccxt/base/exchange.py", line 471, in fetch2 return self .fetch(request['url'], request['method'], request['headers'],request['body']) 文件“/usr/local/lib/python3.7/dist-packages/ccxt/base/exchange.py”,第 580 行,在 fetch self.handle_errors(http_status_code, http_status_text, url, method, headers, http_response, json_response, request_headers, request_body) 文件“/usr/local/lib/python3.7/dist-packages/ccxt/binance.py”,第 1935 行,handle_errors self.throw_exactly_matched_exception(self.exceptions, message, self .id + ' ' + 消息)文件“/usr/local/lib/python3.7/dist-packages/ccxt/base/exchange.py”,第 489 行,在 throw_exactly_matched_exception 中引发精确字符串json_response, request_headers, request_body) 文件“/usr/local/lib/python3.7/dist-packages/ccxt/binance.py”,第 1935 行,在 handle_errors self.throw_exactly_matched_exception(self.exceptions, message, self.id + ' ' + 消息)文件“/usr/local/lib/python3.7/dist-packages/ccxt/base/exchange.py”,第 489 行,在 throw_exactly_matched_exception 中引发精确字符串json_response, request_headers, request_body) 文件“/usr/local/lib/python3.7/dist-packages/ccxt/binance.py”,第 1935 行,在 handle_errors self.throw_exactly_matched_exception(self.exceptions, message, self.id + ' ' + 消息)文件“/usr/local/lib/python3.7/dist-packages/ccxt/base/exchange.py”,第 489 行,在 throw_exactly_matched_exception 中引发精确字符串

错误:ccxt.base.errors.InvalidOrder:币安订单将立即触发。

预计 到达时间@Igor Kroltar

感谢您的回复。在查找错误时,我发现了以下内容。在哪里可以找到step-size rule for the symbol

在此处输入图像描述

4

1 回答 1

1

命令将立即触发。” 异常在 Binance 的 API 文档中进行了解释:https ://binance-docs.github.io/apidocs/#9xxx-filter-failures

与最后成交价相比,订单的止损价无效。

于 2020-06-12T03:33:43.677 回答