I just signed up for a Researcher subscription and already am having issues.
Followed the instructions on setting up Local Platform here (https://www.quantconnect.com/docs/v2/local-platform/installation/install-on-macos), was able to successful RUN a backtest with the sample code provided in main.py connecting to the QuantConnect cloud platform.
HOWEVER, I would like to DEBUG, as outlined here (https://www.quantconnect.com/docs/v2/local-platform/backtesting/debugging), and after setting a breakpoint, when I press the 'Debug with Lean CLI' button I get an error popup with message: "connect ECONNREFUSED 127.0.0.1:5678" and an action to open the launch.json file.
I think this has something to do with Docker, but I only installed it based on the QuantConnect instructions and have no idea what I'm supposed to configure. I just want to set break points as I execute the code. Here is my launch.json file (with personal directories replaced with <PRIVATE>):
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug with Lean CLI",
"type": "python",
"request": "attach",
"connect": {
"host": "localhost",
"port": 5678
},
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "/LeanCLI"
},
{
"localRoot": "<PRIVATE>",
"remoteRoot": "/Library"
}
]
}
]
}
Mia Alissi
Based on the information provided in the extracts, it seems like you're trying to debug your algorithm using the Lean CLI and encountering an issue with the connection to Docker.
The error message "connect ECONNREFUSED 127.0.0.1:5678" suggests that the debugger is unable to connect to the specified port on your localhost. This could be due to a variety of reasons, such as Docker not running, the specified port being blocked or used by another process, or a misconfiguration in your
launch.json
file.Here are a few steps you can take to troubleshoot this issue:
Ensure Docker is running: Docker needs to be running for the Lean CLI to work. You can check if Docker is running by using the command
docker info
in your terminal. If Docker is not running, you may need to start it manually.Check if the port is blocked or used by another process: You can use the command
lsof -i :5678
in your terminal to check if the port 5678 is being used by another process. If it is, you may need to stop that process or use a different port.Review your
launch.json
configuration: Thelaunch.json
file is used to configure the debugger in Visual Studio Code. Based on the extracts, your configuration seems to be correct, but you may want to double-check it against the documentation.If you continue to experience issues, you may want to refer to the QuantConnect documentation or ask for help in the QuantConnect forum.
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.
Anthony Sabbadini
I ran
docker info
and the return showed a bunch of information, indicating Docker is running.
I then ran
lsof -i :5678
and it returned nothing, which I assume means there is nothing currently using of that port.
Not sure what to do.
Mia Alissi
Based on the information provided in the extracts, it seems like your Docker is running and the port 5678 is not being used by another process, which are both good signs.
One thing to note when running algorithms in a Docker container is that
localhost
does not point to your computer'slocalhost
. Instead, you should substitutelocalhost
withhost.docker.internal
if your algorithm needs to connect to other services running on your computer. In other words, instead of connecting tohttp://localhost:<port>/
, connect tohttp://host.docker.internal:<port>/
. This information is mentioned in the Deployment section of the documentation.However, this might not be the issue as the error message you're seeing typically indicates a problem with the debugger connecting to the Docker container, not the algorithm connecting to other services.
If you're still unable to solve your issues, you are welcome to contact the QuantConnect engineers by opening an issue in the QuantConnect/lean-cli repository on GitHub. Before doing so, please run the command that's giving issues with the
--verbose
flag and copy and paste the output into the issue. The--verbose
flag enables debug messages to be printed, which makes it easier for the engineers to help you. This information is mentioned in the Troubleshooting section of the documentation.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.
Anthony Sabbadini
After replacing the
"host": "localhost",
line in the launch.json file with
"host": "host.docker.internal",
instead of:
connect ECONNREFUSED 127.0.0.1:5678
I received the error message:
getaddrinfo ENOTFOUND host.docker.internal
Not sure what to do.
Mia Alissi
The error message
getaddrinfo ENOTFOUND host.docker.internal
suggests that the system is unable to resolve the hostnamehost.docker.internal
. This hostname is typically used to connect to services running on the host from within a Docker container.However, it's important to note that
host.docker.internal
is currently only guaranteed to work on Windows and Mac systems. If you're running Docker on a Linux system, this hostname may not be recognized, which could be the cause of the error you're seeing.If you're running Docker on a Mac or Windows system and still seeing this error, it could be due to a misconfiguration or issue with your Docker installation. In this case, you may want to try reinstalling Docker or checking your Docker settings to ensure that
host.docker.internal
is correctly mapped to your host's IP address.If you're still unable to solve your issues, you are welcome to contact the QuantConnect engineers by opening an issue in the QuantConnect/lean-cli repository on GitHub. Before doing so, please run the command that's giving issues with the
--verbose
flag and copy and paste the output into the issue. The--verbose
flag enables debug messages to be printed, which makes it easier for the engineers to help you. This information is mentioned in the Troubleshooting section of the documentation.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.
Anthony Sabbadini
I am running on a Mac.
Anthony Sabbadini
Restarted Docker. Was able to RUN on the cloud. Still unable to DEBUG with BOTH:
localhost
and
Mia Alissi
I'm sorry to hear that you're still having trouble debugging with both
localhost
andhost.docker.internal
.Given the information provided in the extracts, it's difficult to pinpoint the exact cause of the issue. However, it's worth noting that Docker-related issues can sometimes be resolved by checking Docker's file sharing settings. According to the Troubleshooting section of the documentation, you should ensure that Docker's Settings > Resources > File Sharing includes the necessary directories.
If you're still unable to resolve the issue, I recommend reaching out to the QuantConnect team for further assistance. You can do this by opening an issue in the QuantConnect/lean-cli repository on GitHub. Before doing so, please run the command that's giving issues with the
--verbose
flag and copy and paste the output into the issue. The--verbose
flag enables debug messages to be printed, which makes it easier for the engineers to help you.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.
Anthony Sabbadini
Restarted Docker. Was able to RUN on the cloud. Still unable to DEBUG with BOTH:
localhost
and
Anthony Sabbadini
OK, I finally figured this out. In order to connect the VSCode debugger, one has to first:
Open a terminal in your organization workspace, run lean backtest "<projectName>" --debug ptvsd
via the CLI, as explained in:
https://www.lean.io/docs/v2/lean-cli/backtesting/debugging
Anthony Sabbadini
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!