Skip to content
This repository has been archived by the owner on Feb 15, 2022. It is now read-only.

increment is improperly implemented on Binance #1380

Closed
glennfu opened this issue Feb 20, 2018 · 0 comments
Closed

increment is improperly implemented on Binance #1380

glennfu opened this issue Feb 20, 2018 · 0 comments
Labels

Comments

@glennfu
Copy link
Contributor

glennfu commented Feb 20, 2018

Take EOS/BTC. EOS is an integer coin. increment is thus specified as "1.00000000" as pulled from stepSize from the Binance output.

However, we have engine calculations like:
n(quote.bid).subtract(n(quote.bid).multiply(s.options.markdown_buy_pct / 100)).format(s.product.increment, Math.floor)

Now this is taking the EOS stepSize, and passing it to a format of BTC. Luckily, for numbro, a format of "1.00000000" is functionally equivalent to "0.00001000". It only cares about how many digits are represented. This means that the current implementation of increment` is entirely meaningless.

Later on, when you have size calculations, you see things like this: size = n(s.balance.currency).multiply(buy_pct).divide(100).subtract(size).divide(price).format('0.00000000')

This gives you values like 9.14567431 when it should be 9 since EOS is an integer coin. Luckily Binance corrects this and spits back 9 after you place an order, but it still screws up calculations within Zenbot and leads to other errors, like trying to buy more than you can afford if what Zenbot wants to buy is very close but not quite an integer.

It's simple to convert stepSize to how numbro needs it to be like this:

    for (i = stepSize.length - 1; i > 0; i--) {
      if (stepSize[i] === '0') stepSize = stepSize.slice(0, i)
    }

However, this breaks lots more things because like I mentioned increment is passed as the format to BTC, instead of EOS, so the wrong thing gets formatted. I could just reverse this, but I don't understand the original intent so I'd risk breaking more than I fix.

Anyone have any insights on this?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants