Created
February 5, 2018 12:55
-
-
Save kobkrit/ee3f5d04a2d93a2ff068662594fc4075 to your computer and use it in GitHub Desktop.
Bitcoin Statistic in Hourly extraction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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