- I understand that local setup here is quite challenging because of the need for mono, pythonnet and any of a number of other components.
- I also understand (after reading every related forum post) that you'd like us to just use CLI Jared Broad 😊
That said, I simply can't run untested code managing real money. I need to be able to break aspects of the algo down into modules, and pytest them thoroughly.
So I've been working on a devcontainer setup that hopefully others with the same needs could also use. Here it is:
To use this, just:
- Install the DevContainers extension from Microsoft in VSCode: https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers
- `git clone https://github.com/jeffdeville/qc_dev_containers`
- open the folder in vscode
- VSCode should ask if you want to reopen the folder in a container in a popup at bottom-right. Do that
- In an integrated terminal (you should be the root users in /workspaces/qc_dev_containers), run poetry install to install the dependencies. (Which you can see in pyproject.toml)
- Now, just run `python main.py`
The error is:
Traceback (most recent call last):
File "main.py", line 1, in <module>
from AlgorithmImports import Resolution
ImportError: cannot import name 'Resolution' from 'AlgorithmImports' (unknown location)
Now, pylance can see it and link to it. And my docker image has successfully installed python3.8, mono, and pythonnet. The dependencies are just quantconnect and friends.
So obviously, what I'd love is for someone to tell me how to fix it, or fork it to your github, fix it, and then make it available to the community.
But what could also help would be:
- Any suggestions about alternative approaches? I see several Dockerfiles in the Lean project. Might one of those be a better starting point that would then be kept up to date more or less automatically?
- My AlogorithmImports package is just a .pyi file that appears to be looking for .dlls in the same directory as the file I'm loading. Does this mean I need to compile the Lean projects, place the dlls with my code at runtime?
Jeff Deville
Ok, digging into how things seem to work a bit. It looks like the c# files are parsed, and empty implementations are written in python. Just enough for pylance to work.
But it does not appear as if there is any facility to go from python → c#. So I'm guessing it's only c# → python. At which point there's really no way to do what I need to do, because things will only work when loaded by the Lean framework, because the calls are basically intercepted by the CLR.
If so, then I'm assuming that my options are:
Is that an accurate assessment?
Martin Molinero
Hey Jeff Deville !
We just pushed a minor improvement to Lean so this use case is easier. Please take a look at the following 4 steps to get lean embedded in python process. We suggest using the lean research image to avoid setup issues, for example mono/pythonnet should not be installed really but dotnet 6 should.
Hope it helps!
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.
Jeff Deville
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!