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

Product update broken for Binance ? #1794

Closed
BAKFR opened this issue Dec 10, 2018 · 2 comments
Closed

Product update broken for Binance ? #1794

BAKFR opened this issue Dec 10, 2018 · 2 comments
Labels

Comments

@BAKFR
Copy link
Contributor

BAKFR commented Dec 10, 2018

Under Node 8.12 (I've not tested others), ./extensions/exchanges/binance/update-products.sh is broken:

(node:27164) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'length' of undefined
    at /data/Projects/202/zenbot/extensions/exchanges/binance/update-products.sh:17:28
    at Array.forEach (<anonymous>)
    at /data/Projects/202/zenbot/extensions/exchanges/binance/update-products.sh:7:11
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:189:7)
(node:27164) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:27164) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

@DeviaVir How do you update the product list ? Does it works for you ?
Also, what do you think about integrating directly at the start of Zenbot ?

@BAKFR
Copy link
Contributor Author

BAKFR commented Dec 10, 2018

On Travis, the build 2117.2 from Tuesday is the last one who succeeded. The last Travis build 2166 silently failed on Binance.

It seems the product list update for Binance randomly fail or succeed. Since Travis run frequently enough, it's not too much of a problem (the list is recent enough), but it should be fixed.

Also, there seem to have a lot of other bug in these Travis script that should be cared of.

@DeviaVir DeviaVir added the bug label Dec 10, 2018
@BAKFR
Copy link
Contributor Author

BAKFR commented Dec 10, 2018

Okay, I've looked more into it. I have good news and bad news.

The good news is that I've found the bug origin: the Binance API returns an array of filter, with each filter being of a different type. The code searches the filters by index in this array, instead of by id.
Easy to fix.

The bad news is: the min_size attribute will not work anymore without further changes.
Binance uses the concept of minimum notional value (price * quantity). Zenbot doesn't support this.
For now, Zenbot uses the maxPrice and the minNotional to create an arbitrary minimal size value. This values doesn't correspond to anything. It just creates an highly overestimated minimal size and it prevents valid orders to be executed, but it blocks almost every bad orders.

Current code of extensions/exchanges/binance/update-products.sh:

    // The MIN_NOTIONAL filter defines the minimum notional value allowed for an order on a symbol.
    // An orders notional value is the price * quantity.
    // In order to know the Value it is necessary to know the price which does not come on this JSon.
    // But I have the maxPrice which seems to be: price * 10
    var maxPrice       = Number(market.info.filters[0].maxPrice);
    var curPrice       = maxPrice / 10;
    var minNotional    = Number(market.info.filters[2].minNotional);
    var minNotionalQty = minNotional / curPrice;
    var minQty         = Number(market.info.filters[1].minQty);
    var min_size       = Math.max(minQty, minNotionalQty).toString();

However,

Solution ?

I see two solutions:

  • Changing to code of extensions/exchanges/binance/update-products.sh to compute a new min_quantity value. It will block some valid orders, and it's dirty, but easy to do.
  • Adding a min_notional attribute in product.js and using its value in the engine. Far better, but more complex.

@DeviaVir what do you think ?

BAKFR pushed a commit to BAKFR/zenbot that referenced this issue Dec 10, 2018
Changes with the previous version:
- Binance filters are selected by type rather than by index. It fixes DeviaVir#1794
- No more useless removal of trailing zeros of 'increment' and 'asset_increment'
- Binance notional filter is set in `product.min_total` rather than roughly modifying `product.min_size`.
  It fixes DeviaVir#1793
YarnSeemannsgarn pushed a commit to YarnSeemannsgarn/zenbot that referenced this issue Apr 15, 2020
* Engine: Split code about check of minimal order size into a function

The function avoid code duplication and is more easily readable.

Small behavior change: the new function accept products with both `min_size` and `min_total`.
Previously, only the first one available was checked.

* Binance: rewrite update-products to fix bugs

Changes with the previous version:
- Binance filters are selected by type rather than by index. It fixes DeviaVir#1794
- No more useless removal of trailing zeros of 'increment' and 'asset_increment'
- Binance notional filter is set in `product.min_total` rather than roughly modifying `product.min_size`.
  It fixes DeviaVir#1793
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