Back

The solution of FadingTheGap at "Accessing-a-Rolling-Window" Occurs Exception " Boot Camp: We couldn't reconcile your trades with what we expected..."

Hi there, 

I have tried "Fading The Gap" in Boot camp and met this exception : "Boot Camp: We couldn't reconcile your trades with what we expected..."  .

The code is copied and pasted from the solution.py of "Accessing a Rolling WIndow" section.  The Log (https://www.quantconnect.com/backtest/32193/5483863/cd7e346f8b8cbf5405740e5a12d8a5c7-log.txt) said "2018-06-29 16:00:00 Algorithm Id:(cd7e346f8b8cbf5405740e5a12d8a5c7) completed in 1.69 seconds at 77k data points per second. Processing total of 130,287 data points." 

I have tried with the different symbols, StartDates and EndDates, but the results are the same: "Boot Camp: We couldn't reconcile your trades with what we expected..." 

How can I solve it? 

class FadingTheGap(QCAlgorithm):

def Initialize(self):
self.SetStartDate(2017, 11, 1)
self.SetEndDate(2018, 7, 1)
self.SetCash(100000)
self.AddEquity("TSLA", Resolution.Minute)

self.Schedule.On(self.DateRules.EveryDay(), self.TimeRules.BeforeMarketClose("TSLA", 0), self.ClosingBar)
self.Schedule.On(self.DateRules.EveryDay(), self.TimeRules.AfterMarketOpen("TSLA", 1), self.OpeningBar)
self.Schedule.On(self.DateRules.EveryDay(), self.TimeRules.AfterMarketOpen("TSLA", 45), self.ClosePositions)

self.window = RollingWindow[TradeBar](2)

def ClosingBar(self):
self.window.Add(self.CurrentSlice["TSLA"])

def OpeningBar(self):
if "TSLA" in self.CurrentSlice.Bars:
self.window.Add(self.CurrentSlice["TSLA"])

#1. If our window is not full use return to wait for tomorrow
if not self.window.IsReady:
return

#2. Calculate the change in overnight price
delta = self.window[0].Open - self.window[1].Close

#3. If delta is less than -$10, SetHoldings() to 100% TSLA
if delta < -10:
self.SetHoldings("TSLA", 1)

def ClosePositions(self):
self.Liquidate()

 

Update Backtest







0

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.


Note that TSLA went though split 5-to-1 in the end of August, and historical prices are split-adjusted. So you need to make a small change in the solution in order to get the required results.

0

Sorry, split was 5-for-1, not 5-to-1

0

Hi Shinseitaro,

This is an error in the BootCamp caused by the split event in TSLA. We we fix this ASAP, however, if the error hasn't been fixed yet, please change 

self.AddEquity("TSLA", Resolution.Minute)

to 

self.AddEquity("TSLA", Resolution.Minute).SetDataNormalizationMode(DataNormalizationMode.Raw)

Furthermore, for any future errors in the BootCamp, feel free to move past them as BootCamp lessons aren't locked by order.

Best,
Shile Wen

0

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.


Hi Shile, Thank you! 

0

Update Backtest





0

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.


Loading...

This discussion is closed