Back

Unit Testing Algorithms

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
Update Backtest








We haven't got one but its been on my todo list, we could even supply a small sample of data to help. We're a small bootstrapped group so welcome any help and contributions to the community Dennis -- Would you be willing to make the wrapper and we could publish it on GitHub?

We were thinking of allowing live trading with this harness as well -- with an API to their local IB account, so you could backtest in the cloud and trade locally if you wanted.

At the moment most users build locally, and then debug using "Debug()" which sends short messages to the IDE, or "Log()" which allows up to 2000 lines per day.
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.


Hi, Jared. Sorry to take a couple of days to respond. I have used the debug and log, and both work, but I'm wanting to feed a small set of data into my tests - trying to follow TDD, still finding my way around that way of thinking :)

Yes, I would be willing to help write the wrapper. It may take a bit, as I'm getting just a few hours per week on this. Also new to "opensource" type projects and git, so I may need a little coaching there.

I used the Log a few days ago, and tried to serialize 4 days of minute resolution data into JSON for testing, but the build failed as I was using the System.Runtime.Serialization.Json namespace. Is there another serialization framework I should be calling that you prefer? I ended up using a plain StringBuilder.

One thought on the wrapper - I would like to see it have a repository interface that the QC community could implement their own repositories to the data stream. That way people could store the test data in their file/datastore/datasource of choice. I believe it would also support your thinking of feeding alternate data streams for live trading?

I poked around the github repo last night, and I don't see any community coding standards published. For now, I'll follow the standards in the current files, hope that is okay. Also, let me know if you guys have a tracking mechanism for things you'd like the community to help submit.

Thank you very much.
0

Hey @Dennis :) I'm happy to help, we've already written a desktop trading environment for my last company so it should just be simple to port it over.

We don't have any coding standards published, but if you copy the styles and comment well that should be fine. Perhaps we should do a phone call to discuss and sketch out the starting points?

Please don't try and serialize the data for download or our data providers will revoke our licence, that would be against the terms of use (https://www.quantconnect.com/terms). I'll ask the provider if we can make a week available at all the different resolutions for testing purposes.
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.


Sorry, Jared, unintentional violation. Data is destroyed on my end. I will do a personal reach out with my contact info so we can discuss potential options on the wrapper.
0

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!

0

Andreas Sandberg Yes its in the Algorithm Runner - in the tests project with 50+ algorithms under regression in Python & C#.

https://github.com/QuantConnect/Lean/blob/master/Tests/AlgorithmRunner.cs
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.


Thanks Jared, much appreciated!

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