sql-synergy
Version:
Synergy Wave TA
136 lines (135 loc) • 4.54 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TickerQuotes = void 0;
const IConstants_1 = require("./IConstants");
// const SMA = require('technicalindicators').SMA;
// const RSI = require('technicalindicators').RSI;
// const MACD = require('technicalindicators').MACD;
// const Stochastic = require('technicalindicators').Stochastic
class TickerQuotes {
constructor(sSymbol, iPC) {
this.iData = new Array(0); // OHLC
this.iPC = -1;
this.sSymbol = "NOTSET";
this.sSymbol = sSymbol;
this.iPC = iPC;
}
getSymbol() {
return this.sSymbol;
}
getPeriod() {
return this.iPC;
}
// public getStockFileName():string
// {
// return this.getSymbol() ;
// }
getData(iPC = IConstants_1.IConstants.DAILY) {
//TODO return daily chart
return this.iData;
}
setOHLC(OHLC) {
this.iData = OHLC;
}
addOHLC(OHLC) {
// OHLC[0] = OHLC[0]/1000 ;
this.iData.push(OHLC); //OHLC.map(Number)) ;
}
getSize() { return this.iData.length; }
// getUpStick(iDay: number): number {
// if (iDay >= this.iData.length)
// return 0.0;
// return this.iData[iDay][IConstants.HIGH] - Math.max(this.iData[iDay][IConstants.OPEN], this.iData[iDay][IConstants.CLOSE]);
// }
// getDownStick(iDay: number): number {
// if (iDay >= this.iData.length)
// return 0.0;
// return Math.min(this.iData[iDay][IConstants.OPEN], this.iData[iDay][IConstants.CLOSE]) - this.iData[iDay][IConstants.LOW];
// }
getOpen(iDay) {
return this.iData[iDay][IConstants_1.IConstants.OPEN];
}
getHigh(iDay) {
return this.iData[iDay][IConstants_1.IConstants.HIGH];
}
getLow(iDay) {
return this.iData[iDay][IConstants_1.IConstants.LOW];
}
getClose(iDay) {
return this.iData[iDay][IConstants_1.IConstants.CLOSE];
}
getDate(iDay) {
return this.iData[iDay][IConstants_1.IConstants.DATE_TIME];
}
getLastDay() {
return this.getSize() - 1;
}
getBody(iDay) {
if (iDay >= this.iData.length)
return 0.0;
return Math.abs(this.iData[iDay][IConstants_1.IConstants.OPEN] - this.iData[iDay][IConstants_1.IConstants.CLOSE]);
}
// isWhiteCandle(iDay: number): boolean {
// if (iDay >= this.iData.length)
// return false;
// return this.iData[iDay][IConstants.OPEN] < this.iData[iDay][IConstants.CLOSE];
// }
// isBlackCandle(iDay: number): boolean {
// if (iDay >= this.iData.length)
// return false;
// return this.iData[iDay][IConstants.OPEN] > this.iData[iDay][IConstants.CLOSE];
// }
// isNonReversal(iDay: number): boolean {
// return this.getBody(iDay) > 2 * (this.getUpStick(iDay) + this.getDownStick(iDay));
// }
// isWhiteAndNonReversal(iDay: number): boolean {
// return this.isWhiteCandle(iDay) && this.isNonReversal(iDay);
// }
// isBlackAndNonReversal(iDay: number): boolean {
// return this.isBlackCandle(iDay) && this.isNonReversal(iDay);
// }
// channelHighBroken ( iDay:number ):boolean
// {
// if ( this.isWhiteAndNonReversal ( iDay ) == false )
// return false ;
// return this.getClose ( iDay ) > this.getCH ( iDay ) ;
// }
// channelLowBroken ( iDay:number ):boolean
// {
// if ( this.isBlackAndNonReversal ( iDay ) == false )
// return false ;
// return this.getClose ( iDay ) < this.getCL ( iDay ) ;
// }
// channelLowJustBroken ( iDay:number ):boolean
// {
// if ( !this.channelLowBroken ( iDay ) )
// return false ;
// while ( --iDay > 0 )
// {
// if ( this.channelHighBroken ( iDay ) )
// return true ;
// if ( this.channelLowBroken ( iDay ) )
// return false ;
// }
// return true ;
// }
// channelHighJustBroken ( iDay:number ):boolean
// {
// if ( !this.channelHighBroken ( iDay ) )
// return false ;
// while ( --iDay > 0 )
// {
// if ( this.channelLowBroken ( iDay ) )
// return true ;
// if ( this.channelHighBroken ( iDay ) )
// return false ;
// }
// return true ;
// }
getColumn(iColumn) {
return this.iData.map(function (r) {
return r[iColumn];
});
}
}
exports.TickerQuotes = TickerQuotes;