Data model won´t work

Keep error with

ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-1-79a16d69f653> in <module>
     23 sys.path.append("C:/Usersjmbmi/Downloads/Deep-Reinforcement-Learning-in-Trading-Resources/")
     24 
---> 25 from data_modules.quantra_reinforcement_learning import Game
     26 from data_modules.quantra_reinforcement_learning import reward_exponential_pnl

ModuleNotFoundError: No module named 'data_modules'

Hi Johan,



This type of error is usually due to a missing file or folder and the program cannot find it.

Usually, Quantra provides all the notebooks, data files as well as modules that contain different functions, in a zip file at the end of the course.

To make it easily navigable, the folders are named according to the sections of the course and the notebooks of that particular section are in that folder.

For data files, a folder named "data_modules" is also provided in the zip file. The various functions used in the course are placed in a .py file in the folder too. 



When you are running the notebook, we have to make sure that the "data_modules" folder is placed in the same folder. 



Further you have to use the commands



import sys

sys.path.append(“…”)



to make sure that the program understands that it is a function.



A sample way of accessing functions is given below.


  1. Let’s say the function “analyse performance” is stored in the “ST_functions_quantra.py” file. As specified earlier, the module is in the data_modules folder. The location is given as .“C:\Downloads\Python-for-Trading-Basic-Resources\data_modules”, and the notebook “Data Visualization.ipynb” is in the folder “C:\Downloads\Python-for-Trading-Basic-Resources\Importing Data and Data Visualization”.


  2. You would first write the line

    “import sys” which will help you in importing functions in modules.


  3. You would then write “sys.path.append(“…”)” so that we can add a specific path for the interpreter to search.


  4. Finally, we specify the name of the file and function we want to import. Here the name of the file is "quantra_functions" and the function name is "analyse performance".

    Thus, the code will be as follows
from data_modules.quantra_functions import analyse performance