In the bootcamp of Buy and Hold with a Trailing Stop, section "Visualizing the Stop Levels", I was able to pass the tests, however, I don't see the charts/figures that I created using self.Plot().
Though this might be a silly question, but just where are those figures? The videos didn't say anything about it either, I think it's a bit over-simplified.
Aaron Janeiro Stone
Ensure that all was specified as per the above link. I recall seeing the plot on my attempt, however if all was specified correctly as per the documentation above in your attempt, please do attach your answer.
Yuying liu
Hi Aaron, thanks for the response, however, I still don't see it. But let me be more specific of my question:Â
I was trying to get myself through the boot camp toy projects, when I attempted the one named "Visualizing the Stop Levels" within "Buy and Hold with a Trailing Stop", and submitted the code with the solution below, it succesfully run through the backtest. But I cannot find the plot anywhere on my Browser (see attached screenshot).Â
Even if I followed the link you sent me and added:
stockPlot = Chart('Data Chart')
self.AddChart(stockPlot)
It doesn't work.
Â
Â
Â
Â
Solution code:
class BootCampTask(QCAlgorithm):
# Order ticket for our stop order, Datetime when stop order was last hit
stopMarketTicket = None
stopMarketOrderFillTime = datetime.min
highestSPYPrice = -1
def Initialize(self):
self.SetStartDate(2018, 12, 1)
self.SetEndDate(2018, 12, 10)
self.SetCash(100000)
spy = self.AddEquity("SPY", Resolution.Daily)
spy.SetDataNormalizationMode(DataNormalizationMode.Raw)
def OnData(self, data):
# 1. Plot the current SPY price to "Data Chart" on series "Asset Price"
self.Plot('Data Chart', 'Asset Price', data["SPY"].Close)
if (self.Time - self.stopMarketOrderFillTime).days < 15:
return
if not self.Portfolio.Invested:
self.MarketOrder("SPY", 500)
self.stopMarketTicket = self.StopMarketOrder("SPY", -500, 0.9 * self.Securities["SPY"].Close)
else:
#2. Plot the moving stop price on "Data Chart" with "Stop Price" series name
self.Plot('Data Chart', 'Stop Price', self.stopMarketTicket.Get(OrderField.StopPrice))
if self.Securities["SPY"].Close > self.highestSPYPrice:
self.highestSPYPrice = self.Securities["SPY"].Close
updateFields = UpdateOrderFields()
updateFields.StopPrice = self.highestSPYPrice * 0.9
self.stopMarketTicket.Update(updateFields)
def OnOrderEvent(self, orderEvent):
if orderEvent.Status != OrderStatus.Filled:
return
if self.stopMarketTicket is not None and self.stopMarketTicket.OrderId == orderEvent.OrderId:
self.stopMarketOrderFillTime = self.Time
Â
Screenshot:
Â
Derek Melchin
Hi Yuying,
Custom plots are not shown in the Boot Camp. To see the plot, run the algorithm in the terminal. The bootcamp algorithms are in the Algorithm Lab under Bootcamp > My Projects.
Best,
Derek Melchin
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.
Yuying liu
Hello Derek, thanks for responding! When you say run in the terminal, do you mean backtest the same algorithm on "www.quantconnect.com/terminal/"? If so, I still cannot find the plot, please see the attached figure below. Thanks!
Â
Jared Broad
It is closed by default =) You can open it here:
Â
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.
Yuying liu
Ah I see, thank you so much Jared!
Yuying liu
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!