Overall Statistics
class HorizontalNadionCoreWave(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2019, 10, 21)  # Set Start Date
        self.SetEndDate(2019, 10, 27)    # Set Start Date
        self.SetCash(100000)             # Set Strategy Cash
        self.AddEquity("TSLA", Resolution.Daily) # Add data feed
        
        self.max_train_seconds = 5 # Specify max training time

    def train(self):
        start_time = datetime.now() # Current time
        while True:
            # Train function call...
            
            # Stop looping if reached maximum training duration
            if (datetime.now() - start_time).seconds >= self.max_train_seconds:
                break

    def OnData(self, data):
        if not self.Portfolio.Invested:
            self.SetHoldings("TSLA", 1)
        
        self.train()