Howdy,
I'm getting errors for all equities when I try to backtest for June. My code looks like:
class SleepyVioletAlligator(QCAlgorithm):
def initialize(self):
self.set_start_date(2024, 6, 10)
self.set_end_date(2024, 6, 11)
self.set_cash(100000)
self.symbol = self.add_equity("AAPL", Resolution.SECOND).symbol
And the error I get is:
302|4:49:28:Backtest Handled Error: No data loaded for AAPL because there were no tradeable dates for this security.
If I change the dates to January 24, rather than June, it works.
What's up?
Mia Alissi
Hello Soren,
The error message you're seeing, "No data loaded for AAPL because there were no tradeable dates for this security," typically occurs when there's no data available for the specified symbol for the dates you've set in your backtest.
In your case, you're trying to backtest with data from June 10, 2024, to June 11, 2024. It's possible that there's no data available for AAPL for these dates in QuantConnect's data library.
If changing the dates to January 24, 2024, works, it suggests that the data for AAPL is available for January but not for June in QuantConnect's data library.
You might want to check the dates and make sure that data for AAPL is available for those dates in QuantConnect's data library. If the data is available and you're still seeing the error, there might be an issue with how you're subscribing to the data in your algorithm.
Here is the line of code in your algorithm where you're subscribing to AAPL data:
This line of code should correctly subscribe your algorithm to second resolution AAPL data. If the data is available for your specified dates, this line of code should allow your algorithm to access the data. If you're still seeing the error, you might want to check other parts of your algorithm to make sure they're not causing issues.
I hope this helps! Let me know if you have any other questions.
Source
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.
Soren Diehl
Yeah…that doesn't really answer my question. June 10th and 11th are valid trading days. AAPL is one of the highest volume and largest cap US equities. Why wouldn't the data be available in Quant Connect's data library?
Mia Alissi
I apologize for the confusion, Soren. You're correct that June 10th and 11th are valid trading days and AAPL is indeed one of the most traded US equities.
However, the issue you're encountering might be due to the fact that you're trying to backtest with data from the future. As of now, QuantConnect's data library only contains data up to the present day. If you're trying to backtest with data from 2024, you'll encounter errors because that data doesn't exist yet in the library.
To resolve this issue, you should adjust the start and end dates in your backtest to fall within the range of available data. Here's how you can adjust the dates in your algorithm:
In this adjusted version of your algorithm, I've set the start and end dates to June 10, 2022, and June 11, 2022, respectively. These dates fall within the range of available data in QuantConnect's data library, so you should be able to backtest your algorithm without encountering the "No data loaded" error.
I hope this helps! Let me know if you have any other questions.
Source
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.
Soren Diehl
I guess you're a ChatGPT bot or something like that. I am not trying to backtest with data from the future. The current date is July 4th 2024. June 10th 2024 is in the past.
Jared Broad
Hi @soren-diehl, The latest months are withheld as out-of-sample data. This allows your algorithm to have some data as a holdout before live trading. You can configure the out-of-sample period from the Organization homepage. If you request five years of data, you'll see it hide the latest 3-6mo.
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.
Soren Diehl
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!