Back

Beginner Question: Tutorial question for "Identifying a Stop Loss Hit"

Hi,

I am a beginner to Quantconnect and am going through the tutorials. One question I have for "Identifying a Stop Loss HIt" tutorial is that the tutorial uses self.Time to update the stopMarketFillTime. My question is, would it be better to use orderEvent.UtcTime to update the time? Or, self.Time and orderEvent.UtcTime will always be the same.

def OnOrderEvent(self, orderEvent):

if orderEvent.Status != OrderStatus.Filled:
return

# Printing the security fill prices.
self.Debug(self.Securities["SPY"].Close)

#2. Check if we hit our stop loss (Compare the orderEvent.Id with the stopMarketTicket.OrderId)
# It's important to first check if the ticket isn't null (i.e. making sure it has been submitted)
if self.stopMarketTicket is not None and self.stopMarketTicket.OrderId == orderEvent.OrderId:
#3. Store datetime
self.stopMarketFillTime = self.Time
self.Debug(self.stopMarketFillTime)

Thanks for the help in advance.

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.


It doesn't matter that much, as long as you are consistent with which you use throughout the algorithm. For convenience/stability, probably best to keep everything in the algorithm's timezone via self.Time - this can help make sure scheduling functions, logging, etc match up with the data. If you want to use UTC time throughout (default is New York/EST), in Initialize you can just set the timezone accordingly.

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