In "Python for Trading" course: Section 3, Unit 6 Calculating Moving Average, I can't seem to resolve the following error in my code:
No module named quantrautil
Here's my code:
import pandas as pd
from quantrautil import get_data
# To fetch data, you can either load from pandas_datareader or download & read data from CSV
data = get_data('AAPL')
I've already pip installed Quandl, fix_yahoo_finance, iexfinance.stocks, and nsepy.
It works in the command prompt built-in to the course online, but not in my standalone jupyter notebook. How can I make it work there?
Also, I've already tried this reference link, but it didn't help:
https://quantra.quantinsti.com/questionDetails/219/Quantrautil-import-getdata-not-working
https://quantra.quantinsti.com/questionDetails/67/quantrautil-library
After saving the file quantrautil.py to my site-packages directory, its now resulting in the following error:
File "C:\Users\HP\Anaconda2\lib\site-packages\quantrautil.py", line 7
<!DOCTYPE html>
^
SyntaxError: invalid syntax
*NOTE: I did not change anything on that code chuck file before saving it to the destination.
Gary, It seems like some html component got copy pasted in the quantrautil file.
You can follow below steps to fix the problem:
- Go to the following github link where quantrautil raw code is: https://raw.githubusercontent.com/QuantInsti/Quantra-Courses/master/quantrautil.py
- Open a text editor or spyder, create a new file, paste the code and save it as "quantrautil.py". The location can be either site-package folder or your current working folder (where your other files are stored).
- Run the code which you have mentioned in the first post.
Note: you have to replace line no. 17 with the quandl api key. This key helps to authenticate your request to quandl. To get your API key, sign up for a free Quandl account (https://docs.quandl.com/docs#section-authentication). Then, you can find your API key on Quandl account settings page
I hope this solves your problem. Please feel free to post the comment if this doesn't solve your problem.
Yes, that worked! All good now. Thank you