Skip to content

Commit 17d9b14

Browse files
committed
Fixed one off issue
1 parent c9992c7 commit 17d9b14

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

server/api/backtest/backtest.service.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -515,20 +515,22 @@ class BacktestService {
515515
const idx = Number(key);
516516

517517
if (idx > minQuotes) {
518-
const q = quotes.slice(idx - minQuotes, idx);
518+
const q = quotes.slice(idx - minQuotes, idx + 1);
519519
getIndicatorQuotes.push(this.initStrategy(q));
520520
}
521521
});
522522

523523
return Promise.all(getIndicatorQuotes);
524524
})
525-
.then(indicators => {
525+
.then((indicators: Indicators[]) => {
526526
let testResults;
527+
527528
testResults = this.backtestIndicators(this.getAllRecommendations,
528529
indicators,
529530
parameters);
530531

531532
testResults.algo = 'All indicators';
533+
532534
return testResults;
533535
});
534536
}

src/app/rh-table/rh-table.component.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ <h3 class="table-title">Stocks</h3>
7878
<span *ngSwitchCase="'impliedMovement'">
7979
{{element?.impliedMovement | percent}}
8080
</span>
81+
<span *ngSwitchCase="'previousImpliedMovement'">
82+
{{element?.previousImpliedMovement | percent}}
83+
</span>
8184
<span *ngSwitchDefault>
8285
{{element[col.field]}}
8386
</span>

src/app/rh-table/rh-table.component.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ export class RhTableComponent implements OnInit, OnChanges, OnDestroy {
139139
{ field: 'upperResistance', header: 'Upper Resistance' },
140140
{ field: 'lowerResistance', header: 'Lower Resistance' },
141141
{ field: 'impliedMovement', header: 'Implied Movement' },
142+
{ field: 'previousImpliedMovement', header: 'Previous IM' },
142143
{ field: 'bearishProbability', header: 'Probability of Bear Profit' },
143144
{ field: 'bullishProbability', header: 'Probability of Bull Profit' },
144145

@@ -192,6 +193,7 @@ export class RhTableComponent implements OnInit, OnChanges, OnDestroy {
192193
{ field: 'sellSignals', header: 'Sell' },
193194
{ field: 'strongsellSignals', header: 'Strong Sell' },
194195
{ field: 'impliedMovement', header: 'Implied Movement' },
196+
{ field: 'previousImpliedMovement', header: 'Previous IM' },
195197
{ field: 'bearishProbability', header: 'Probability of Bear Profit' },
196198
{ field: 'bullishProbability', header: 'Probability of Bull Profit' }
197199
];
@@ -358,7 +360,8 @@ export class RhTableComponent implements OnInit, OnChanges, OnDestroy {
358360
if (lastSignal.recommendation.hasOwnProperty(indicator)) {
359361
const result = {
360362
algo: String(indicator),
361-
recommendation: 'Neutral'
363+
recommendation: 'Neutral',
364+
previousImpliedMovement: null
362365
};
363366
if (lastSignal.recommendation[indicator] === 'Bullish') {
364367
result.recommendation = 'Buy';
@@ -368,6 +371,8 @@ export class RhTableComponent implements OnInit, OnChanges, OnDestroy {
368371
bearishSignals.push(indicator);
369372
}
370373

374+
result.previousImpliedMovement = this.getPreviousImpliedMove(indicatorResults.signals[indicatorResults.signals.length - 2]);
375+
371376
const tableObj = {
372377
...indicatorResults,
373378
...result
@@ -377,7 +382,6 @@ export class RhTableComponent implements OnInit, OnChanges, OnDestroy {
377382
}
378383
}
379384

380-
381385
this.getProbability(bullishSignals, bearishSignals, testResults.signals)
382386
.subscribe((data) => {
383387
this.findAndUpdateIndicatorScore(param.ticker, {
@@ -411,6 +415,10 @@ export class RhTableComponent implements OnInit, OnChanges, OnDestroy {
411415
}
412416
}
413417

418+
private getPreviousImpliedMove(signal) {
419+
return signal.impliedMovement;
420+
}
421+
414422
scoreSignals(stock, signals) {
415423
this.dailyBacktestService.getSignalScores(signals)
416424
.subscribe((score) => {

0 commit comments

Comments
 (0)