In [39]:
%matplotlib
from datetime import datetime, timedelta
from pandas.io.data import DataReader
from pandas.io.parsers import read_csv
FIN_SERVICE_PROVIDER = 'yahoo'
PAST_DAYS = 60
# SYMBOL = ['IBM', 'AAPL']
SYMBOL = ['USD', 'EUR']
# today
t1 = datetime.now()
# two months later
t2 = t1 - timedelta(days=PAST_DAYS)
df1 = DataReader(SYMBOL[0], FIN_SERVICE_PROVIDER , t2, t1)
df2 = DataReader(SYMBOL[1], FIN_SERVICE_PROVIDER , t2, t1)
In [40]:
df1.tail()
Out[40]:
In [41]:
df2.tail()
Out[41]:
In [35]:
plt.figure(1)
plt.subplot(211)
plt.title(SYMBOL[0])
plt.xlabel('days')
plt.ylabel('close val.')
plot(df1['Close'])
plt.figure(2)
plt.subplot(211)
plt.title(SYMBOL[1])
plt.xlabel('days')
plt.ylabel('close val.')
plot(df2['Close'])
Out[35]:
In [46]:
# BIT_COIN_CSV_URL = 'http://www.quandl.com/api/v1/datasets/BCHARTS/BITSTAMPUSD.csv'
BIT_COIN_CSV_URL = 'http://www.quandl.com/api/v1/datasets/BCHARTS/KRAKENEUR.csv'
bcdf = read_csv(BIT_COIN_CSV_URL)
bcdf = bcdf[bcdf['Date']> t2.strftime("%Y-%m-%d")]
bcdf.head()
Out[46]:
In [49]:
plt.title("BitCoin")
plt.xlabel('days')
plt.ylabel('close val.(EUR)')
plot(bcdf['Close'])
Out[49]:
In [50]:
bcdf['Close'].mean()
Out[50]:
In [51]:
bcdf['Close'].var()
Out[51]:
In [ ]: