10

Does Python has a similar library like quantmod in R that can download financial statement data? I want to download the historical revenue of each stock in Python. Can someone give me a hint? Thanks.

user2668789
  • 211
  • 1
  • 2
  • 10

2 Answers2

16

Yes a lot of them, zipline, pandas and even matplotlib can download data from Yahoo Finance. I recommend you use pandas:

>>> from pandas_datareader.data import DataReader
>>> from datetime import datetime

>>> goog = DataReader("GOOG",  "yahoo", datetime(2000,1,1), datetime(2012,1,1))
>>> goog["Adj Close"]
Date
2004-08-19     49.982655
2004-08-20     53.952770
2004-08-23     54.495735
2004-08-24     52.239197
2004-08-25     52.802086
...
elyase
  • 39,479
  • 12
  • 112
  • 119
  • Ooh, I had forgotten pandas can do that. – Andrew Aug 16 '13 at 16:57
  • You can also try QSTK package `http://wiki.quantsoftware.org/index.php?title=QuantSoftware_ToolKit` There was a entire free online course using this, goolge, Computational Investing, Part I (coursera) – Ahdee Oct 28 '13 at 14:09
3

Rather than build your own system with urllib2, you can use rpy2 to load the actual quantmod package through R into Python. It's somewhat convoluted, but it'll get you the exact quantmod data you're looking for.

Community
  • 1
  • 1
Andrew
  • 36,541
  • 13
  • 67
  • 93
  • 2
    I tried using rpy2 before and as you say found it convoluted. I now use python to write a CSV, then load that in R. OP here can do the opposite and download the data in R, write to a CSV, and then use it from python. – appleLover Aug 16 '13 at 17:43
  • Or just use pandas :) – Andrew Aug 16 '13 at 19:40
  • seems like pandas can't give you Japan exchange data. – jason Apr 01 '14 at 12:54