@@ -221,7 +221,6 @@ export class AutopilotComponent implements OnInit, OnDestroy {
221
221
. pipe ( takeUntil ( this . destroy$ ) )
222
222
. subscribe ( async ( ) => {
223
223
const startStopTime = this . getStartStopTime ( ) ;
224
- console . log ( new Date ( ) . toString ( ) ) ;
225
224
if ( moment ( ) . isAfter ( moment ( startStopTime . endDateTime ) . subtract ( 5 , 'minutes' ) ) &&
226
225
moment ( ) . isBefore ( moment ( startStopTime . endDateTime ) ) ) {
227
226
if ( this . reportingService . logs . length > 0 ) {
@@ -618,13 +617,16 @@ export class AutopilotComponent implements OnInit, OnDestroy {
618
617
const found = ( name ) => {
619
618
return Boolean ( this . currentHoldings . find ( ( value ) => value . name === name ) ) ;
620
619
} ;
621
-
622
- do {
623
- stock = this . machineDaytradingService . getNextStock ( ) ;
624
- } while ( found ( stock ) )
625
- const backtestResults = await this . backtestTableService . getBacktestData ( stock ) ;
626
- if ( backtestResults ) {
627
- cb ( stock , backtestResults . ml ) ;
620
+ let counter = this . machineDaytradingService . getCurrentStockList ( ) . length ;
621
+ while ( counter > 0 && ( this . cartService . buyOrders . length + this . cartService . otherOrders . length ) < this . maxTradeCount ) {
622
+ do {
623
+ stock = this . machineDaytradingService . getNextStock ( ) ;
624
+ } while ( found ( stock ) )
625
+ const backtestResults = await this . backtestTableService . getBacktestData ( stock ) ;
626
+ if ( backtestResults ) {
627
+ cb ( stock , backtestResults . ml ) ;
628
+ }
629
+ counter -- ;
628
630
}
629
631
}
630
632
@@ -650,7 +652,7 @@ export class AutopilotComponent implements OnInit, OnDestroy {
650
652
console . log ( 'training daytrade results ' , trainingResults ) ;
651
653
if ( trainingResults [ 0 ] . correct / trainingResults [ 0 ] . guesses > 0.6 && trainingResults [ 0 ] . guesses > 50 ) {
652
654
await this . addDaytrade ( stock ) ;
653
- if ( this . cartService . otherOrders . length > this . maxTradeCount ) {
655
+ if ( ( this . cartService . buyOrders . length + this . cartService . otherOrders . length ) > this . maxTradeCount ) {
654
656
break ;
655
657
}
656
658
}
@@ -713,7 +715,7 @@ export class AutopilotComponent implements OnInit, OnDestroy {
713
715
}
714
716
715
717
async addBuy ( holding : PortfolioInfoHolding , allocation = round ( this . riskToleranceList [ this . riskCounter ] , 2 ) ) {
716
- if ( this . cartService . buyOrders . length < this . maxTradeCount ) {
718
+ if ( ( this . cartService . buyOrders . length + this . cartService . otherOrders . length ) < this . maxTradeCount ) {
717
719
console . log ( 'Adding buy ' , holding ) ;
718
720
719
721
const currentDate = moment ( ) . format ( 'YYYY-MM-DD' ) ;
@@ -740,7 +742,7 @@ export class AutopilotComponent implements OnInit, OnDestroy {
740
742
}
741
743
742
744
async addDaytrade ( stock : string ) {
743
- if ( this . cartService . otherOrders . length < this . maxTradeCount ) {
745
+ if ( ( this . cartService . buyOrders . length + this . cartService . otherOrders . length ) < this . maxTradeCount ) {
744
746
const currentDate = moment ( ) . format ( 'YYYY-MM-DD' ) ;
745
747
const startDate = moment ( ) . subtract ( 100 , 'days' ) . format ( 'YYYY-MM-DD' ) ;
746
748
try {
0 commit comments