* Make FOPs selection universe file-based for backtesting * Make FOPs option chains universe file based * Make Future universe selection file-based like option universe * Make Future universe selection file-based like option universe * Abstraction cleanup * Add FuturesChains API to QC algorithm Also refactor future chain provider to use the new FutureUniverse instead of zip file names * Update regression algorithms stats * Refactor QuantBook option and future history to use new universes * Fix failing tests * Fix failing tests * Fix failing tests * Minor future chains unit test improvement * Add futures chains DataFrame property Also, remove IDerivativeSecurity interface from Future * Add DataFrame property to FuturesChains class * Add regression algorithms * Add regression algorithms * Replace QCAlgorithm.FutureChainProvider usages with new FuturesChain api * Minor fixes * Reduce number of universe files in repo * Minor data fixes * Regression algorithms updates * Add implicit conversion from FuturesContract to Symbol Modified algorithms to use futures contract objects directly instead of accessing their Symbol property. Removed unnecessary import statements and redundant lines in various files. * Improve resolution handling for history requests * Changed _auxiliaryData field to lazily-initialized AuxiliaryData property * Refactor data handling in BaseChain and TimeSliceFactory - Added `AddData` method to `BaseChain` for adding market data - Refactored `TimeSliceFactory` to use `BaseChain.AddData` method * Remove specific constructors and indexers from Chain classes Removed public indexers in `BaseChains` for getting or setting `BaseChain` instances by `ticker` or `Symbol`, which were used for Pythonnet compatibility. * Remove chain cache logic from FuturesChainUniverse * Refactor class and interface names for clarity Renamed `FileBasedUniverse` to `BaseChainUniverseData` and `IFileBasedUniverse` to `IChainUniverseData`. * Add base class for options and futures contracts - Introduced `BaseContract` as an abstract base class for contracts, consolidating common properties and methods. - Removed ISymbolInterface * Add minor fix for future options tickers parsing Added tests * Trigger Build * Trigger Build * Trigger Build * Trigger Build * Clean chain provider classes up * Remove ZipEntryName other classes and unused code Removed ZipEntryName class and references across various files. Removed DataQueueFuturesChainUniverseDataCollectionEnumerator and DataQueueOptionChainUniverseDataCollectionEnumerator classes. Removed OptionChainUniverseSubscriptionEnumeratorFactory class. Removed unused code for handling OptionChainUniverse and FuturesChainUniverse in FileSystemDataFeed.cs and LiveTradingDataFeed.cs. Removed several test files related to enumerator factories and universe data collection. * Minor changes and cleanup * Trigger Build * Trigger Build * Refactor FuturesContract data handling Forward price data from bars and ticks stored in private fields for improved memory usage * Fix: use universe data for market data in FuturesContract * Update regression algorithms stats after rebase Added HSI futures universe files * Sort configs by internal flag Internals go first * Throw from option universe data filters for future options Future options IV, Open interest and greeks are not supported for future options * Minor changes * Improve some regression algorithms * Minor fix for failing unit tests * Update FOPs universe file header Removed greeks and IV columns. Updated FOPs universe files: removed outdated columns. * Minor unit test fix * Trigger Build * Trigger Build * Trigger Build * Trigger Build * Trigger Build * Trigger Build * Trigger Build * Trigger Build * Trigger Build * Trigger Build * Trigger Build * Trigger Build * Trigger Build * Minor fix * Add history provider as constructor argument for chain providers * Update new regression algorithms data points count * Minor fix for FakeDataQueue * Add initialize method to chain providers classes * Minor changes * Trigger Build * Trigger Build * Trigger Build * Minor fix * Minor fix * Trigger Build * Trigger Build * Trigger Build * Trigger Build * Add logs to ProcessedDataProvider * Removed test logs * Minor fix * Support downloading options and futures universe files from api data provider
QuantConnect Research Project
Currently we have a few ways to use QuantConnect research notebooks:
- Lean CLI (Recommended)
- Install locally and run directly on your OS.
This document will cover the setup, getting started, and known issues.
Setup
Below we cover how to get setup with our two options listed above.
Research with Lean CLI (Recommended)
Our research docker image has been integrated with Lean CLI to streamline the process and allow user to use their cloud and local projects in the research environment. Please refer to Lean CLI documentation here on how to get started.
Lean CLI research specific documentation is found here.
We highly recommend using Lean CLI with docker for research but below in Running Jupyter Locally we cover how to install and prepare the environment on your personal desktop.
Running Jupyter Locally
Note: we recommend using the above approach with our Docker container, where the setup and environment is tested and stable.
Before we enable Jupyter support, follow Lean installation and Python installation to get LEAN running Python algorithms on your machine. Then be sure to build Lean at least once before the following.
1. Installation:
- Install JupyterLab:
pip install jupyterlab
- Install QuantConnect Python API
pip install quantconnect
- Install pythonnet/clr-loader
pip install clr-loader
2. Run Jupyter:
- Run Jupyter from the command line
cd Lean/Launcher/bin/Debug
jupyter lab
Getting Started with Research
C# Notebook
When using C# for research notebooks it requires that you load our setup script CSX file Initialize.csx into your notebook. This will load our QuantConnect libraries into your C# Kernel. In both docker setups, the file is one directory above the notebooks dir. Be sure to use the following line in your first cell to load in this csx file:
#load "../Initialize.csx"
After this the environment is ready to use; take a look at our reference notebook KitchenSinkCSharpQuantBookTemplate.ipynb for an example of how to use our QuantBook interface!
Note: All Lean namespaces you want to use in your notebook need to be directly added via using statements.
Python Notebook
With Python we have a setup script that will automatically load QuantBooks libraries into the Python kernel so there is no need to import them. In our docker image the script should run automatically, but locally you will need to call %run "start.py" in the first cell.
You notebook is ready to use; take a look at our reference notebook KitchenSinkQuantBookTemplate.ipynb for an example of how to use our QuantBook interface!
Using the Web Api from Notebook
Both of our setup scripts for Python & C# include a instantiated Api object under the variable name api. Before you can use this api object to interact with the cloud you must edit your config in the root of your Notebook directory. Once this has been done once, it does not need to be done again.
In config.json add the following entries with your respective values
job-user-id: 12345, // Your id here
api-access-token: "token13432", // Your api token here
Once this has been done, you may restart your kernel and begin to use the api variable.
Reference our examples mentioned above for practical uses of this object.
Shutting Down the Notebook Lab
When you are done with the research environment be sure to stop the container with Docker Dashboard or via Docker CLI.
Build a new image
For most users this will not be necessary, simply use docker pull quantconnect/research to get the latest image.
docker build -t quantconnect/research - < DockerfileJupyter will build a new docker image using the latest version of lean. To build from particular tag of lean a build arg can be provided, for example --build-arg LEAN_TAG=8631.
Known Issues
-
Python research is extremely dependent on the
start.pyscript as it is responsible for assigning core clr as the runtime for PythonNet and clr-loader to use for C# library. For local use where the script is not launched automatically by Jupyter, one must call%run "start.py"in their first notebook cell for research to work properly. Note that the location ofstart.pyis in the launcher bin directory so you may have to use../start.pyor specify the full path. -
C# research latest kernel no longer supports using statements outside of the notebook context, meaning that
#load ./QuantConnect.csxno longer applies QC namespaces to the notebook out of the box. Therefore one must specify the namespace directly in a cell. Our default notebooks include these statements as examples. -
Python can sometimes have issues when paired with our quantconnect stubs package on Windows. This issue can cause modules not to be found because
site-packagesdirectory is not present in the python path. If you have the required modules installed and are seeing errors about them not being found, please try the following steps:- remove stubs -> pip uninstall quantconnect-stubs
- reinstall stubs -> pip install quantconnect-stubs