I have been working in Visual Studio with a local copy of the QC Algorithm project from Github. I am curious about how others are unit testing components and integration testing their algorithm for correct operation before deploying it for backtesting into QC.
Does anyone have a "test harness" running that feeds a local data stream into the OnTick or OnTradeBar handlers? If so, would you be willing to share what it looks like?
Thanks
Jared Broad
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.
Dennis Howell
Jared Broad
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.
Dennis Howell
Andreas Sandberg
Greetings, wanted to see if there was any additional progress on this front. In short I have my own data and would like to ensure as I'm developing my algos I don't regress certain use cases. Anybody cobble anything together? I do see there are some tests for the Lean engine itself but don't see anything I could use as an example for the actual algos. Thanks!
Jared Broad
Andreas Sandberg Yes its in the Algorithm Runner - in the tests project with 50+ algorithms under regression in Python & C#.
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.
Andreas Sandberg
Thanks Jared, much appreciated!
Timothy
Is there any documentation anywhere on how to do testing? I haven't been able to find any.
Louis Szeto
Hi Timothy
It is usually not necessary to run unit tests since we had tested all functionality before publishing, but if you wish to test for the algorithm statistics are as expected, you may use regression test. First, you will need to download the LEAN repo to local, as well as having .NET6 SDK installed, be sure to add your dotnet sdk folder to PATH (check here and here). Then, put your regression algorithm under `/Lean/Algorithm.CSharp` directory.
If you have visual studio installed, open the `QuantConnect.Lean.sln` file in local LEAN repo by VS. Look for `/Tests/RegressionTests.cs`, right-click and select `run test` to do your regression test. Otherwise, open a command line terminal and cd to the root directory of the downloaded LEAN local repo. Run `dotnet test --filter “TestCategory=RegressionTests”`.
Best
Louis
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.
Timothy
Hi Louis.
Thanks for taking a look. I did experiment a bit down this road previously including setting up the dotnet environment but i realized that these tests are fundamentally different from the tests that i would like to run.
I would love to have my algorithm teseted under various scenarios to make sure that i do not break things and also that my assumptions are corrected. I would for instance like to feed in mock data and see how my indicators behave. This is very slow to do manually with backtests and i lose out on not having them automated and run on code changes.
When i was digging around it felt like I would need to have quite a bit of knowledge in order to set something like this. Are the existing regression tests still the place to look for this type of testing?
Louis Szeto
Hi Timothy
Maybe you'd need to add some custom unit tests. Create a test under the project “QuantConnect.Lean.Tests” in the LEAN repo with input values and expected output values. Right click the created testing file and click “Run Tests" in Visual Studio should do what you'd want.
Best
Louis
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.
Dennis Howell
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!