Intro and Getting Stock Price Data – Python Programming for Finance p.1

Home/Programming Video Tutorials/Python Video Tutorials/Intro and Getting Stock Price Data – Python Programming for Finance p.1

Intro and Getting Stock Price Data – Python Programming for Finance p.1

FavoriteLoadingAdd to favorites

Welcome to a Python for Finance tutorial series. In this series, we’re going to run through the basics of importing financial (stock) data into Python using the Pandas framework. From here, we’ll manipulate the data and attempt to come up with some sort of system for investing in companies, apply some machine learning, even some deep learning, and then learn how to back-test a strategy. I assume you know the fundamentals of Python. If you’re not sure if that’s you, click the fundamentals link, look at some of the topics in the series, and make a judgement call. If at any point you are stuck in this series or confused on a topic or concept, feel free to ask for help and I will do my best to help.

https://pythonprogramming.net

https://www.facebook.com/pythonprogramming.net/
https://plus.google.com/+sentdex

By | 2017-06-12T02:06:53+00:00 June 12th, 2017|Python Video Tutorials|50 Comments

50 Comments

  1. neil armstrong June 12, 2017 at 2:08 am - Reply

    while running web.DataReader(‘GOOG’, ‘yahoo’, start, end), ย I get following error: RemoteDataError: No data fetched using ‘YahooDailyReader’ – how to debug it?

  2. Andrew Loo June 12, 2017 at 2:09 am - Reply

    does this still work? yahoo seems down?

  3. Aki Riisiรถ June 12, 2017 at 2:11 am - Reply

    Hello! Thank you for these tutorials, they are awesome. Can you recommend any good book(s) about analytics with Python?

  4. mina Benjamin June 12, 2017 at 2:13 am - Reply

    I can’t install pandas on my machine (MacBook), can you help pls?

  5. kish bish June 12, 2017 at 2:14 am - Reply

    I wrote down exactly what you did for the first example, but got the following error, why? I have version 3.6.1.
    AttributeError: module ‘pandas_datareader.data’ has no attribute ‘datareader’

  6. otacon1024 June 12, 2017 at 2:15 am - Reply

    Cool, I’ve been writing a complete Bitcoin trading app for the past week or two, so this could end up being a good reference and source of ideas like your previous finance videos.

    I hope you’ll at least touch on genetic algorithms when backtesting, you mentioned them in passing before but never really covered them, and it would be awesome to see your take on them.

  7. Kevin Millan June 12, 2017 at 2:15 am - Reply

    got it. used google

  8. Thames Khi June 12, 2017 at 2:16 am - Reply

    Thankyou very much for sharing your python knowledge with us online. It’s been fun learning python on my PC using your videos alongside other materials. As per your advice, I am now ready to start my project. I hope this will bring me some financial freedom and a route out of the rat race. I would like to learn to integrate my python code and display results like graphs, calculations on a website. The idea is to create a prototype. Do you have any suggestions? I noticed that for graphs you have been using static png files. Thank you very much.

  9. Elddy hosea June 12, 2017 at 2:19 am - Reply

    Edward can you please add the code as part of the video series. It’s inefficient for us to pay attention to the lesson while trying to keep up with typing

  10. vincent uhlke June 12, 2017 at 2:20 am - Reply

    Does anyone get also the error: AttributeError: ‘_NamespacePath’ object has no attribute ‘sort’ย  :S

  11. Johnny Scott June 12, 2017 at 2:21 am - Reply

    I installed all the libraries you mentioned and ran the script but got an error. It says "No such file or directory: ‘gg.plot’ and ‘OSError: ‘gg.plot’ not found in the style library and input is not a valid URL or path.’ I’ve found many sites about how to install gg.plot but they won’t install properly. Is there another library/package I can install and also get gg.plot? I installed Python 3.5 on Windows 10 64bit.

  12. reddy nishanth June 12, 2017 at 2:21 am - Reply

    This was the error when I tried to implement the above code:-
    Traceback (most recent call last):
    File "E:Codesentfin1.py", line 11, in <module>
    import pandas_datareader.data as web
    File "C:UsersMy ComputerAppDataLocalProgramsPythonPython36libsite-packagespandas_datareader__init__.py", line 3, in <module>
    from .data import (get_components_yahoo, get_data_famafrench, get_data_google, get_data_yahoo, get_data_enigma, # noqa
    File "C:UsersMy ComputerAppDataLocalProgramsPythonPython36libsite-packagespandas_datareaderdata.py", line 7, in <module>
    from pandas_datareader.google.daily import GoogleDailyReader
    File "C:UsersMy ComputerAppDataLocalProgramsPythonPython36libsite-packagespandas_datareadergoogledaily.py", line 1, in <module>
    from pandas_datareader.base import _DailyBaseReader
    File "C:UsersMy ComputerAppDataLocalProgramsPythonPython36libsite-packagespandas_datareaderbase.py", line 13, in <module>
    from pandas_datareader._utils import (RemoteDataError, SymbolWarning,
    File "C:UsersMy ComputerAppDataLocalProgramsPythonPython36libsite-packagespandas_datareader_utils.py", line 5, in <module>
    from pandas.core.common import PandasError
    ImportError: cannot import name ‘PandasError’

  13. Jayden M June 12, 2017 at 2:21 am - Reply

    Hi, I am using python36 and pip installed pandas datareader, yet it pumps me an error when I trying to
    import pandas_datareader.data as web

    this is the error return ;

    Traceback (most recent call last):
    File "F:DownloadsPython Worktry figuring thigns outfinancetry.py", line 1, in <module>
    import pandas_datareader.data as web
    File "C:Python36libsite-packagespandas_datareader__init__.py", line 3, in <module>
    from .data import (get_components_yahoo, get_data_famafrench, get_data_google, get_data_yahoo, get_data_enigma, # noqa
    File "C:Python36libsite-packagespandas_datareaderdata.py", line 7, in <module>
    from pandas_datareader.google.daily import GoogleDailyReader
    File "C:Python36libsite-packagespandas_datareadergoogledaily.py", line 1, in <module>
    from pandas_datareader.base import _DailyBaseReader
    File "C:Python36libsite-packagespandas_datareaderbase.py", line 13, in <module>
    from pandas_datareader._utils import (RemoteDataError, SymbolWarning,
    File "C:Python36libsite-packagespandas_datareader_utils.py", line 5, in <module>
    from pandas.core.common import PandasError
    ImportError: cannot import name ‘PandasError’

    I was trying to lookup online yet I could not find any solution, anybody can help?

  14. Michael Bricci June 12, 2017 at 2:22 am - Reply

    Does the yahoo finance api not work anymore?

  15. Mehul Patel June 12, 2017 at 2:22 am - Reply

    Thank you very much for this series. ๐Ÿ™‚ ๐Ÿ™‚

  16. Shrikant Shinde June 12, 2017 at 2:23 am - Reply

    Do you use Git?

  17. Lemuel Hui June 12, 2017 at 2:24 am - Reply

    I love your content so much, really. Your stuff is amazing <3

  18. Yaqian Shen June 12, 2017 at 2:25 am - Reply

    Thanks so much for this series of tutorial. They are so helpful! Just wonder where I can find the source code of this tutorial.

  19. Kwame Enyonam June 12, 2017 at 2:25 am - Reply

    This is exactly y I am learning python. I’m not at the level yet to dive into this video but I’ll be back in a few days. Thank you so much for this.

  20. CedricLavieFacile June 12, 2017 at 2:26 am - Reply

    Hello, I”m having serious trouble installing scikit-learn. Using CMD to intall, I get the message "Scientific Python (SciPy) is not installed." BUT THEN, when I try to install SciPy, this is the message I get

    Command "c:userscedricappdatalocalprogramspythonpython36-32python.exe -u
    -c "import setuptools, tokenize;__file__=’C:\Users\cedric\AppData\Local\Te
    mp\pip-build-mfrz88kv\scipy\setup.py’;f=getattr(tokenize, ‘open’, open)(__fil
    e__);code=f.read().replace(‘rn’, ‘n’);f.close();exec(compile(code, __file__,
    ‘exec’))" install –record C:UserscedricAppDataLocalTemppip-kpaqyonj-recor
    dinstall-record.txt –single-version-externally-managed –compile" failed with
    error code 1 in C:UserscedricAppDataLocalTemppip-build-mfrz88kvscipy

    Don’t know what to do and I really need this for work

  21. Dominic Jake King Lim June 12, 2017 at 2:26 am - Reply

    u r smart

  22. MrStetsonator June 12, 2017 at 2:28 am - Reply

    I love your stuff! Glad to see you are posting more and more videos.

  23. 1738 1738 June 12, 2017 at 2:28 am - Reply

    Can I use this on Quantopian or do I need to actually download the files mentioned?

  24. TheMrCatDogRabbit June 12, 2017 at 2:29 am - Reply

    Help ๐Ÿ™ I get this error:

    File "E:My programsPythonAnacondalibsite-packagespandas_datareaderbase.py", line 120, in _get_response
    raise RemoteDataError(‘Unable to read URL: {0}’.format(url))

    RemoteDataError: Unable to read URL: http://ichart.finance.yahoo.com/table.csv?a=0&ignore=.csv&s=TSLA&b=1&e=17&d=4&g=d&f=2017&c=2000

  25. Doug P June 12, 2017 at 2:31 am - Reply

    Though not necessary for this tutorial, I was unable to install scikit-learn. The error msg said scipy is needed. When I attempted to install it an error occurred saying I should use pip for installing, which I’m using. I went to the scikit-learn website mentioned in the error msg, but it wasn’t really helpful. Has anyone else had problems installing scikit-learn? Any help is appreciated.

  26. John Fisher June 12, 2017 at 2:34 am - Reply

    In case you are wondering, Edward Snowden is using idle3. Type idle3 in your terminal and it should open it. Then go to file and open. That should get you to a similar screen as him.

  27. Peter Talesnik June 12, 2017 at 2:34 am - Reply

    So i get an attribute error when i try to run this code. Googling gets me to tpoics saying that it is an issue with pandas being used instead of pandas_datareader. What do you do to solve this?

  28. VilleV Kettu June 12, 2017 at 2:35 am - Reply

    I had to change the datareader to:

    web.DataReader("NASDAQ:TSLA", ‘google’, start, end)

    instead, as yahoo was not giving me info
    ( RemoteDataError: Unable to read URL: … )

  29. CaptainKage June 12, 2017 at 2:36 am - Reply

    Could you help me with getting whole output with all prices? ๐Ÿ™‚

    as an output I get only this
    2011-01-11 126.248814
    2011-01-12 127.808929

    2015-10-20 133.165604

    first 30 and last 30 values
    with code print(df)

  30. bala google June 12, 2017 at 2:37 am - Reply

    can you some basic videos on python for absolute beginners

  31. Nuno Silvestre June 12, 2017 at 2:38 am - Reply

    Can get DateTime Module to work ๐Ÿ™ using Ubuntu 16.04 HELP!

    always get:

    ย import datatime as dt
    ImportError: No module named datatime

  32. Vibhutha Kumarage June 12, 2017 at 2:40 am - Reply

    I missed your videos @sentdox.. You made a huge surprise..

  33. lankyfingers June 12, 2017 at 2:40 am - Reply

    You should do a series about finding an edge in trading with Python! With futures too, not always stocks etc.

  34. Animesh Gaitonde June 12, 2017 at 2:42 am - Reply

    Which IDE do you use for Development ?

  35. Kevin Millan June 12, 2017 at 2:42 am - Reply

    hi, i’m having trouble fetching the data from yahoo. your code gives me the following error:

    RemoteDataError(‘Unable to read URL: {0}’.format(url))
    pandas_datareader._utils.RemoteDataError: Unable to read URL:

  36. Ravi Raaja June 12, 2017 at 2:43 am - Reply

    upload videos at slow rate.. ๐Ÿ˜› because if you start uploading any shit named as python… my entire day will be lost from college assignments and projects becoz i keep on listening to your idle ๐Ÿ˜› /…..ha ha…. dude your tutorials are awesome ๐Ÿ™‚
    please complete drone tutorials asap ………

  37. ravi teja June 12, 2017 at 2:46 am - Reply

    Hey how do we do this for forex trading can you please consider currency pairs instead of stocks please

  38. Vedant Gawade June 12, 2017 at 2:48 am - Reply

    Can we use pycuda for doing the hard work ??

  39. David SERERO June 12, 2017 at 2:50 am - Reply

    Hey! i have this error message : AttributeError: module ‘pandas_datareader.data’ has no attribute ‘Datareader’. When i install it on my computer it says " Requirement already satisfied" so i guess i have already downloaded it. I can’t see what I did wrong. can someone help?

  40. Randy Diaz June 12, 2017 at 2:51 am - Reply

    Dude Brilliant! I hope you can teach us how to get fundamental data outside of the Quantopian API also!

  41. Prashant Nayak June 12, 2017 at 2:52 am - Reply

    for the example you have shared , i am getting error with import pandas_datareader.data as web. Do i need to do it in different way

  42. bala google June 12, 2017 at 2:53 am - Reply

    can you some basic videos on python for absolute beginners

  43. Sonny Torres June 12, 2017 at 2:54 am - Reply

    As soon as I pressed that F5…..WHAT IS THIS VOODOO THAT YOU SHOW ME???!?!?!?

  44. Olf Mombach June 12, 2017 at 2:54 am - Reply

    8:08
    I love how the tail needs more space just because Tesla’s stock rose so extremely ๐Ÿ˜€

  45. Principal Concepts June 12, 2017 at 2:56 am - Reply

    I keep getting import _tkinter # If this fails your Python may not be configured for Tk
    ImportError: No module named _tkinter on fedora yet I have tk-devel and tcl-devel installed :/

  46. Lee K June 12, 2017 at 2:57 am - Reply

    you are awesome! my hero!

  47. Best Screenwriting Books June 12, 2017 at 2:59 am - Reply

    Extremely frustrating have been trying to get Python up and running and getting all sorts of errors.

  48. Sandesh Daundkar June 12, 2017 at 3:00 am - Reply

    Thanks a lot ๐Ÿ™‚ eternally grateful for your efforts . One stop for python !!

  49. Atharva Kshirsagar June 12, 2017 at 3:02 am - Reply

    No thumbs down ๐Ÿ™‚ everyone loves you

  50. justin pamintuan June 12, 2017 at 3:02 am - Reply

    Hi!! is it possible to get the minute data instead of the daily data from yahoo api?

Leave A Comment

*