Back

How do i test a C# Algorithm locally from Visual Studio?

I understand we can test the algorithm by createing a new unit test inside the project QuantConnect.Tests.  However i set a breakpoint on any of the existsing test and it doesn't seem to break.  Can some one please provide a sample unit test they have written to test their algorithm locally.

Update Backtest








Found the solution to my problem.  You must either install the NUnit VSAdapter vsix extension, or add the adapter as nuget package to your solution. The latest version is the 2.0, and the vsix is available here: https://visualstudiogallery.msdn.microsoft.com/6ab922d0-21c0-4f06-ab5f-4ecd1fe7175d And the nuget package can be found here: http://www.nuget.org/packages/NUnitTestAdapter/

I was able to successfully debug the alogrithm locally from the unit tests after installing the NUnit test adapter.

2

It's certainly possible to run an algorithm as a unit test and there are regression tests that do this. However, I think most people edit their config.json in the Launcher project, set this as the startup project and hit F5.

There's lot's going on in the config.json but the main things you need are near the top:

"environment": "backtesting",

// algorithm class selector
"algorithm-type-name": "ClassNameOfYourAlgorithm",

// Algorithm language selector - options CSharp, FSharp, VisualBasic, Python, Java
"algorithm-language": "CSharp",

//Physical DLL location
"algorithm-location": "Path\NameOfYourAlgorithmLibrary.dll"

It's also possible to automate multiple parallel backtests if you ever feel the need, but this is all you need to do to run a backtest manually.

 

0

Thank you James.

0

Update Backtest





0

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.


Loading...

This discussion is closed