I have LEAN Desktop installed along with the Visual Studio add-in. Following along with the information on this page:
https://www.quantconnect.com/tutorials/open-source/backtesting-from-visual-studioWhen I click on an algorithm and right-click "send for backtesting", I see "QuantConnect: Backtesting project" in the Visual Studio statusbar, but then Visual Studio restarts.
I expected a browser window to open to monitor the backtest results.
Any suggestions on why this is happening?
Thanks,
-Frank
Quanticus
Hi,
Let me know if I understand your question first.
You have a copy of Lean engine compiled in Visual Studio and you want to start a backtest in GUI mode displaying the data into the "Lean Backtest Desktop" window. Doing so, your Visual Studio restarts.
I use latest master branch in Visual Studio 2017 and 2019 and all is working fine.
The only difference is that I do not use any plugin as I like to kow at the low level what is happening.
Personally I would have a clean Visual Studio environment in which you compile Lean.
Then you just have to configure a few things:
1. In QuantConnect.Lean.Launcher project, modify config.json file as per below:
"environment": "backtesting-desktop"
"algorithm-type-name": "BasicTemplateFrameworkAlgorithm", //or whatever algo you have
"algorithm-language": "CSharp" //cSharp is as default as I use C#
"job-user-id": "xxxx",
"api-access-token": "yyyy",
xxxx and yyyy you find them into "My Account section as below"
"Your unique access token to the API is shown below:
yyyy
Your user id for the API is shown below:
xxxx"
2. Second Step is: Right Click on QuantConnect.Lean solution and select "Properties"
On this "Property Pages" window, select "Configuration" under "Configuration Properties".
This will list all projects and here make sure all projects have the same Configuration
either "Debug" either "Release".
As default in debug mode, all have "Debug" selected except project QuantConnect.Views
which has the "Release" configuration selected.
This will give you runtime exceptions if you try to start the application (QuantConnect.Lean.Launcher" is the default project to run by the way).
Once you made sure all projects have lets say Debug Configuration selected, click Apply and then OK.
Save all and recompile the solution.
If you do all these stepts correctly it will work and you shoulsee "Lean Backtest Desktop" window.
Cheers and Happy testing
Frank Perugini
Thanks HappyPip. I actually did all of the above and I can run backtests with no issues locally. I installed the VSIX add-in so that I can backtest in QuantConnect where I can use larger datasets. Is there a way to to accomplish this easily without the add-in? I can always copy my strategy source code to QuantConnect manually, but I thought this is why the add-in was created, to facilitate local development in VS, then copying the strategy files to QuantConnect for testing.
I even compiled the VSIX project from source, uninstalled the precompiled version, then replaced it with the version I compiled, and that threw errors when I tried to use it.
Any suggestions on how to develop locally, and backtest in the cloud in an easy fashion? What do you all do?
-Frank
Michael Manus
hm when you did so much could you try the last point in the manual and turn on the log.
https://www.quantconnect.com/tutorials/open-source/backtesting-from-visual-studio#Backtesting-from-Visual-Studio-Troubleshootingmaybe the log says that they have a bug in the plugin why your Visual studio dies.
Frank Perugini
I just tried that and nothing was recorded to the log. Here's a very short screencast showing what happens:
https://www.screencast.com/t/IiLQY1zuG9ICFrank Perugini
I tried this process on another computer and it worked properly. The backtest executed on QuantConnect and the backtest results window opened properly. This computer was also on another network and I noticed that when I ran the LEAN engine for the first time it prompted me for a firewall exception which I don't remember seeing on the original computer. I'll look to add that exception manually and see if it makes any difference.
Michael Manus
ooh ok firewall settings :) :) :) :) :) :) :) :) :) :) :) :) :)
Martin Molinero
Hi! Some ideas:
- Have you tried running Visual Studio as Administrator?
- What version of VS are you using, is it different from the other computer that successfully `Sent for backtesting`? -> Might be worth updating your VS
- The VisualStudio activity log should throw some light, please check VS documentation on how to set it up and find it: doc1 or doc2 there are some SO posts about it too.
- Can you open an existing backtest from the QuantConnect tool window?
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.
Frank Perugini
Hi Martin, thanks for the suggestions.
- I always run Visual Studio as Administrator
- Yes, the 2 computers both have the same verison of Visual Studio
- I already tried using the Activity Log window, and when I send for backtesting, a new entry is created and it looks like things are running, but then Visual Studio crashes and restarts.
- Yes, I can open an existing backtest from that window.
What I found is happening is that the Visual Studio add-in crashes at some point late in the backtest process and causes Visual Studio to crash and restart. I found this by entries in the Windows Event viewer.
The first entry is a .NET null pointer exception in the VSIX add-in, then the second is devenv.exe crashing.
I removed the pre-compiled VSIX add-in, then compiled the VSIX add-in project trhat comes with the LEAN distribution in Debug mode and configured the project for debugging. I was stepping through in the debugger and was going the find the point of failure and correct it, but I'm having issues with an area of code where the quantconnect login occurs, so I can't get to the backtesting portion yet.
I'll try again today and reach out to the LEAN google group for help.
Regards,
-Frank
Frank Perugini
I finally got it working, I installed the latest updates to Visual Studio 2017, then I compiled the VSIX add-in from the LEAN source distrubution, installed that compiled VSIX, and everything works properly now.
Martin Molinero
Awesome!
Wondering if the precompiled version of the plugin did not work for you after the VS update?
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.
Frank Perugini
Martin, I did not go back to test that becasue I'm in the middle of strategy development now and don't want to disrupt my progress. The precompiled version is installed and working on my other PC with the same version of VS.
Frank Perugini
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!