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 create order by quote amount not working?

See original GitHub issue

When I try to create a new market buy/sell order on KuCoin by providing the quote amount using the quoteAmount parameter, like this:

kucoin.createOrder(symbol, 'market', 'buy', (void 0), (void 0), {
    'quoteAmount': value
});

I receive the following error [here]: TypeError: Cannot read property 'toString' of undefined.

I saw that this has been implemented more than a year ago in #6035, but I think there is a problem with that:

if (this.safeValue (params, 'quoteAmount')) {
    // used to create market order by quote amount - https://github.com/ccxt/ccxt/issues/4876
    request['funds'] = this.amountToPrecision (symbol, amount);  //<- ERROR! 'amount' used here accidentally instead of value of 'quoteAmount'?
} else {
    request['size'] = this.amountToPrecision (symbol, amount);
}

  • Programming Language version: Node.Js v14.15.5
  • CCXT version: v1.43.71
  • CCXT Pro version: v0.6.9

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
kroitorcommented, Mar 20, 2021

@frzsombor

so I don’t understand the problem. Is KuCoin giving bad market data or costToPrecision is used accidentally

The problem is that by logical reasoning funds should accept quote cost precision, but KuCoin API still accepts base precision only. I’ve pushed another fixup, please let me know if you still have this issue with 1.43.80, it will be available in ~20 minutes.

0reactions
frzsomborcommented, Mar 20, 2021

Unfortunately still not working, getting the same “Error: Balance insufficient!” error.

Now, it looks like the new costToPrecision leaves the request['funds'] at 8 number length precision (0.00061202), but KuCoin only accepts 5(-6?) as I found above.

And this is actually strange, because when I’ve checked this.markets[symbol].precision it showed precision: {amount: 4, price: 8}, for the symbol, so I don’t understand the problem. Is KuCoin giving bad market data (and this is why amountToPrecision was used until v1.43.76) or costToPrecision is used accidentally instead of amountToPrecision/priceToPrecision?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Order size increment invalid · Issue #112 - GitHub
The priceIncrement field specifies the min order price as well as the price increment.This also applies to quote currency. The order price must ......
Read more >
Explanation of problems when publish the ads? - KuCoin
Setting an ad floating quote means that your quote is a floating price. You can set a premium or a cut-rage price. Q2.What...
Read more >
KuCoin API Documentation: General
General. Introduction. Welcome to KuCoin's trader and developer documentation. These documents outline the exchange functionality, market details, and APIs.
Read more >
[Spot Grid] Introduction to Parameters - KuCoin
Price ” composed the price range of the spot trading. No. of Orders Placed: Total number of placed sell/buy orders. It is used...
Read more >
Open Orders Did Not Go Through - KuCoin
If an order has remained open for an extended period, it may be that the price you entered is not consistent with the...
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