DeviaVir / zenbot

Zenbot is a command-line cryptocurrency trading bot using Node.js and MongoDB.
MIT License
8.22k stars 2.04k forks source link

Bitstamp get balance not working #1956

Open sanitariu opened 4 years ago

sanitariu commented 4 years ago

I cloned latest git (unstable) version of zenbot. I did npm install so far no problems then i filled my bistamp key/secret/client id and tried:

./zenbot.sh balance bitstamp.BTC-USD

Bitstamp API is not answering! unable to call getQuote, retrying in 2s

Anyone have any idea about this ? Do bitstamp work at all ?

sanitariu commented 4 years ago

After waiting 2-3 errors finally i got my balance and quote:

Bitstamp API is not answering! unable to call getQuote, retrying in 2s 2019-10-20 14:20:26 7945.64 BTC-USD

Seems like timeout is too low for bitstamp ? Anyone knows where i can touch this ?

KlausKnopper commented 4 years ago

I ran into this problem, too, when checking back on zenbot with bitstamp, and looked into the code written by tuxitor.

Apparently the way extensions/exchanges/bitstamp.js gets trades and quotes information from bitstamp is, or rather was, a specially prepared websocket stream from pusher.com which had to be subscribed to by a registered app key, hardcoded in bitstamp.js line 59: var BITSTAMP_PUSHER_KEY = 'de504dc5763aeef9ff52'

pusher.com now reports (which is invisible on the console, but an strace reveals it) "App key de504dc5763aeef9ff52 not in this cluster.", which probably means that the trade data stream is no longer available from there.

Since information from this stream is also used for calculating the balances BTC vs. USD value, also the "balance" zenbot command fails, unless you change line 122 of bitstamp.js:

var wsquotes = {} // zenbot unstable branch

back to

var wsquotes = {bid: 0, ask: 0} // zenbot master branch

which allows display of the raw balance once connection to the real bitstamp succeeds using your API data, even without the live data stream from pusher.com.

I wonder why pusher.com was used for a websocket connection instead of bitstamps own websocket. Can someone explain? Easier to parse maybe?

I do think it would be more secure to read the data from bitstamp directly, though, even when using the older https API instead of the new websocket API, documented here: https://www.bitstamp.net/websocket/v2/ https://www.bitstamp.net/api/

Regards -Klaus