lean-cli icon indicating copy to clipboard operation
lean-cli copied to clipboard

Inconsistent inclusion of library code in local an cloud backtest (Python)

Open sandrinr opened this issue 4 years ago • 1 comments

Consider the following file structure:

+
|- Library
|  |- MyLibrary
|     |- mylib.py
|- MyProject
   |- main.py

In order to make mylib from MyLibrary available in main.py from MyProject I need to use two different import statements depending on whether i run the code in a local or in a cloud backtest.

Local backtest needs:

from MyLibrary import mylib

Cloud backtest needs:

import mylib

I think this difference comes from the fact that in local backtesting the Library folder is sourced into the backtest as is. However, in cloud backtesting, QC copies the contents of the referenced libraries into the projects directly. In our case here, mylib.py would be copied next to main.py.

sandrinr avatar Dec 29 '21 09:12 sandrinr

Also suffer from this issue

MatanSabag avatar Jan 15 '22 20:01 MatanSabag

Closing with #175

Now both imports work in cloud and locally:

from MyLibrary import mylib

or

import mylib

for the projects structure above.

jhonabreul avatar Oct 04 '22 13:10 jhonabreul