Skip to content

Instantly share code, notes, and snippets.

@kobkrit
Created February 5, 2018 12:55
Show Gist options
  • Save kobkrit/ee3f5d04a2d93a2ff068662594fc4075 to your computer and use it in GitHub Desktop.
Save kobkrit/ee3f5d04a2d93a2ff068662594fc4075 to your computer and use it in GitHub Desktop.
Bitcoin Statistic in Hourly extraction
var moment = require('moment');
var histohour = require('./histohour.json');
var stats = require("stats-lite")
var d = histohour.Data;
let h = {};
for (let i=0;i<d.length;i++){
let date = moment(d[i].time*1000);
console.log(date);
let hour = date.hours();
let diff = d[i].close - d[i].open;
if (!h[hour]){
h[hour] = [];
}
h[hour].push(diff);
}
for (let i=1;i<=23;i++){
console.log("hour="+i+" mean="+stats.mean(h[i])+" sd="+stats.stdev(h[i])+" max="+Math.max.apply(null, h[i]).toFixed(2)+" min="+Math.min.apply(null, h[i]).toFixed(2));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment