Back

How to run Lean with python locally

I download the project from github. I compile it with VS2019, and updated the config file. I then try to run a simple algorithm. An error comes up.

ERROR:: WorkerThread.<.ctor>b__7_0(): WorkerThread(): exception thrown when running task Python.Runtime.PythonException: NameError : name 'Resolution' is not defined

I would like to ask which library should I import? Thank you.

Attached the code I am testing. I have already added to the head of the file but don't know how to continue:

from QuantConnect.Algorithm import *

Thank you very much.

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 am unsure of exactly what your code looks like as the linked backtest does not show the imports. Try again with clr/quantconnect imports before any non-Lean libraries or ensure that your import arguments are made *FIRST* in the .py file. I just debugged a similar problem in my environment and noticed that algos without third party imports and make such import args immediately had no issues with Resolution (e.g., WarmupAlgorithm.py should work).

1

Aaron Janeiro Stone 

Thank you. I would like to ask if there is a way to find the correct package to import for local lean ? For example, if I am using MorningstartSectorCode.xxx, how can I know which quantconnect package should I import ?

 

0

Hi Sulfred,

One method of finding the correct imports would be to run the algorithm, get the error, look for the class in LEAN using the IDE search, then add that import, and repeat this step until all of the necessary imports have been added.

Best,
Shile Wen

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