Last active
December 15, 2017 05:29
-
-
Save kakopappa/cb89f2bd945a1214d3697246df786add to your computer and use it in GitHub Desktop.
nostradamus example
This file contains hidden or 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 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