I tried to produce my very first own ba

cktest with a bsic strategy, the EMA crossover.

I have used a sample code and modified it to fit the requirements I want to backtest.

Unfortunatelly, I'm unable to produce any backtesting data with my code and can't find the problem.

It woumld be great if someone could help.

Many thanks in advance  ! 


class EMA_CrossOver(QCAlgorithm): def Initialize(self): # Set our main strategy parameters self.SetStartDate(2012,1, 1) # Set Start Date self.SetEndDate(2015,1,1) # Set End Date self.SetCash(100000) # Set Strategy Cash #Set EMA Values Slow_EMA_Period = 50 Fast_EMA_Period = 20 self.Allocate = 0.50 # Percentage of captital to allocate self.AddEquity("AAPL", Resolution.Daily) #build the indicators self.EMA_Slow = self.EMA("AAPL", Slow_EMA_Period, Resolution.Daily) self.EMA_Fast = self.EMA("AAPL", Fast_EMA_Period, Resolution.Daily) #self.SetWarmUp(200) history = self.History(["AAPL"], 200, Resolution.Daily) for time, row in history.loc["AAPL"].iterrows(): self.EMA_Slow.Update(time, row["close"]) self.EMA_Fast.Update(time, row["close"]) def OnData(self, data): if self.IsWarmingUp: return if not self.EMA_Slow.IsReady or not self.EMA_Fast.IsReady: return if not self.Portfolio.Invested: if self.EMA_Fast.Current.Value > self.EMA_Fast.Current.Value: # Buy Apple self.SetHoldings("AAPL", 1.0) else: if self.EMA_Fast.Current.Value < self.EMA_Fast.Current.Value: # Sell Apple self.Liquidate("AAPL")