Hi there,
I am trying to backtest a project that rebalances a portfolio of stocks every month. The stocks that should be held each month are determined from a csv file like below. This is similar to the example algorithm https://github.com/QuantConnect/Lean/blob/master/Algorithm.Python/DropboxBaseDataUniverseSelectionAlgorithm.pyhttps://github.com/QuantConnect/Lean/blob/master/Algorithm.Python/DropboxBaseDataUniverseSelectionAlgorithm.pyhttps://github.com/QuantConnect/Lean/blob/master/Algorithm.Python/DropboxBaseDataUniverseSelectionAlgorithm.pyhttps://github.com/QuantConnect/Lean/blob/master/Algorithm.Python/DropboxBaseDataUniverseSelectionAlgorithm.pyhttps://github.com/QuantConnect/Lean/blob/master/Algorithm.Python/DropboxBaseDataUniverseSelectionAlgorithm.pyter/Algorithm.Python/DropboxBaseDataUniverseSelectionAlgorithm.py
2003-08-31,CLV,MCR,KCN,NCM,GWA,SWM,SVW,TLS,WPL,MTS
2003-09-30,CLV,MCR,NCM,KCN,GWA,SWM,SVW,WPL,WES,MTS
2003-10-31,MCR,NCM,SWM,SVW,GWA,KCN,WES,JHX,MTS,WPL
2003-11-30,MCR,NCM,AVJ,KCN,SWM,MTS,SVW,WPL,TLS,JHX
Each stock is has custom data with each stock having its own csv file with the format below. The data is loaded as per the instructions in
date,open,high,low,close,adjusted_close,volume
2007-01-16,7.1672,7.4068,7.1396,7.3699,4.3993,1409035
2007-01-17,7.3699,7.591,7.1857,7.591,4.5313,2811738
2007-01-18,7.7292,7.8397,7.6094,7.6831,4.5863,2612682
2007-01-19,7.6094,7.6923,7.545,7.591,4.5313,1631908
When I backtest the project, I receive an error:
ERROR:: DHG 2T: The security does not have an accurate price as it has not yet received a
a bar of data. Before placing a trade (or using SetHoldings) warm up your algorithm with SetWarmup, or use slice.Contains(symbol) to confirm the Slice object has price before using the data. Data does not necessarily all arrive at the same time so your algorithm should confirm the data is ready before using it. In live trading this can mean you do not have an active subscription to the asset class you're trying to trade. If using custom data make sure you've set the 'Value' property.
When I debug the script, every symbol parameter shows only the three digit code, like “DHG” so I am confused as to why my logs show “DHG 2T”.
Jeremy Buttel
I managed to solve the problem by saving the files as formatted csv's within zip's inside the data\equity\usa\daily folder.
Jeremy Buttel
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!