Back

Lean Vagrant box?

I am having difficulty setting up lean to work with vscode but believe it may be due to my particular base env that I would rather not have to deactivate. As an alternative, I was wondering if a vagrant box containerization method currently exists in order to take any system config issues out of the mix.

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.


Hi there, we offer a fully configured ready to roll Docker container. If you're open to using that its got a bunch of scripts to make it easy to launch in the root of the LEAN repository.

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.


I believe I attempted to use that via the debug in container option but am having some problems actually getting VS code to attach itself after it initializes the container. That is, the container will run and is fully interactive with its own shell but VS code seems unable to actually debug using it.

0

I should mention that I technically could use the interpreter in the container's instance. I will do so in the interim although it remains to be seen how such might interact with my other extensions I hoped to use.

0

Hey Aaron,

Would you mind sending over the details of your problems attaching to the container in VS Code?

Just some preliminary questions:
Are you trying to debug a Python algorithm?
If so, do you have the debugger option in the config set to true, and PTVSD?

The script that is launched with the "Debug in Container" will start the docker image and then connect to the Mono process using a VS Code extension called "Mono Debug". This allows for debugging C#, but to debug Python it requires that we set the config and then connect using the launch option "Attach To Python (Container)" when prompted in the Docker output.

 

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.


Indeed I should have mentioned I am using python.

Output errors:

Following debug in container, I see x64 errors of form (for each comment):

{
"resource": "/..../Lean/Launcher/config.json",
"owner": "_generated_diagnostic_collection_name_#4",
"code": "521",
"severity": 8,
"message": "Comments are not permitted in JSON.",
"startLineNumber": 2,
"startColumn": 5,
"endLineNumber": 2,
"endColumn": 68
}

But then I ignore that and merely enter the attached terminal to enter my root password. After this, I run Attach to Python (Container), but the debugger immediately then proceeds to exit.

0

Ah yes, VS Code can be picky about comments in JSON files. This StackOverflow link describes how to fix that.

Althought that fix is nice, it shouldn't change your ability to launch and connect to the debugger. One thing that is an issue that might be causing a problem is when the "Debug In Container" launch option attempts to attach to the Mono debugger server running in the container, is that it will timeout if it is not able to attach within a certain amount of time. When this happens VS Code will also launch a "close-docker" task that will attempt to shut down the container.  Unfortunately the Mono extension in VS Code does not allow a longer timeout period to be set. With Windows this isnt much of an issue since it doesn't require a root password to start the container, but with Linux/Mac a couple of extra seconds makes a difference.

There are a few ways around this,
One options is to look at your "launch.json" file in the ".vscode" directory. Under "Debug in Container" comment out the "postDebugTask" that will attempt to close the docker if the debugger connection doesn't connect. Once you do this the container will not be stopped after exiting the debugger. If the intial debugger connection doesn't connect to mono in time, you can use the already configured "Attach to Mono" to try and connect to the container again. Once you get this initial connection the Lean should start up and you should see the Python debugger connection waiting.

Lean is setup to wait for this Mono connection always, but there are ways to disable the mono debugger as well. This can be done in the "tasks.json" under ".vscode" dir, just change "run-docker" argument "debugging=Y" to "N". Then it won't await a mono connection at all, and Lean should start up imediately.

 

Either of these options should atleast get you into Lean so you can connect your debugger. Please refer to the readme under the ".vscode" directory as well, it goes into detail on the many different ways you can use it.

Hope this helps!!

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.


Its certainly an intricate process! I think for the time being I will merely start the container and launch python from within manually, then attaching the interpreter to the local vscode process. This does seem to work, luckily.

1

I think the problem has to do with my pythonnet installation. Removing my local ~/anaconda3/lib/python3.7/site-packages/clr/ folder and then reinstalling solved the issue. FWIW I am on arch linux and mono-complete isn't on the aur. By comparison, I set up a VM with ubuntu and by merely following the steps on the github docs, I did not encounter an issue. If this is due to my distro or my particular environment, however, is up in the air but can be tested when I get the time by merely initializing a new venv.

0

Hmmm, interesting.

I'm glad the VM setup works for you and I appreciate you following up on thread so we can know where the issue might lie. I have been poking around with a docker dev container in my free time that has Lean all configured and is set up to work in with a VS Code remote connection. If that project turns out to be succesful I hope to get an official release which should help in situations like this.

1

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.


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