Skip to content

Commit acdedde

Browse files
committed
Fix set list
1 parent 2c44037 commit acdedde

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

src/app/autopilot/autopilot.component.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,9 @@ export class AutopilotComponent implements OnInit, OnDestroy {
611611
}
612612

613613
async findSwingtrades(cb = async (stock: string, mlResult: number) => { }, stockList: (PortfolioInfoHolding[] | any[]) = CurrentStockList) {
614-
this.machineDaytradingService.setCurrentStockList(stockList);
614+
if (stockList) {
615+
this.machineDaytradingService.setCurrentStockList(stockList);
616+
}
615617
let stock;
616618
const found = (name) => {
617619
return Boolean(this.currentHoldings.find((value) => value.name === name));

src/app/machine-daytrading/machine-daytrading.service.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import * as moment from 'moment-timezone';
44
import * as _ from 'lodash';
55

66
import { BacktestService, MachineLearningService, PortfolioService } from '@shared/services';
7-
import{ CurrentStockList } from '../rh-table/stock-list.constant';
7+
import { CurrentStockList } from '../rh-table/stock-list.constant';
8+
import { shuffle } from '../rh-table/backtest-stocks.constant';
89
import { GlobalSettingsService } from '../settings/global-settings.service';
910
import { tap } from 'rxjs/operators';
1011

@@ -135,7 +136,7 @@ export class MachineDaytradingService {
135136

136137
getNextStock() {
137138
if (!this.currentStockList) {
138-
this.currentStockList = CurrentStockList;
139+
this.currentStockList = shuffle(CurrentStockList);
139140
}
140141
this.counter++;
141142
if (this.counter > this.currentStockList.length - 1) {

src/app/rh-table/backtest-stocks.constant.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function createParam(ticker: string): AlgoParam {
1212
};
1313
}
1414

15-
const shuffle = (array) => {
15+
export const shuffle = (array) => {
1616
let currentIndex = array.length, randomIndex;
1717

1818
while (currentIndex > 0) {

0 commit comments

Comments
 (0)