UNPKG

sql-synergy

Version:

Synergy Wave TA

63 lines (62 loc) 2.15 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.LoadData = void 0; const IConstants_1 = require("./IConstants"); const TickerQuotes_1 = require("./TickerQuotes"); const MSQuote_1 = require("./MSQuote"); //const dfd = require("danfojs-node"); var DataFrame = require('dataframe-js').DataFrame; const resolve = require('path').resolve; class LoadData { constructor(sSymbol, iPeriod) { this.o = null; this.sSymbol = "LoadDataSymbolUnSet"; this.iPeriod = -1; this.sPeriod = ""; this.sSymbol = sSymbol; this.iPeriod = iPeriod; this.sPeriod = IConstants_1.IConstants.sChartPeriods[iPeriod]; } static addDF(sSymbolPeriod, df) { LoadData.oDF.set(sSymbolPeriod, df); } static deleteDF() { LoadData.oDF = new Map(); } static getDF(sSymbolPeriod) { return LoadData.oDF.get(sSymbolPeriod); } getData(df = undefined) { // var done = false; let oQ = new TickerQuotes_1.TickerQuotes(this.sSymbol, this.iPeriod); df = LoadData.getDF(this.sSymbol + "_" + this.iPeriod); if (df !== undefined) { let data = df.toArray(); for (var value of data) { oQ.addOHLC(value); } this.o = new MSQuote_1.MSQuote(oQ); this.o.iPC = this.iPeriod; // console.log("Returning... " + this.sPeriod) ; return this.o; } console.log("Loading... " + this.sPeriod); // dfd.read_json('./data/' + this.sSymbol + '/' + this.sPeriod + '.json') // .then((df: any) => { // console.log(df) ; // for (var value of df.data) { // oQ.addOHLC(value); // } // this.o = new MSQuote(oQ); // this.o.iPC = this.iPeriod; // done = true; // }); // console.log("Waiting..") // require('deasync').loopWhile(function () { // return !done; // }); return this.o; } } exports.LoadData = LoadData; LoadData.oDF = new Map();