Hi,
I've written very similar pieces of code shown below. However, they resulted in drastically different back-testing results. The first version ended up with over 600K whereas the second one got only around 150K. Something must be seriously wrong here. Any help will be highly appreciated.
from AlgorithmImports import *
class PatternTrading(QCAlgorithm):
def Initialize(self):
self.symbol = "NVDA"
self.SetStartDate(2018, 1, 1) # Set Start Date
self.SetEndDate(2022, 1, 1)
self.SetCash(100000) # Set Strategy Cash
self.AddEquity(self.symbol, Resolution.Minute)
def OnData(self, data):
self.SetHoldings(self.symbol, 1.0)
from AlgorithmImports import *
class PatternTrading(QCAlgorithm):
def Initialize(self):
self.symbol = "NVDA"
self.SetStartDate(2018, 1, 1) # Set Start Date
self.SetEndDate(2022, 1, 1)
self.SetCash(100000) # Set Strategy Cash
self.AddEquity(self.symbol, Resolution.Minute)
def OnData(self, data):
if self.symbol in data.Bars:
self.SetHoldings(self.symbol, 1.0)
Henry Nguyen
After some time, the results of these two examples become the same. I tested multiple times before that and the results were different. NVDA was ordered in 2018, but the price was around $195 (the actual price at that point is around $48). Is there anything I did not know that explains this backtesting behavior?
Yuri Lopukhov
I have experienced similar behaviour when there was a split event not recorded correctly for GOOG. It also behaved sporadically at first. They fixed the split, but no comments about different results.
Henry Nguyen
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!