简体   繁体   中英

ccxt.base.errors.InvalidOrder: binance Order would trigger immediately

I am using Python, Binance, and CCXT API libraries to create a BUY order on Binance. I am getting an error when executing the code below.

ERROR: ccxt.base.errors.InvalidOrder: binance Order would trigger immediately.

I have also added the inputs.

Why am I getting this error?

TIA

CODE

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)

INPUTS

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

LOG FILE

ERR-3A59F2841 Traceback (most recent call last): File "/usr/local/lib/python3.7/dist-packages/ccxt/base/exchange.py", line 568, in fetch response.raise_for_status() File "/usr/lib/python3/dist-packages/requests/models.py", line 940, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://api.binance.com/api/v3/order

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "../trade_binance/trade_binance.py", line 660, in ccxt_create_buy_order price=price, params=params) File "/usr/local/lib/python3.7/dist-packages/ccxt/binance.py", line 1223, in create_order response = getattr(self, method)(self.extend(request, params)) File "/usr/local/lib/python3.7/dist-packages/ccxt/base/exchange.py", line 452, in inner return entry(_self, **inner_kwargs) File "/usr/local/lib/python3.7/dist-packages/ccxt/binance.py", line 1954, in request response = 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']) File "/usr/local/lib/python3.7/dist-packages/ccxt/base/exchange.py", line 580, in fetch self.handle_errors(http_status_code, http_status_text, url, method, headers, http_response, json_respons e, request_headers, request_body) File "/usr/local/lib/python3.7/dist-packages/ccxt/binance.py", line 1935, in handle_errors self.throw_exactly_matched_exception(self.exceptions, message, self.id + ' ' + message) File "/usr/local/lib/python3.7/dist-packages/ccxt/base/exchange.py", line 489, in throw_exactly_matched_exception raise exactstring

ERROR: ccxt.base.errors.InvalidOrder: binance Order would trigger immediately.

ETA @Igor Kroltar

Thanks for the response. When looking up the errors, I found the following. Where can one find the step-size rule for the symbol ?

在此处输入图像描述

The "Order would trigger immediately." exception is explained in Binance's API docs here: https://binance-docs.github.io/apidocs/#9xxx-filter-failures

The order's stop price is not valid when compared to the last traded price.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM