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

Bittrex balances are inverted #277

Closed
alessionobile opened this issue Jun 12, 2017 · 19 comments
Closed

Bittrex balances are inverted #277

alessionobile opened this issue Jun 12, 2017 · 19 comments
Labels

Comments

@alessionobile
Copy link

Hi guys

Testing Zenbot, both live trade and paper mode, i noticed that balances are inverted.
I am trading on bittrex.BTC-ETH and it tells me that i have 1 BTC and 0 ETH, while in reality i have 1 ETH and 0 BTC.

@DeviaVir is also mentioning it here
https://github.com/carlos8f/zenbot/blob/master/extensions/exchanges/bittrex/exchange.js#L122

Tried to fix it in update-products.sh and exchange.js, but it doesn't help, as there are calls from engine.js that should also be adapted.

Any suggestions?

@DeviaVir
Copy link
Owner

Noticed the same thing, but it's "just" a cosmetic thing. Buy/sell/trade should still be doing the right things. Hence why I haven't been too interested in trying to fix it. It's definitely a bug, though.

@DeviaVir DeviaVir added the bug label Jun 12, 2017
@alessionobile
Copy link
Author

thanks for the feedback @DeviaVir
Will give it a deeper look and see if I can help with the fix

@DeviaVir
Copy link
Owner

much appreciated @Netziro!

@alessionobile
Copy link
Author

alessionobile commented Jun 13, 2017

@DeviaVir
I suspect for a proper fix we should "just" change a little the implementation of lib.normalize-selector and exchange.joinProduct :-)

Under my point of view, exchange.joinProduct should return an object with currency and asset clearly defined and maybe move the init of the exchange selector in a stand alone library that will take care about normalizing the selector, initiating the exchange object which will parse asset and currency from a local function that can be adapted and customized as needed within the exchange object scope.
Following this design all calls from trade.js, engine.js or everything else outside the exchange library, should only call a function from the new library in order to fetch currency and asset, avoiding code redundancy and splits all over the place.

Basically you end up creating a Selector library that works as an abstract or router towards exchanges objects.

Even better, would be to actually specify asset, currency and exchange as arguments, so the subsystem will always have clear configurations which will be then interpreted/combined by exchanges as needed. It would mean a major change.

There is always the quick and dirty solution, fixing the output cosmetic but perhaps making the code cosmetic a little uglier.

What's your thought?

@FreshLondon
Copy link

FreshLondon commented Jun 14, 2017

@DeviaVir - "Noticed the same thing, but it's "just" a cosmetic thing. Buy/sell/trade should still be doing the right things. Hence why I haven't been too interested in trying to fix it. It's definitely a bug, though."

Yes, although if the bot is thinking it has the loads of BTC and attempts to put down tiny sell orders of the asset (using the figure in BTC rather than the sum of asset) the exchange often comes back with an error stating it cant be less than 50k satoshi per order placement.
..which of course wouldn't be the case if the balances were swapped the other way around!

I did have a look into editing this one but JS is not the language i write in, help needed from you guys for sure 😃

@MCrypto
Copy link

MCrypto commented Jun 14, 2017

I believe that what is @CreativeBacon is mentioning is what i keep seeing ... i keep seeing this 50k satoshi msg.

[https://github.com//issues/280#issuecomment-308235224]

@FreshLondon
Copy link

exactly, which seems to only be occuring as the balances are swapped and its trying to trade a crazy small amount of crypto 👍

@grooter
Copy link

grooter commented Jun 23, 2017

I have the same mistake,
Can you tell me if there will be a solution soon?
It's important to trade on bittrex, since other exchanges do not support my country.

@MCrypto
Copy link

MCrypto commented Jun 24, 2017

Im now getting this output (note that order is placed alright on bittrex):

2017-06-24 23:31:53 0.00 BTC-ZCL +0.0% 150 - 0.12% 7.45004 BTC 0.00 ZCL -2.0% +0.0%DUST_TRADE_DISALLOWED_MIN_VALUE_50K_SAT
DUST_TRADE_DISALLOWED_MIN_VALUE_50K_SAT
DUST_TRADE_DISALLOWED_MIN_VALUE_50K_SAT
DUST_TRADE_DISALLOWED_MIN_VALUE_50K_SAT
DUST_TRADE_DISALLOWED_MIN_VALUE_50K_SAT
DUST_TRADE_DISALLOWED_MIN_VALUE_50K_SAT
DUST_TRADE_DISALLOWED_MIN_VALUE_50K_SAT
DUST_TRADE_DISALLOWED_MIN_VALUE_50K_SAT

{ Error: order not found in cache
at Object.getOrder (/home/mylin/Bots/zenbot/extensions/exchanges/bittrex/exchange.js:263:29)
at Timeout.checkOrder [as _onTimeout] (/home/mylin/Bots/zenbot/lib/engine.js:275:24)
at ontimeout (timers.js:386:14)
at tryOnTimeout (timers.js:250:5)
at Timer.listOnTimeout (timers.js:214:5) desc: 'could not execute sell: error placing order' }

undefined
UUID_INVALID
undefined

@asterismo
Copy link

I'm getting the same thing plus Zenbot is buying high and selling low, so losing money. Can we just multiply everything times -1?

@asterismo
Copy link

2017-07-28 07:03:00 0.00276750 BTC-ANS +0.0% 213 64 ++ 0.0328 0.0119 buy 0.02664 BTC 0.01 ANS -0.8% -1.8%
2017-07-28 07:03:01 0.00276750 BTC-ANS +0.0% 7 64 ++ 0.0310 0.0136 0.02664 BTC 0.01 ANS -0.8% -1.8%
2017-07-28 07:04:00 0.00277626 BTC-ANS +0.3% 460 69 +++ 0.0482 0.0139 2.63939 BTC 0.00 ANS -0.2% -1.5%
2017-07-28 07:05:00 0.00277626 BTC-ANS +0.0% 1468 69 +++ 0.0456 0.0173 2.63939 BTC 0.00 ANS -0.2% -1.5%
2017-07-28 07:06:00 0.00277626 BTC-ANS +0.0% 309 69 +++ 0.0431 0.0171 2.63939 BTC 0.00 ANS -0.2% -1.5%
2017-07-28 07:07:00 0.00275250 BTC-ANS -0.9% 467 - 47 -0.0059 0.0170 2.63939 BTC 0.00 ANS -1.0% -1.5%
2017-07-28 07:08:00 0.00275251 BTC-ANS +0.0% 459 - 47 -0.0055 0.0184 2.63939 BTC 0.00 ANS -1.0% -1.5%
2017-07-28 07:09:00 0.00275251 BTC-ANS +0.0% 7 - 47 -0.0052 0.0195 2.63939 BTC 0.00 ANS -1.0% -1.5%
2017-07-28 07:10:00 0.00277617 BTC-ANS +0.9% 572 62 ++ 0.0415 0.0209 2.63939 BTC 0.00 ANS -0.2% -1.5%
2017-07-28 07:11:00 0.00277626 BTC-ANS +0.0% 1067 62 ++ 0.0394 0.0212 2.63939 BTC 0.00 ANS -0.2% -1.5%
2017-07-28 07:12:00 0.00277750 BTC-ANS +0.0% 167 63 ++ 0.0397 0.0207 2.63939 BTC 0.00 ANS -0.1% -1.5%
2017-07-28 07:13:00 0.00277750 BTC-ANS +0.0% 108 63 ++ 0.0375 0.0209 2.63939 BTC 0.00 ANS -0.1% -1.5%
2017-07-28 07:14:00 0.00277600 BTC-ANS -0.1% 892 61 ++ 0.0325 0.0210 2.63939 BTC 0.00 ANS -0.2% -1.5%
2017-07-28 07:16:00 0.00277600 BTC-ANS +0.0% 190 61 ++ 0.0308 0.0201 2.63939 BTC 0.00 ANS -0.2% -1.5%
2017-07-28 07:17:00 0.00277600 BTC-ANS +0.0% 81 61 ++ 0.0291 0.0192 2.63939 BTC 0.00 ANS -0.2% -1.5%
2017-07-28 07:18:00 0.00277607 BTC-ANS +0.0% 39 61 ++ 0.0277 0.0184 2.63939 BTC 0.00 ANS -0.2% -1.5%
2017-07-28 07:19:00 0.00277750 BTC-ANS +0.1% 267 62 ++ 0.0289 0.0159 2.63939 BTC 0.00 ANS -0.1% -1.5%
2017-07-28 07:20:00 0.00277750 BTC-ANS +0.0% 125 62 ++ 0.0274 0.0122 2.63939 BTC 0.00 ANS -0.1% -1.5%
2017-07-28 07:21:00 0.00277750 BTC-ANS +0.0% 2748 62 ++ 0.0259 0.0050 2.63939 BTC 0.00 ANS -0.1% -1.5%
2017-07-28 07:22:00 0.00277749 BTC-ANS 0.0% 541 62 ++ 0.0245 0.0047 2.63939 BTC 0.00 ANS -0.1% -1.5%
2017-07-28 07:23:00 0.00277703 BTC-ANS 0.0% 30 61 ++ 0.0222 0.0045 2.63939 BTC 0.00 ANS -0.1% -1.5%
2017-07-28 07:24:00 0.00277703 BTC-ANS +0.0% 42 61 ++ 0.0210 0.0040 2.63939 BTC 0.00 ANS -0.1% -1.5%
2017-07-28 07:25:00 0.00277706 BTC-ANS +0.0% 74 62 ++ 0.0199 0.0034 2.63939 BTC 0.00 ANS -0.1% -1.5%
2017-07-28 07:26:00 0.00277583 BTC-ANS 0.0% 40 59 ++ 0.0165 0.0034 2.63939 BTC 0.00 ANS -0.2% -1.5%
2017-07-28 07:27:00 0.00277524 BTC-ANS 0.0% 129 58 ++ 0.0144 0.0039 2.63939 BTC 0.00 ANS -0.2% -1.5%
2017-07-28 07:28:00 0.00277100 BTC-ANS -0.2% 27 50 + 0.0054 0.0047 2.63939 BTC 0.00 ANS -0.3% -1.5%
2017-07-28 07:29:00 0.00277522 BTC-ANS +0.2% 27 56 ++ 0.0133 0.0064 2.63939 BTC 0.00 ANS -0.2% -1.5%
2017-07-28 07:30:00 0.00277750 BTC-ANS +0.1% 1459 59 ++ 0.0170 0.0061 2.63939 BTC 0.00 ANS -0.1% -1.5%
2017-07-28 07:31:00 0.00277750 BTC-ANS +0.0% 29 59 ++ 0.0161 0.0055 2.63939 BTC 0.00 ANS -0.1% -1.5%
2017-07-28 07:32:00 0.00277750 BTC-ANS +0.0% 153 59 ++ 0.0152 0.0049 2.63939 BTC 0.00 ANS -0.1% -1.5%
2017-07-28 07:33:00 0.00277945 BTC-ANS +0.1% 178 62 ++ 0.0182 0.0043 2.63939 BTC 0.00 ANS 0.0% -1.5%
2017-07-28 07:34:00 0.00277947 BTC-ANS +0.0% 469 62 ++ 0.0173 0.0039 2.63939 BTC 0.00 ANS 0.0% -1.5%
2017-07-28 07:35:00 0.00277947 BTC-ANS +0.0% 222 62 ++ 0.0163 0.0036 2.63939 BTC 0.00 ANS 0.0% -1.5%
2017-07-28 07:36:00 0.00278184 BTC-ANS +0.1% 573 66 +++ 0.0201 0.0033 2.63939 BTC 0.00 ANS +0.0% -1.5%
2017-07-28 07:37:00 0.00278000 BTC-ANS -0.1% 165 61 ++ 0.0154 0.0036 2.63939 BTC 0.00 ANS 0.0% -1.5%
2017-07-28 07:38:00 0.00279000 BTC-ANS +0.4% 668 73 +++ 0.0341 0.0039 2.63939 BTC 0.00 ANS +0.3% -1.5%
2017-07-28 07:39:00 0.00278200 BTC-ANS -0.3% 703 58 ++ 0.0166 0.0053 2.63939 BTC 0.00 ANS +0.0% -1.5%
2017-07-28 07:40:00 0.00278000 BTC-ANS -0.1% 2513 55 ++ 0.0118 0.0051 2.63939 BTC 0.00 ANS 0.0% -1.5%
2017-07-28 07:41:00 0.00279000 BTC-ANS +0.4% 2571 65 +++ 0.0307 0.0055 2.63939 BTC 0.00 ANS +0.3% -1.5%
2017-07-28 07:42:00 0.00280104 BTC-ANS +0.4% 1326 72 +++ 0.0505 0.0070 2.63939 BTC 0.00 ANS +0.7% -1.5%
2017-07-28 07:43:00 0.00279322 BTC-ANS -0.3% 656 62 ++ 0.0325 0.0108 2.63939 BTC 0.00 ANS +0.4% -1.5%
2017-07-28 07:44:00 0.00278250 BTC-ANS -0.4% 331 52 + 0.0099 0.0110 2.63939 BTC 0.00 ANS +0.1% -1.5%
2017-07-28 07:45:00 0.00278000 BTC-ANS -0.1% 18 50 + 0.0045 0.0117 2.63939 BTC 0.00 ANS 0.0% -1.5%
2017-07-28 07:46:00 0.00278250 BTC-ANS +0.1% 326 52 + 0.0091 0.0127 2.63939 BTC 0.00 ANS +0.1% -1.5%
2017-07-28 07:47:00 0.00278250 BTC-ANS +0.0% 1101 52 + 0.0086 0.0133 2.63939 BTC 0.00 ANS +0.1% -1.5%
2017-07-28 07:48:00 0.00278250 BTC-ANS +0.0% 675 52 + 0.0082 0.0137 2.63939 BTC 0.00 ANS +0.1% -1.5%
2017-07-28 07:49:00 0.00277523 BTC-ANS -0.3% 6524 -- 45 -0.0064 0.0136 2.63939 BTC 0.00 ANS -0.2% -1.5%
2017-07-28 07:50:00 0.00278250 BTC-ANS +0.3% 25 52 + 0.0081 0.0152 2.63939 BTC 0.00 ANS +0.1% -1.5%
2017-07-28 07:52:00 0.00280397 BTC-ANS +0.8% 3915 65 +++ 0.0494 0.0156 2.63939 BTC 0.00 ANS +0.8% -1.5%
2017-07-28 07:53:00 0.00278250 BTC-ANS -0.8% 137 50 + 0.0049 0.0178 2.63939 BTC 0.00 ANS +0.1% -1.5%
2017-07-28 07:54:00 0.00280000 BTC-ANS +0.6% 996 59 ++ 0.0387 0.0147 2.63939 BTC 0.00 ANS +0.7% -1.5%
2017-07-28 07:55:00 0.00277523 BTC-ANS -0.9% 1109 - 47 -0.0115 0.0155 2.63939 BTC 0.00 ANS -0.2% -1.5%
2017-07-28 07:56:00 0.00280000 BTC-ANS +0.9% 375 56 ++ 0.0372 0.0171 2.63939 BTC 0.00 ANS +0.7% -1.5%
2017-07-28 07:57:00 0.00277555 BTC-ANS -0.9% 1172 - 47 -0.0123 0.0184 2.63939 BTC 0.00 ANS -0.2% -1.5%
2017-07-28 07:59:00 0.00277503 BTC-ANS 0.0% 100 - 47 -0.0127 0.0199 2.63939 BTC 0.00 ANS -0.2% -1.5%
2017-07-28 08:00:00 0.00279998 BTC-ANS +0.9% 33 55 ++ 0.0365 0.0212 2.63939 BTC 0.00 ANS +0.7% -1.5%
2017-07-28 08:01:00 0.00277503 BTC-ANS -0.9% 622 - 47 -0.0139 0.0225 2.63939 BTC 0.00 ANS -0.2% -1.5%
2017-07-28 08:02:00 0.00277500 BTC-ANS 0.0% 2265 - 47 -0.0132 0.0231 2.63939 BTC 0.00 ANS -0.2% -1.5%
2017-07-28 08:03:00 0.00277500 BTC-ANS +0.0% 460 - 47 -0.0125 0.0243 2.63939 BTC 0.00 ANS -0.2% -1.5%
2017-07-28 08:04:00 0.00275000 BTC-ANS -0.9% 15173 -- 40 -0.0604 0.0221 sell 2.63939 BTC 0.00 ANS -1.1% -1.5%
2017-07-28 08:04:48 0.00275425 BTC-ANS +0.2% 6 -- 42 -0.0489 0.0285 selling 0.02639 BTC 0.00 ANS -98.3% -98.3%
sell order completed at 2017-07-28 05:07:16:

2.61299928 BTC at 0.00275000 ANS
total 0.00718575 ANS
0.7273% slippage (orig. price 0.00277000 ANS)
execution: 2 minutes

This are my negative earnings from the transaction history from Bittrex

07/28/2017 05:07:19 AM 07/28/2017 05:06:23 AM Limit Sell 0.00275000 2.61299928 2.61299928 0.00274999 0.00716778
07/28/2017 04:03:49 AM 07/28/2017 04:03:43 AM Limit Buy 0.00275208 2.61274931 2.61274931 0.00275207 -0.00720846

@asterismo
Copy link

The bot also buys high and attempt to sell low in Poloniex. Candle data is inverted, show green text when stock is at sale on red in web graph.

@shadowrider26
Copy link

shadowrider26 commented Aug 9, 2017

DUST_TRADE_DISALLOWED_MIN_VALUE_50K_SAT

I think its looking at the minimum coin amount in the bittrex products file.
Set the minimum for your coin in ./extensions/exchanges/bittrex/products.json
They all default to 0.01 so change your coin minimum to a value that exceeds 50k sats (or greater) as min.

@fishfugu
Copy link

fishfugu commented Aug 14, 2017

I'm confused - is this causing a problem with the calculation of the strategy or not? Early comments above claim it's "just cosmetic" but other comments are claiming it might lead to miscalculations of amounts to trade. If it's miscalculating amount to trade - does that mean it could be miscalculating the strategy in other ways?

My run on bittrex.btc-eth also crashed due to #472. Are these connected at all?

Is it sensible to keep running this before it's fixed?

@redsh4de
Copy link
Contributor

Wouldn't it be possible to make the bot flip the viewable currency and asset tickers exclusively for Bittrex?

@vea45
Copy link

vea45 commented Aug 17, 2017

I think I fixed this issue. Do those changes:
On exchange.js:
line 39: return product_id.split('-')[1] + '-' + product_id.split('-')[0].
line 123:
if(opts.last_signal === 'buy') {
if (_balance['Currency'] === opts.currency.toUpperCase()) {
balance.currency = n(_balance.Available).format('0.00000000'),
balance.currency_hold = 0
}
if (_balance['Currency'] === opts.asset.toUpperCase()) {
balance.asset = n(_balance.Available).format('0.00000000'),
balance.asset_hold = 0
}
} else {
if (_balance['Currency'] === opts.asset.toUpperCase()) {
balance.asset = n(_balance.Available).format('0.00000000'),
balance.asset_hold = 0
}
if (_balance['Currency'] === opts.currency.toUpperCase()) {
balance.currency = n(_balance.Available).format('0.00000000'),
balance.currency_hold = 0
}
}

Also on update products.sh:
line 10 & 11:
asset: quote,
currency: base,

When finished execute the "update-products.sh" script and everything should work fine then.

@procmail
Copy link

Thanks vea45!

@relaxdev
Copy link

relaxdev commented Nov 8, 2017

Hi @DeviaVir , it is still happening with me. I always loss balances.

Opened Date Market Type Bid/Ask Actual Rate
11/8/17 12:25 BTC-NEO Limit Sell 0.00357 0.00356999
11/8/17 12:01 BTC-NEO Limit Buy 0.0036033 0.00360329
11/8/17 11:41 BTC-NEO Limit Sell 0.00358346 0.00358345
11/8/17 10:52 BTC-NEO Limit Buy 0.00359241 0.0035924
11/8/17 7:46 BTC-NEO Limit Sell 0.00368004 0.00368003
11/8/17 7:20 BTC-NEO Limit Buy 0.00368657 0.00368656

my command likes this: [ "trade", "--trend_ema=15", "--period=5m"].
Could you please advise ?

@ghost
Copy link

ghost commented Nov 8, 2017

Cosmetic or not, people are only as good as the data they action on.

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