UNPKG

fme-fv-fetch

Version:

This fetches the fair-value numbers from index-arb.com

49 lines 1.73 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const fme_logger_1 = require("fme-logger"); const cheerio = require("cheerio"); const request = require("request"); var L = new fme_logger_1.Log("fv-fetch"); class FairValues { constructor() { this.timeStamp = new Date(); this.SPX = ""; this.NQ = ""; this.DOW = ""; this.SPX = this.NQ = this.DOW = "N/A"; this.timeStamp = new Date(); } } exports.FairValues = FairValues; class FairValue { fetch() { L.debug("fetching Fair Values"); this.fairValues = new FairValues(); request({ uri: 'http://indexarb.com', }, (err, res, body) => { var $ = cheerio.load(body); var idx = 0; var td = $("td"); // L.info(td.length); // for (var i=0; i<td.length; i++) { // L.info(i,td[i].children[0].data); // } var spx = td[66].children[0].data; if (typeof spx == "string") { this.fairValues.SPX = spx.replace(/[^0-9.+-]/g, ""); } var nq = td[72].children[0].data; if (typeof nq == "string") { this.fairValues.NQ = nq.replace(/[^0-9.+-]/g, ""); } var dow = td[78].children[0].data; if (typeof dow == "string") { this.fairValues.DOW = dow.replace(/[^0-9.+-]/g, ""); } L.info("SPX FV:", this.fairValues.SPX, " NQ FV:", this.fairValues.NQ, "DOW FV:", this.fairValues.DOW); }); } } exports.FairValue = FairValue; //# sourceMappingURL=fv-fetch.js.map