Back

HELP: Scheduling Portfolio Construction within the AlgorithmFramework

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?

 

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.


Hi Mark,

Please refer to our previous thread to setup monthly rebalancing without these errors.

Best,
Derek Melchin

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