sql-synergy
Version:
Synergy Wave TA
82 lines (81 loc) • 2.24 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Analyzer = void 0;
class Analyzer {
constructor(oPC) {
this.iSignalDay = 0;
// abstract hasBuySignal ( iDay:number ):boolean ;
// abstract hasSellSignal ( iDay:number ):boolean ;
this.fAction = [];
this.oPC = oPC;
this.fAction = new Array(this.size()).fill(0);
}
size() {
return this.oPC.size();
}
getSignalDay() {
return this.iSignalDay;
}
getSignalDate() {
return "" + this.oPC.getDate()[this.iSignalDay];
}
getSingalDateInt() {
return this.oPC.getDate()[this.iSignalDay];
}
static getOPBUp(f) {
return f;
// return SYGOPB.Up ( SYGOPB.SGX, f ) ;
}
static getOPBDown(f) {
return f;
// return SYGOPB.Dn ( SYGOPB.SGX, f ) ;
}
hasEnoughData(iDay = 0) {
return true;
}
hasBuySignal4Day(iDay) {
// if (this.hasEnoughData(iDay) == false)
// return false;
return this.fAction[iDay] == 1;
}
hasSellSignal4Day(iDay) {
// if (this.hasEnoughData(iDay) == false)
// return false;
return this.fAction[iDay] == -1;
}
hasBuySignal(iDay) {
this.iSignalDay = -1;
// if ( this.hasEnoughData ( iDay ) == false )
// return false ;
if (iDay >= this.fAction.length)
return false;
var n = iDay + 1;
while (--n > 0) {
if (this.fAction[n] > 0) {
this.iSignalDay = n;
return true;
}
if (this.fAction[n] < 0)
return false;
}
return false;
}
hasSellSignal(iDay) {
this.iSignalDay = -1;
if (iDay >= this.fAction.length)
return false;
// if ( this.hasEnoughData ( iDay ) == false )
// return false ;
var n = iDay + 1;
while (--n > 0) {
if (this.fAction[n] < 0) {
this.iSignalDay = n;
return true;
}
if (this.fAction[n] > 0)
return false;
}
return false;
}
}
exports.Analyzer = Analyzer;