Datasets
Testing Data Models
Introduction
The implementation of your Data Source must be thoroughly tested to be listed on the Dataset Market.
Run Demonstration Algorithms
Follow these steps to test if your demonstration algorithm will run in production with the processed data:
- Open the Lean.DataSource.<vendorNameDatasetName> / QuantConnect.DataSource.csproj file in Visual Studio.
- In the top menu bar of Visual Studio, click .
- Close Visual Studio.
- If you have a local copy of LEAN, pull the latest changes.
- If you don't have a local copy of LEAN, fork the LEAN repository and then clone it.
- Copy the contents of the Lean.DataSource.<vendorNameDatasetName> / output directory and paste them into the Lean / Data directory.
- Open the Lean / QuantConnect.Lean.sln file in Visual Studio.
- In the Solution Explorer panel of Visual Studio, right-click QuantConnect.Algorithm.CSharp and then click .
- In the Add Existing Item window, click the Lean.DataSource.<vendorNameDatasetName> / <vendorNameDatasetName>Algorithm.cs file and then click .
- In the Solution Explorer panel, right-click QuantConnect.Algorithm.CSharp and then click .
- In the Reference Manager window, click .
- In the Select the files to reference… window, click the Lean.DataSource.<vendorNameDatasetName> / bin / Debug / net9.0 / QuantConnect.DataSource.<vendorNameDatasetName>.dll file and then click .
- Click .
- In the Lean / Algorithm.CSharp / <vendorNameDatasetName>Algorithm.cs file, write an algorithm that uses your new dataset.
- In the Solution Explorer panel, click QuantConnect.Lean.Launcher > config.json.
- In the config.json file, set the following keys:
- Press Ctrl+F5 to backtest your demonstration algorithm.
- Copy the Lean.DataSource.<vendorNameDatasetName> / <vendorNameDatasetName>Algorithm.py file and paste it in Lean / Algorithm.Python directory.
- In the Lean / Algorithm.Python / <vendorNameDatasetName>Algorithm.py file, write an algorithm that uses your new dataset.
- In the Solution Explorer panel, click QuantConnect.Lean.Launcher > config.json.
- In the config.json file, set the following keys:
- Press Ctrl+F5 to backtest your demonstration algorithm.
- Copy the Lean / Algorithm.CSharp / <vendorNameDatasetName>Algorithm.cs file to Lean.DataSource.<vendorNameDatasetName> / <vendorNameDatasetName>Algorithm.cs.
- Copy the Lean / Algorithm.Python / <vendorNameDatasetName>Algorithm.py file to Lean.DataSource.<vendorNameDatasetName> / <vendorNameDatasetName>Algorithm.py.
The Output panel displays the build status of the project.
$ git pull upstream master
$ git clone https://github.com/<username>/Lean.git
The Reference Manager window displays the QuantConnect.DataSource.<vendorNameDatasetName>.dll file with the check box beside it enabled.
The Solution Explorer panel adds the QuantConnect.DataSource.<vendorNameDatasetName>.dll file under .
"algorithm-type-name": "<vendorNameDatasetName>Algorithm", "algorithm-location": "QuantConnect.Algorithm.CSharp.dll",
"algorithm-type-name": "<vendorNameDatasetName>Algorithm", "algorithm-location": "../../../Algorithm.Python/<vendorNameDatasetName>Algorithm.py",
Important: Your backtests must run without error. If your backtests produce errors, correct them and then run the backtest again.
Run Unit Tests
You must run your demonstration algorithms without error before you set up unit tests.
In the Lean.DataSource.<vendorNameDatasetName> / <vendorNameDatasetName>Tests.cs file, define the CreateNewInstance
method to return an instance of your DataSource
class and then execute the following commands to run the unit tests:
$ dotnet build tests/Tests.csproj $ dotnet test tests/bin/Debug/net9.0/Tests.dll