ccxt: huobi create_market_buy_order() error

  • OS: window10
  • Programming Language version: py
  • CCXT version 1.18.562
  • Exchange: huobipro
  • Method: create_market_buy_order()

the code ::

         market_price_buy = float(ticker_base['bid'])
        order_result = self.huobi.create_market_buy_order('EOS/BTC', market_buy_size, market_price_buy)

I have add the param: price

But when I use create_market_buy_order() it says error: InvalidOrder(self.id + " market buy order requires price argument to calculate cost(total amount of quote currency to spend for buying, amount * price). To switch off self warning exception and specify cost in the

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 15 (4 by maintainers)

Commits related to this issue

Most upvoted comments

Do not add the price.

@Tezeug no worries… there are other such cases, CEX, CoinTiger and probably a dozen others. It’s common to place a market buy for total cost in quote currency, instead of market buying the amount in base currency.

Did not know that, wow. Looks like every exchange is absolutely different in some aspects but in the most cases you do not need to add it 😕. Sorry, man.

When you execute an market order you shall not add the price. It will cause an error because the price variable is calculated automatically. You execute an market order so you do not set the price. The price is being set automatically.

@runrun88 you mean, the issue is now resolved and we can close this? )

Yes, yes. thanks

ccxt.base.errors.InvalidOrder: huobipro {“status”:“error”,“err-code”:“order-marketorder-amount-min-error”,“err-msg”:“market order amount error, min: 0.0001”,“data”:null}

@runrun88 see the answer here:

And, also check this:

Basically the exchange is telling you what’s wrong, but the message isn’t very clear:

market order amount error, min: 0.0001

↑ that refers either to the amount or to the total cost = amount * price of the order. Either the amount or amount * price is too low (below exchange limits). But it’s impossible to tell from the code you’ve copypasted above.

So, we need you to follow precisely these guides and paste your verbose request and verbose response:

self.huobi.load_markets()

# ...

market_price_buy = float(ticker_base['bid'])

self.huobi.verbose = True  # ←----------- ADD THIS

order_result = self.huobi.create_market_buy_order('EOS/BTC', market_buy_size, market_price_buy)

↑ Paste the output (both the request and the response) here, plz.

thanks very much. I got it.

@Tezeug

Do not add the price.

When you execute an market order you shall not add the price. It will cause an error because the price variable is calculated automatically. You execute an market order so you do not set the price. The price is being set automatically.

The price has to be added in this specific case, so your comments are a bit wrong. The price is required for a market buy on Huobi, because of how the exchange API works. The price is needed to calculate the total cost = amount * price of the order. Huobi implementation requires amount * price for market buy in quote currency to calculate the total cost. See the explanation here: https://github.com/ccxt/ccxt/blob/master/python/ccxt/huobipro.py#L756