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:

  1. Open the Lean.DataSource.<vendorNameDatasetName> / QuantConnect.DataSource.csproj file in Visual Studio.
  2. In the top menu bar of Visual Studio, click Build > Build Solution.
  3. The Output panel displays the build status of the project.

  4. Close Visual Studio.
  5. If you have a local copy of LEAN, pull the latest changes.
  6. $ git pull upstream master
  7. If you don't have a local copy of LEAN, fork the LEAN repository and then clone it.
  8. $ git clone https://github.com/<username>/Lean.git
  9. Copy the contents of the Lean.DataSource.<vendorNameDatasetName> / output directory and paste them into the Lean / Data directory.
  10. Open the Lean / QuantConnect.Lean.sln file in Visual Studio.
  11. In the Solution Explorer panel of Visual Studio, right-click QuantConnect.Algorithm.CSharp and then click Add > Existing Item….
  12. In the Add Existing Item window, click the Lean.DataSource.<vendorNameDatasetName> / <vendorNameDatasetName>Algorithm.cs file and then click Add.
  13. In the Solution Explorer panel, right-click QuantConnect.Algorithm.CSharp and then click Add > Project Reference....
  14. In the Reference Manager window, click Browse….
  15. In the Select the files to reference… window, click the Lean.DataSource.<vendorNameDatasetName> / bin / Debug / net6.0 / QuantConnect.DataSource.<vendorNameDatasetName>.dll file and then click Add.
  16. The Reference Manager window displays the QuantConnect.DataSource.<vendorNameDatasetName>.dll file with the check box beside it enabled.

  17. Click OK.
  18. The Solution Explorer panel adds the QuantConnect.DataSource.<vendorNameDatasetName>.dll file under QuantConnect.Algorithm.CSharp > Dependencies > Assemblies.

  19. In the Lean / Algorithm.CSharp / <vendorNameDatasetName>Algorithm.cs file, write an algorithm that uses your new dataset.
  20. In the Solution Explorer panel, click QuantConnect.Lean.Launcher > config.json.
  21. In the config.json file, set the following keys:
  22. "algorithm-type-name": "<vendorNameDatasetName>Algorithm",
    "algorithm-location": "QuantConnect.Algorithm.CSharp.dll",
  23. Press Ctrl+F5 to backtest your demonstration algorithm.
  24. Copy the Lean.DataSource.<vendorNameDatasetName> / <vendorNameDatasetName>Algorithm.py file and paste it in Lean / Algorithm.Python directory.
  25. In the Lean / Algorithm.Python / <vendorNameDatasetName>Algorithm.py file, write an algorithm that uses your new dataset.
  26. In the Solution Explorer panel, click QuantConnect.Lean.Launcher > config.json.
  27. In the config.json file, set the following keys:
  28. "algorithm-type-name": "<vendorNameDatasetName>Algorithm",
    "algorithm-location": "../../../Algorithm.Python/<vendorNameDatasetName>Algorithm.py",
  29. Press Ctrl+F5 to backtest your demonstration algorithm.
  30. Important: Your backtests must run without error. If your backtests produce errors, correct them and then run the backtest again.

  31. Copy the Lean / Algorithm.CSharp / <vendorNameDatasetName>Algorithm.cs file to Lean.DataSource.<vendorNameDatasetName> / <vendorNameDatasetName>Algorithm.cs.
  32. Copy the Lean / Algorithm.Python / <vendorNameDatasetName>Algorithm.py file to Lean.DataSource.<vendorNameDatasetName> / <vendorNameDatasetName>Algorithm.py.

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/net6.0/Tests.dll

You can also see our Videos. You can also get in touch with us via Discord.

Did you find this page helpful?

Contribute to the documentation: