Hi all,

I am trying to schedule my Portfolio Construction model to only run on the last day of the month at the close.

When I try simply using .MonthEnd, it works... but when I add TimeRules, I get an error...

self.SetPortfolioConstruction( EqualWeightingPortfolioConstructionModel(\
                                        self.DateRules.MonthEnd("SPY")) )........ WORKS

self.SetPortfolioConstruction( EqualWeightingPortfolioConstructionModel(\
                                        self.DateRules.MonthEnd("SPY"), \
                                        self.TimeRules.BeforeMarketClose("SPY")) )...... DOESN'T

I am getting the following error about the SPY not being in the portfolio, yet I am requesting data for SPY at the initialization..

"During the algorithm initialization, the following exception has occurred: KeyNotFoundException : SPY not found in portfolio. Request this data when initializing the algorithm."

Seems strange that this error would occur when adding a TimeRule but not occur with a DateRule? I have also tried requesting Resolutiuon.Minute data instead of daily data but that doesnt fix the issue either. Any ideas?

 

Author