LEAN is the open source
algorithmic trading engine powering QuantConnect. Founded in 2013 LEAN has been built by a
global community of 80+ engineers and powers more than a dozen hedge funds today.
Alpha League Competition: $1,000 Weekly Prize Pool
Qualifying Alpha Streams Reentered Weekly Learn
more
I have done all what is necessary to be able to debug attach using VS 2019 latest version but am unable to do so. I think the problem is with the VS debug adapter. I am unable to attach although I see Lean waiting for me to do so. Consequently I am unable to develop Lean in python!
Is there a way to launch the python -lean runtime without using the .net Launcher??
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.
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.
If you are using the ptvsd debugger method, can you provide specs about the Python environment and DebugPy version you are using? This can help us determine the problem.
If not, can you describe in more detail the steps you are taking to debug an algorithm? The Launcher is required to run Lean, but I'm sure we can get you started with Lean once we figure this out!
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.
So I'll walk you through the steps that work for me, and if it doesn't work for you or these are the steps you are already following, then we can continue debugging.
First step is to make sure your config file is setup correctly. In this, I'm debugging the Python BasicTemplateAlgorithm.
The next step is to do the ptvsd import and setup. The ptvsd.break_into_debugger() shouldn't be needed, although you can use it to break it. I just set a normal breakpoint where I want it to step into the debugger (line 41).
Next, you want to debug it without attaching it to a process yet. You can use Ctrl-F5, or go to Debug > Start Without Debugging. This will bring up this window. Â
Once you see the line underlined in red, you want to hit Ctrl-Alt-P. This will bring up a window where you will attach to a process. Set the process to the following, hit enter, and then click Attach.
Once you hit Attach, this window will close and bring back up the console window. Lean will then continue to run until it hits the breakpoint or ptvsd.break_into_debugger() you set. After this, you can treat it like the normal VS debugger, although you won't be able to step into any code other than the file you're running, whereas using C# allows you to step into code in other files.
Â
Hopefully, this helps. If it doesn't work or this is what you were already doing without it working, let me know and we'll find another way.
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.
I followed your instructions and they were very clear (thanks) but I get the same strange error when clicking on the debug target from the VS attach to process dialog:
"Path to debug adapter executable not specified.
The program '[54321] Python @ tcp://localhost:5678/' has exited with code -1 (0xffffffff)."
I don't have any other information to go on. But I see Lean waiting for the attachment. How stange.
Lee -- mind 1) making sure your firewall allows access to that port, and then 2) testing this?Â
RUN pip install "ptvsd==3.2.1"https://github.com/Microsoft/PTVS/issues/4270
Â
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.
By this "But I am still unable to debug into Lean." - do you mean to step into both python and LEAN C# classes? Python debugging only works in the python file. If you'd like to debug on the C# side will need to debug using the normal C# process (build in debug mode, set a breakpoint in C#).
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.
Hi Jared, apologies for being rather unclear on this. I meant debug attachment to the C# based Lean Launcher running a python algorithm. I used to be able to do this but am not able to do so at present. Hence I am unable to develop python based strategies. But I am able to debug attach into other python projects using the VS ptvsd plugin. I would struggle to convert code to C# from python otherwise.Â
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...
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!
You do not have enough QC Credit to send this award, get a QC Credit Pack
here.
Award Sent Successfully
Thank you for giving back to the community.
Processing...
Choose a Credit Pack
Payment Confirmation
QuantConnect Credit (QCC) can be applied to your cloud-invoices or
gifted to others in the community with Community Awards in recognition of their contributions.
Community Awards highlight the awesome work your fellow community members are doing and inspires
high quality algorithm contributions to the community. Select an option below to add
QuantConnect Credit to your account:
$5
500 Credit Points
 
$10
1,000 Credit Points
 
$18
2,000 Credit Points
10% bonus
$45
5,000 Credit Points
10% bonus
03/23XXXX XXXX XXXX 0592
We will charge your default organization credit card on file, click
here to update.