USD vs EUR


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)


Using matplotlib backend: MacOSX

USD


In [40]:
df1.tail()


Out[40]:
Open High Low Close Volume Adj Close
Date
2015-04-17 91.41 92.20 89.42 89.42 5700 89.42
2015-04-20 89.99 92.74 89.99 92.48 5500 92.48
2015-04-21 92.74 93.32 92.43 92.74 1900 92.74
2015-04-22 93.57 94.68 93.24 94.68 2200 94.68
2015-04-23 90.25 91.84 89.95 91.50 1600 91.50

EUR


In [41]:
df2.tail()


Out[41]:
Open High Low Close Volume Adj Close
Date
2015-04-17 36.81 37.25 36.22 37.00 1071000 36.21
2015-04-20 37.00 37.14 36.55 36.99 279600 36.20
2015-04-21 37.20 37.47 36.55 36.90 379700 36.11
2015-04-22 36.80 37.70 36.62 36.90 374300 36.11
2015-04-23 36.89 37.05 36.61 36.80 302800 36.01

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]:
[<matplotlib.lines.Line2D at 0x10fae6850>]

Bitcoin History vs EUR


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]:
Date Open High Low Close Volume (BTC) Volume (Currency) Weighted Price
0 2015-04-23 217.96000 219.53726 213.69732 216.07424 2565.565405 556321.222937 216.841567
1 2015-04-22 219.18000 220.99990 215.79000 218.00000 2966.605362 647436.879653 218.241660
2 2015-04-21 208.73600 220.00000 208.39000 219.14000 3348.357437 708749.197792 211.670711
3 2015-04-20 206.92460 211.45871 206.30000 208.73084 2875.411730 602077.962728 209.388435
4 2015-04-19 207.83591 211.25000 206.47580 206.85460 792.255962 165759.762088 209.225011

In [49]:
plt.title("BitCoin")
plt.xlabel('days')
plt.ylabel('close val.(EUR)')
plot(bcdf['Close'])


Out[49]:
[<matplotlib.lines.Line2D at 0x10d395650>]

Close Price Statistics

Mean (in 60 Days)


In [50]:
bcdf['Close'].mean()


Out[50]:
234.97629711864406

Variance (in 60 days)


In [51]:
bcdf['Close'].var()


Out[51]:
424.8130569661775

In [ ]: