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.

Binance: amount_to_lots() overly precise

See original GitHub issue
  • OS: Mac
  • Programming Language version: Python 3.6
  • CCXT version: 1.10.837
  • Exchange: Binance
  • Method: amount_to_lots()

I’m trying to buy 1.01 ETH/USDT. To avoid the order amount should be evenly divisible by lot error, I convert the order amount using amount_to_lots() before placing the order.

I’ve been trying to follow this issue: https://github.com/ccxt/ccxt/issues/663, but I’m not sure to understand the conclusion. Should I even call amount_to_lots() before my order, or should I just make sure that the order amount is not below the lot size?

In this case, CCXT tells me that the lot size for ETH/USDT is 1e-05 (which is suspiciously small). As a result, the output of amount_to_lots() is 1.0099. Ordering 1.0099 ETH/USDT works but it only fills 1.0098 without any errors or warning. screenshot 2018-01-24 21 12 00

When I skip amount_to_lots() and directly order 1.01 ETH/USDT, it works. This confirms my assumption that the lot size is incorrect. screenshot 2018-01-24 21 16 01

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:14 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
kroitorcommented, Jan 28, 2018

@mkutny we are making an all-in-one prototype function for this, and will add modules (in C++ V8, precompiled for speed for Node.js and Python) later.

// /*  ------------------------------------------------------------------------ */

// const toPrecision = (x, { round = true, digits = 8, fixed = true })
//        => round ? roundNumber (x, { digits, fixed })
//                 : truncNumber (x, { digits, fixed })

https://github.com/ccxt/ccxt/blob/master/js/base/functions/number.js

We are going to transpile to compiled languages as well (namely, c/cpp, go and probably rust).

1reaction
kroitorcommented, Jan 28, 2018

@fredfortier yep, fixing it now. The problem is decoupling the truncation logic, fixing it and making it work seamlessly and universally for all exchanges, but we are almost there… Thanks for your patience!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Binance: amount_to_lots() overly precise - Bountysource
OS: Mac; Programming Language version: Python 3.6; CCXT version: 1.10.837; Exchange: Binance; Method: amount_to_lots().
Read more >
Binance outflows raise concern about its reserves - Fortune
The alarm over Binance increased amid reports that the company was failing to process withdrawals of USDC, one of the more widely used ......
Read more >
Trading Rules | Binance
Max. Number of Open Limit Orders. 200. Max. Number of Open Conditional Orders. 5. LTC/BTC. Minimum Trade Amount. 0.001 LTC. Minimum Amount Movement....
Read more >
Precision is over the maximum defined for this asset. python ...
I coded a trading bot with python-binance ...
Read more >
Binance Faces 'Too Big to Fail' Worry as FTX Collapse Boosts ...
The death spiral of Sam Bankman-Fried's empire bolsters the dominance of Changpeng Zhao's exchange and amps up potential dangers for 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