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
- wiki/Manual.md notes on market-buys #5251 #564 #4914 #4799 #5197 — committed to ccxt/ccxt by kroitor 5 years ago
- wiki/Manual.md market-buys links #5251 #564 #4914 #4799 #5197 — committed to ccxt/ccxt by kroitor 5 years ago
- wiki/Manual.md market-buys minor edits #5251 #564 #4914 #4799 #5197 — committed to ccxt/ccxt by kroitor 5 years ago
- wiki/Manual.md market-buys #5251 #564 #4914 #4799 #5197 — committed to ccxt/ccxt by kroitor 5 years ago
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.
Yes, yes. thanks
thanks very much. I got it.
@Tezeug
The price has to be added in this specific case, so your comments are a bit wrong. The
priceis required for a market buy on Huobi, because of how the exchange API works. The price is needed to calculate the totalcost = amount * priceof the order. Huobi implementation requiresamount * pricefor 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