Back

OnSecuritiesChanged Questions

Question 1.) After initializing

self.UniverseSettings.Resolution = Resolution.Daily
self.AddUniverse(self.CoarseSelectionFilter, self.FineSelectionFilter)

in def Initialize(self): is 

def OnSecuritiesChanged(self, changes):

called after self.FineSelectionFilter executes? 

Question 2.) Does 'changes' contain the differences between the result sets returned from self.FineSelectionFilter every iteration or does 'changes' contain changes in the universe that are initially passed into def CoarseSelectionFilter(self, coarse)::?

Question 3.) After

def FineSelectionFilter(self, fine):

finishes, is def OnData(self, data) called with the filtered result set returned from def FineSelectionFilter(self, fine):? 

Question 4.) In this instance, is

def OnData(self, data):

called every day at 12:00am because self.UniverseSettings.Resolution is set to Resolution.Daily?

 

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.


Here are my findings for anyone learning the framework that may have the same question. After playing around with the platform and using self.Debug() and self.Log() to track when the functions are called this is what I found. If you set 

self.UniverseSettings.Resolution = Resolution.Daily
self.AddUniverse(self.CoarseSelectionFilter, self.FineSelectionFilter)

All four methods 

def CoarseSelectionFilter(self, coarse):
def FineSelectionFilter(self, fine):
def OnSecuritiesChanged(self, changes):
def OnData(self, data):

will be called at the beginning of each day at 12:00am in that order.

def OnSecuritiesChanged(self, changes):

changes is an object that has properties that reveal the differences between the previous FineSelectionFilter results and the current FineSelectionFilter results. e.g. changes.AddedSecurities and changes.RemovedSecurities. After def OnSecuritiesChanged(self, changes): finishes running, def OnData(self, data): will be called and the data parameter will contain a slice that has all of the securities that were returned from def FineSelectionFiler(self, fine): plus any other securities that may be in the same Resolution.

Some people save the result of the def FineSelectionFilter(self, fine): to their own object so that they can use it in their own Scheduled Events.

 

 

 

0

Hi Jason,

All correct! Thank you for your questions and figuring them out by yourself. :)

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.


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