-
Notifications
You must be signed in to change notification settings - Fork 0
/
talibtest.js
56 lines (47 loc) · 1.58 KB
/
talibtest.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
global.talib = require('talib');
global.config = require('./config/config.json');
global.mongoose = require('mongoose');
global.MongoClient = require('mongodb').MongoClient;
global.co = require('co');
global.parallel = require('co-parallel');
global.thunkify = require('thunkify');
global.util = require('util');
global. _ = require("underscore");
global.json2xls = require('json2xls');
global.fs = require('fs');
try {
global.mongoURI = global.config.mongoDbConn;
}
catch (err) {
global.mongoURI = global.config.mongoDbConn;
}
mongoose.connect(global.mongoURI);
console.log("TALib Version: " + talib.version);
require('./Schema/stockDayQuoteSchema.js')();
require('./Schema/stockProfileSchema.js')();
require('./Schema/stockQuotesArray.js')();
var StockDayQuoteModel = mongoose.model("StockDayQuote");
var StockProfileModel = mongoose.model("StockProfile");
var StockQuotesArrayModel = mongoose.model("StockQuotesArray");
mongoose.connection.on("open", function (err) {
if (err != undefined)
console.log(err.message);
else
console.log("connected");
console.log(util.inspect(talib.explain("ADX"), { depth:3 }));
var marketContents = fs.readFileSync('./examples/marketdata.json','utf8');
var marketData = JSON.parse(marketContents);
talib.execute({
name: "ADX",
startIdx: 0,
endIdx: marketData.close.length - 1,
high: marketData.high,
low: marketData.low,
close: marketData.close,
optInTimePeriod: 9
}, function (result) {
// Show the result array
console.log("ADX Function Results:");
console.log(result);
});
});