Skip to content

Instantly share code, notes, and snippets.

@kakopappa
Last active December 15, 2017 05:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kakopappa/cb89f2bd945a1214d3697246df786add to your computer and use it in GitHub Desktop.
Save kakopappa/cb89f2bd945a1214d3697246df786add to your computer and use it in GitHub Desktop.
nostradamus example
var request = require("request");
var forecast = require('nostradamus');
var stockQuotes = []; var nostroData = []; var predictions = [];
var alpha = 0.5; var beta = 0.4; var gamma = 0.6; var period = 5; var m = 2;
var url = "http://www.google.com/finance/getprices?i=900&p=5d&f=d,o,h,l,c,v&df=cpct&q=(ticker)";
url = url.replace('(ticker)', 'AAPL');
request({
url: url,
json: true
}, function (error, response, body) {
if (!error && response.statusCode === 200) {
var quotes = body.split("\n");
var quoteItems = [];
quotes.forEach(function(quote){
quoteItems = quote.split(",");
if (isNaN(quoteItems[0]) == false && isNaN(quoteItems[0]) == false) {
stockQuotes.push({'date': quoteItems[0], 'quote': quoteItems[1]});
// console.log({'date': quoteItems[0], 'quote': quoteItems[1]});
nostroData.push(parseFloat(quoteItems[1]));
}
});
console.log(nostroData.length);
console.log(forecast(nostroData, alpha, beta, gamma, period, m));
}
})
//https://github.com/dfwcrew/stock-analyzerjs/blob/2507b69e0f2f476bc982853366469966d03d3558/routes.js
//https://github.com/AndrusAsumets/veriff-tryout/blob/10f967394989c5178237e39dfd296985c8c4d7de/proxy/app.js
//https://github.com/diegorod/Bitcoin-Price-Predictor/blob/master/js/prediction.js
//https://github.com/hakanensari/fixer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment