Yet Another Blog in Statistical Computing

I can calculate the motion of heavenly bodies but not the madness of people. -Isaac Newton

Download and Plot Stock Price with Python

Below is a demo showing how to download data from finance.yahoo.com and plot it with python.

In [1]: from pandas.io.data import get_data_yahoo

In [2]: import matplotlib.pyplot as plt

In [3]: data = get_data_yahoo("FITB", start = '2012-01-01', end = '2012-12-31')[['Close', 'Volume']]

In [4]: data.plot(subplots = True, figsize = (8, 8));

In [5]: plt.legend(loc = 'best')
Out[5]: <matplotlib.legend.Legend at 0xb68ce2c>

In [6]: plt.show()

fitb

Advertisements

Written by statcompute

December 9, 2012 at 1:26 pm

Posted in PYTHON

Tagged with ,

%d bloggers like this: