Back

How to get to the Python environment inside the Lean Docker container?

I am able to run the algorithms in the Algorithm.Python folder of the Lean repo using Docker and making the necessary modifications in Launcher/config.json file. This is the command I used:

docker run --rm \
-v /tmp:/Results \
-v $(pwd)/Data:/Data \
-v $(pwd)/Launcher/config.json:/Lean/config.json \
-v $(pwd)/Algorithm.Python/:/Algorithm.Python \
quantconnect/lean:latest --data-folder /Data --results-destination-folder /Results --config /Lean/config.json

I would like to be able to develop algorithms in Python with the help of a Python REPL. I thought I can get one by running:

docker run --rm \
-v /tmp:/Results \
-v $(pwd)/Data:/Data \
-v $(pwd)/Launcher/config.json:/Lean/config.json \
-v $(pwd)/Algorithm.Python/:/Algorithm.Python \
-it \
--entrypoint python \
quantconnect/lean:latest

This launches a Python REPL but running commands like:

from clr import AddReference

gives:

34296_1591917081.jpg 

so I don't think I am using the right Python interpreter inside the container.

How do I call the right Python interpreter inside the Docker container? I know Python but am totally new to the .NET and Mono environment.

 

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.


I found the solution:

docker run --rm \
-v /tmp:/Results \
-v $(pwd)/Data:/Data \
-v $(pwd)/Launcher/config.json:/Lean/config.json \
-v $(pwd)/Algorithm.Python/:/Algorithm.Python \
-it \
--entrypoint mono \
quantconnect/lean:latest nPython.exe

 

1

=) Epic, 100 points! 

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