question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

KuCoin market buy order types

See original GitHub issue
  • OS: Windows
  • Programming Language version: python
  • CCXT version: 3.18.387
  • Exchange: Kucoin
  • Method: create market buy order

Kucoin’s API allows two types of market orders (link here) by specify either one of the two (not both):

  1. specify ‘size’ = base currency amount, e.g. how much BTC one wants to buy in the BTC/USDT pair;
  2. specify ‘funds’ = quote currency amount, e.g how much USDT one wants to spend to buy BTC.

The latter is very handy in creating market buy orders, since one does not need to analyse the order book to find out how much base currency he is able to buy, with the quote currency he’s got. But the option seems to be not enabled in the kucoin.py code (from line 542), i.e. one can only specify ‘size’:

    def create_order(self, symbol, type, side, amount, price=None, params={}):
        self.load_markets()
        marketId = self.market_id(symbol)
        # required param, cannot be used twice
        clientOid = self.uuid()
        request = {
            'clientOid': clientOid,
            'side': side,
            'size': self.amount_to_precision(symbol, amount),
            'symbol': marketId,
            'type': type,
        }

would be great to enable the second market order type as well, thanks very much!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
kroitorcommented, Mar 23, 2019

@lampardlb no worries, will resolve it anyway, thx, really appreciate your reporting!

1reaction
lampardlampscommented, Mar 23, 2019

@kroitor Thanks for your reply - you should take some rest in the weekend mate! I’m a bit embarrassed to say that I do not know how to run github properly, and do not know js… I’ve modified the python codes in kucoin.py (by just removing ‘size’ out of ‘request’ initialisation to allow ‘funds’ in params), hope these can somehow help a little:

def create_order(self, symbol, type, side, amount=None, price=None, params={}):
     self.load_markets()
     marketId = self.market_id(symbol)
     # required param, cannot be used twice
     clientOid = self.uuid()
     request = {
         'clientOid': clientOid,
         'side': side,
         'symbol': marketId,
         'type': type,
     }

    if amount is not None:
        request['size']= self.amount_to_precision(symbol, amount),

     if type != 'market':
         request['price'] = self.price_to_precision(symbol, price)
     response = self.privatePostOrders(self.extend(request, params))
     responseData = response['data']
     return {
         'id': responseData['orderId'],
         'symbol': symbol,
         'type': type,
         'side': side,
         'status': 'open',
         'clientOid': clientOid,
         'info': responseData,
     }
Read more comments on GitHub >

github_iconTop Results From Across the Web

Spot Trade: Order Types - KuCoin
1. Limit Order: A “Limit Order” is an order placed to buy or sell a specified quantity of assets at a specified limit...
Read more >
Order Types Included in KuCoin Futures Trading
KuCoin supports three type orders currently: Limit Order, Market Order, Stop Order. Limit Order: A limit order is an order placed to buy...
Read more >
Stop Limit & Stop Market & Stop Loss in Futures Trading
There are three trigger types for stop order on KuCoin Futures: 1) Last price, 2) Mark price and 3) Index price. When the...
Read more >
How to Make a Trade on KuCoin
KuCoin is built for all types of investors. ... Select Market Order, enter 1000 USDT in the amount box, then click Buy KCS...
Read more >
What Advanced Types of Order Are Included on Futures ...
We only support three types of advanced orders currently: Hidden, Post Only, and Reduce Only. Users may set the advanced types of orders...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found