manu354 / cryptocurrency-arbitrage

A cryptocurrency arbitrage opportunity calculator. Over 800 currencies and 50 markets.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Problems with getting data from Poloniex

WW-build opened this issue · comments

Hi,
after starting parser it can't get data from Poloniex:

Error getting JSON response from https://poloniex.com/public?command=returnTicker SyntaxError: Unexpected token < in JSON at position 0
at JSON.parse ()
at Request._callback (/opt/arbitrage/main.js:41:33)
at Request.self.callback (/opt/arbitrage/node_modules/request/request.js:186:22)
at Request.emit (events.js:159:13)
at Request. (/opt/arbitrage/node_modules/request/request.js:1163:10)
at Request.emit (events.js:159:13)
at IncomingMessage. (/opt/arbitrage/node_modules/request/request.js:1085:12)
at Object.onceWrapper (events.js:254:19)
at IncomingMessage.emit (events.js:164:20)
at endReadableNT (_stream_readable.js:1054:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)

Getting data from other markets working fine.

I usually get this error when an exchange's API is down or offline. If it is operational then poloniex probably has a new endpoint.

I have the same issue.
It seems Poloniex has a security check (One More Step) which returns a HTML instead a string in JSON format.

{
    marketName: 'poloniex',
    URL: 'https://poloniex.com/public?command=returnTicker',
    toBTCURL: false,
    pairURL : '',
    last: function (data, coin_prices) { //Where to find the last price of coin in JSON data
        return new Promise(function (res, rej) {
            try {
                for (var obj in data) {
                    if(obj.includes('BTC_')&&obj!=="BTC_EMC2") {
                        let coinName = obj.replace("BTC_", '');
                        if (!coin_prices[coinName]) coin_prices[coinName] = {};
                        coin_prices[coinName].poloniex = data[obj].last;
                    }
                }
                res(coin_prices);
            }
            catch (err) {
                console.log(err);
                rej(err);
            }

        })
    },

},