Skip to content

Commit

Permalink
Remove preroll logic from strategyImpl and move it to base-strategy.ts (
Browse files Browse the repository at this point in the history
  • Loading branch information
Shawn8901 authored and notVitaliy committed Sep 6, 2018
1 parent bffc37c commit 41ee4b4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/strategy/strategies/base-strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export abstract class BaseStrategy<TOptions = any, TCalcResult = any> {
/* istanbul ignore next */
periodNewListener(() => {
const signal = this.onPeriod()
if (signal) {
if (signal && !this.isPreroll) {
this.signalEmitter({ signal })
}
})
Expand Down
4 changes: 2 additions & 2 deletions src/strategy/strategies/macd/macd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,12 @@ export class Macd extends BaseStrategy<MacdOptions, { rsi: number; signal: numbe
this.periods[0].avgGain = avgGain

this.periods[0].avgLoss = avgLoss
this.overbought = !this.isPreroll && rsi >= this.options.overboughtRsi && !this.overbought
this.overbought = rsi >= this.options.overboughtRsi && !this.overbought
}

public onPeriod() {
/* istanbul ignore next */
const signal = this.isPreroll ? null : this.overboughtSell() ? 'sell' : this.getSignal()
const signal = this.overboughtSell() ? 'sell' : this.getSignal()
/* istanbul ignore next */
if (this.periods.length) {
logger.verbose(
Expand Down

0 comments on commit 41ee4b4

Please sign in to comment.