Reputation: 11
I have the following code:
var urlKraken1 = "https://api.kraken.com/0/public/OHLC?pair=XBTUSD&interval=1";
request({
url: urlKraken1,
json: true
}, function (error, response, body) {
if (!error && response.statusCode === 200) {
var valuesArray = [];
var cur = body.result.XXBTZUSD.length -1;
var time = body.result.XXBTZUSD[cur][0];
var high = body.result.XXBTZUSD[cur][2];
var low = body.result.XXBTZUSD[cur][3];
var open = body.result.XXBTZUSD[cur][1];
var close = body.result.XXBTZUSD[cur][4];
var volume = body.result.XXBTZUSD[cur][6];
var Currency1 = "BTC";
var Currency2 = "USD";
valuesArray.push([time, "kraken.com", Currency1, Currency2, high, low, open, close, volume]);
writeMultiRows("kraken.com", Currency1, valuesArray);
}
But in my database I'm getting values which are not correct with the ones from the API. Data I receive for example:
time = 1499280240
high = 2609.001
low = 2608.666
open = 2609.001
close = 2608.666
volume= 12.42484963
But I should receive:
time = 1499280240
high = 2610.000
low = 2605.022
open = 2609.001
close = 2610.000
volume= 15.42483298
Thanks in advance for every kind of tips and help!
Upvotes: 0
Views: 194
Reputation: 170
The data which your assigning is wrong. press f12 and open network tab and check the network response to see the exact data... Assign the array accordingly...
Upvotes: 1