* Initial options universe with greeks implementation * Options universe improvements * Address peer review * File based options universe fixes and improvements. - Adjust OptionUniverse start-end times and period. - Adapt unit tests and some algorithms to pass with new options universe selection. * Updated options regression algorithms stats for new universe data * Updated options regression algorithms stats for new universe data * Updated options regression algorithms stats for new universe data * Updated options regression algorithms stats for new universe data * Updated options regression algorithms stats for new universe data * Option chain provider with new options universe * Allow canonical option history requests * Address peer review * Address peer review * Fix symbols parsing in OptionUniverse * Fix universe selection subscriptions start time to not include extended market hours * Minor changes * Minor changes * Peer recommended changes and fixes * Update regression algorithm stats * Update regression algorithms stats and minor fixes * Fix option chain provider history request * Round option indicators values * Added option universe csv header property * Update regression algorithms stats * Update regression algorithms stats * Data fixes and regression algos stats update * Unit test fixes * Minor changes * Option chain handling in live trading data feed * Minor changes * Added processed data provider * Fix thread-safety violation in Slice class * Minor change * Update options filter universe API to use OptionUniverse data Add new filter methods for greeks, IV and open interest * Option filter universe api updates * Add OptionUniverse history regression algorithms * Add regression algorithms for new options filter universe api methods * Added options greeks data and updated regression algorithms * Address peer review * Address peer review * Add more assertions to new options filter api regression algorithms * Minor performance improvement. Reduce greeks binomial model steps to 140 * Minor tests updates * Greeks numerical models performance improvements * Greeks numerical models performance improvements * Revert array pool change for option pricing numerical models * Update default dividend yield provider depending on option type * [TEST] * Add helper method con calculate time till expiration * Use double in price option numerical models * Implied volatility calculation improvements - Adjust root finding method accuracy as a factor of the option price - Use BSM to get a first guess * Cleanup * Some regression algorithms and unit tests cleanup * Regression tests updates after rebasing from master * Add universe files * Self review and cleanup * Minor regression tests updates after rebase * Fix: set data time zone to same as exchange tz for options universes * Minor change * Minor change * Fix for live trading options universe selection * Keep underlying when aggregating collections in BaseDataCollectionAggregatorEnumerator * Update index options regression algorithms stats * Minor change * Address peer review * Memory usage improvements * Minor build fix * Minor changes and test fixes * Cache symbols in OptionUniverse * Cleanup * Fix index option creation in OptionUniverse * Use cached underlying SID when parsing from string * Abstract symbols cache to BaseDataCollection * Return actual underlying symbol when mapping decomposing ICO ticker * Address peer review * Minor performance improvements reduce garbage * Limit Symbols and SIDs cache size to help with memory usage * Minor fix in symbols and sid cache cleanup * Build fix * Lazily parse greeks on individual access * Cleanup and tests * Address peer review * Minor greeks fix --------- Co-authored-by: Martin Molinero <martin.molinero1@gmail.com>
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