Hey guys! I'm new here so forgive me if this is a dumb question. I'm an experienced programmer and found the browser based cloud IDE a bit slow to use, and would prefer to use my local VSCode IDE instead of the browser one.
I got everything set up and my backtests work as expected, but when I attempt to use the Lean CLI to do step debugging, I'm not getting any data and the market is closed 100% of the time.
Does anyone know what's going on here? I've been digging into this for hours.
Mia Alissi
Hi Jordan,
It seems like you're having trouble with debugging in VS Code. Here are some steps you can follow to debug Python code in VS Code:
lean backtest "<projectName>" --debug ptvsd, and then wait until the CLI tells you to attach to the debugger.If you're still having trouble, it might be due to some issues with your Python environment or the way your project is set up. Make sure you have the correct Python version installed and that your project dependencies are correctly set up.
If the problem persists, you might want to check the QuantConnect forum for similar issues or post your question there to get help from the community.
Regarding the market being closed 100% of the time, it might be due to the data time zone or the market hours you've set in your algorithm. Make sure you've set the correct market hours and data time zone in your algorithm.
If you're using custom data, you might need to download some of QuantConnect's data for local usage. You can find more information about this here.
I hope this helps! Let me know if you have any other questions.
Source: QuantConnect Forum, QuantConnect Documentation
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.
Jordan Arldt
Thanks for the help. I've followed all the steps. it's important to note that my step debugging does work, but there is just no market data and the market is registered as closed during debugging, but when I run my backtest, there is data and it works as expected.
Mia Alissi
Hi Jordan,
It's possible that the issue you're experiencing is related to the data feed during the debugging process. In the backtest, the data feed is simulated based on historical data, but during debugging, it might be trying to access real-time data, which could be unavailable or the market could be closed at that time.
One thing you could try is to ensure that your algorithm is set up to handle cases where the market is closed or data is not available. For example, you could add checks in your
OnDatamethod to ensure that data is available before executing any trading logic.Here's an example in Python:
In this example,
self.symbolis the symbol of the security you're trading. This check ensures that theOnDatamethod exits early if data for the security is not available.If you're using multiple symbols, you can iterate over them and check if data is available for each one:
In these examples,
self.symbolsis a list of the symbols of the securities you're trading.I hope this helps! Let me know if you have any other questions.
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.
Jordan Arldt
This still didn't work. My Debugging environment simply isn't getting data. I'm already paying for the service, do I also have to pay for the data that my debugger uses?
Mia Alissi
Hi Jordan,
Based on the information provided, it seems like you're having issues with data availability during debugging. In one of the forum discussions, a user mentioned a similar issue where the local data was only complete with daily data and the algorithm was using minute data. Setting the equity resolution to daily produced expected results. The sample data does appear to be slightly scrambled but is good enough for testing. You might want to check if this is the case with your setup as well.
As for the cost, while there is a subscription fee for the QuantConnect service, there might be additional costs for data depending on your usage. For local backtesting, you might need to download the data which could incur additional costs. However, it's important to note that the cost of data can vary depending on the type and amount of data you need.
If you're still having issues, I would recommend reaching out to the QuantConnect support team or posting your question on the QuantConnect forum for more specific help.
Sources: QuantConnect Forum
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.
Jordan Arldt
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!