Back

ReadMe on Running Local Backtests in Linux Python

Hi,

I have managed to get Lean working locally in Linux with the Python module. However, I'm still confused about a few thiings. 

 

1. Do I have to go through the whole "xbuild... " procedure followed by mono ./QuantConnect.Lean.Launcher.exe each time I change up my algorithm by a little bit, or each time that I change which file it points to? 

2. I did read that data available on the cloud is not available locally due to licenscing reasons. If I were to purchase the license, how would that data then feed into my local backtests? Alternatively if I had my own data where would I place it and in what format for my backtest to run locally. 

3. I have gotten the "global name: MovingAverageType is not defined" error. Is this related to not having data set up or do I have to import or place another module somewhere? 

4. I'm trying to load a file into my script. I have the exact filepath in my Linux setup to go, but it still says file not found. I have the file placed in the same folder as the script. Does the program import/load files from a separate location or need some other references? 

 

Thanks for all of the help!

Update Backtest








1. Since we are talking about python, no, you don't need to rebuild Lean. You just need to delete the pyc files in Lean/Algorithm.Python directory.

2. The license we mention is the licensing agreement between us (QuantConnect) and our data vendors. You can use your own data (note that it should be written in Lean format), it should go into Lean/Data subfolders matching the security type and resolution. 

3. It is related to not importing the required QuoteConnect library. Please add:

AddReference("QuantConnect.Indicators")
from QuantConnect.Algorithm import *

4. Any input file should be placed in the executable directory Lean/Launcher/bin/Debug. If you want to place it in the script location (Launcher/Algorithm.Python), you can use the relative path. For instance, if you want to read a name called data.csv, you need to write in the python script that it can be found at ../../../data.csv. 

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.


Thank you for your responses. That all makes sense. I do have a follow-up on #2 however. How do I convert a regular .csv data file to the Lean Format?

0

Please take a look at the Toolbox project.
There we can find programs that convert data from different sources to Lean format.
Checkout LeanDataWriter.cs.
 

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.


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