I'm new to the platform and I found 2 annoying things & keep my coding productivity low.
The cloud IDE doesn't have autocomplete for python
Opposite to what is claimed
and here's a similar question
Local Development just doesn't work without paying an expensive data subscription
I learned it the hard way after spending hours setting up local python IDE, etc to just realize I cannot do anything locally because you have to pay for the data, which isn't explicitly documented (and it should be) to avoid people wasting the time.
Though lean, lean-cli claim to be open-source projects, it's just useless without real financial data.
At least, can I run some backtesting scripts with sample data???
Q: Lastly, if I need to have SPY, QQQ historical option data, which datasets should I purchase?
Thanks!
Mia Alissi
Here's a guide to address Wang's concerns and questions:
Cloud IDE Autocomplete for Python: To enable autocomplete in the cloud IDE, ensure you include the necessary imports in your Python files. Use
from AlgorithmImports import *
at the top of your files to ensure all necessary modules are available for autocomplete.Local Development without Data Subscription: While a data subscription is required for full access to historical data, you can still run backtesting scripts using sample data or custom data sources. Consider using publicly available datasets or creating custom data types for testing. You can refer to examples like the
CustomDataRegressionAlgorithm
for guidance on implementing custom data types.Running Backtesting Scripts with Sample Data: Implement custom data types in your algorithm to simulate data feeds, allowing you to test strategies without a data subscription. This approach can help you develop and test your algorithms locally without incurring additional costs.
SPY and QQQ Historical Option Data: For SPY and QQQ historical option data, consider purchasing datasets like the US Index Options dataset by AlgoSeek, which covers European Option contracts for US indices. This dataset provides comprehensive historical data starting from January 2012.
Setting Up Local Autocomplete: If using local development environments like VS Code or PyCharm, ensure the correct extensions and configurations are set up. For VS Code, install the Python and Pylance extensions. For PyCharm, open the project directory and wait for indexing to complete. Ensure your project includes the necessary imports for autocomplete to function correctly.
Understanding Data Requirements: Review the QuantConnect documentation to understand the data requirements and limitations for local development. This will help you be aware of any necessary subscriptions or alternative data sources.
Explore Dataset Listings: Visit the QuantConnect datasets page to explore available datasets and their pricing, ensuring you select the appropriate data for your trading strategies. The US Index Options dataset by AlgoSeek is a good option for SPY and QQQ historical option data.
Sources: Costs - QuantConnect.com, Autocomplete - QuantConnect.com, US Index Options - QuantConnect.com, Crypto - QuantConnect.com, Documentation Home - QuantConnect.com
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.
Sean Champ
For type hint support with QuantConnect algorithm programming in Python, I wonder does the quantconnect-stubs package help? (It was mentioned in a readme under the QuantConnect lean sources at GithHub)
If one could try to put together an ad hoc walkthrough for local backtests with lean-cli, though tbh I'm new to this platform myself:
1) Create a cloud_root directory (directory name may vary, of course) and set up a python virtual environment there. One could use virtualenv though preferences may vary here. (A package management tool such as pdm or poetry could be used to create a python project in this dir, though the dir will contain other python projects shortly.)
2) Ensure that the docker service is installed and working. There's a small hello-world image available for purpose of test
3) Install the lean CLI tools in the python virtual environment: pip install lean
4) under the cloud_root directory, run ‘lean init’. This will create a ‘lean.json’ file and download some sample data for backtests under the local object store root dir, named ‘data’ (This data dir will be passed to Docker, at some point)
5) To create a Python project named ‘quantexample’ for backtesting, run ‘lean project-create -l python quantexample’ from within the cloud_root dir
6) After editing the example to suit, then to backtest locally under docker, run `lean backtest quantexample' from within the cloud_root dir. (Initially, this will download something more than 9 GB of docker image data. Reportedly, containerd-snapshotter can be enabled in docker, to allow for resumble downloads during docker pull and other features. Of course, docker will need to be restarted after this feature is enabled.) The backest cmd supports a number of additional args, available with `lean backtest --help'
Towards coding the trading algorithm, the LEAN sources contain a number of examples, illustrating some API features. Personally, I'd started with Greg Bland's QuantConnect 101. His example features a trading strategy based on a Bollinger Bands indicator available directly in QuantConnect.
It seems the QuantConnect API has been updated in some ways since the article was published, e.g ‘self.set_warm_up(…)’ instead of ‘self.SetWarmUp(…)’
For local backtests with the LEAN docker image, the backtesting data provided from quant seems to be limited to some very old data (at least in FOREX symbols) as old as 2014. At least for FOREX data, these are provided as zip files containing csv files. It may be possible to guess out the CSV format and write newer CSV files for backtesting with newer data, e.g via yfinance or directly via a broker's web API. For the data as provided, perhaps it may be enough for a simple example tho?
The ‘lean cloud’ commands would provide support for synching with the Lean cloud system, for backtest or live trades
HtH!
Wang Yi
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!