datpark

pandas, Plotly & Cufflinks

plotly is a plotting engine for fast easy generation of interactive D3.js plots. Cf. http://plot.ly.

In [1]:
import numpy as np
import pandas as pd
import pandas.io.data as web
import plotly.plotly as py
import cufflinks as cf
In [2]:
py.sign_in('Python-Demo-Account', 'gwt101uhh0')

Reading Financial Data

In [3]:
symbols = ['AAPL', 'MSFT', 'YHOO']
In [4]:
data = pd.DataFrame()
for sym in symbols:
    data[sym] = web.DataReader(sym, data_source='yahoo')['Adj Close']
In [5]:
data.tail()
Out[5]:
AAPL MSFT YHOO
Date
2015-03-27 123.25 40.97 45.10
2015-03-30 126.37 40.96 44.95
2015-03-31 124.43 40.66 44.44
2015-04-01 124.25 40.72 44.13
2015-04-02 125.32 40.29 44.15

Plotting the Data

In [6]:
data.iplot(filename='financial', world_readable=True)
Out[6]:
In [7]:
data['AAPL'].iplot(filename='best_fit', bestfit=True, colors=['pink'],
                bestfit_colors=['blue'], world_readable=True)
Out[7]: