forked from robcarver17/python-uk-trading-tax-calculator
-
Notifications
You must be signed in to change notification settings - Fork 6
/
quandlfxrates.py
50 lines (28 loc) · 998 Bytes
/
quandlfxrates.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
"""
Python UK trading tax calculator
Copyright (C) 2015 Robert Carver
You may copy, modify and redistribute this file as allowed in the license agreement
but you must retain this header
See README.txt
"""
import pandas as pd
import Quandl
authtoken='qWXuZcdwzwQ2GJQ88sNb'
"""
Get currency data from www.quandl.com
You can also use an authentication code if you have one
"""
def get_quandl_currency(currency):
"""
Given a currency code eg USDAUD returns a pandas data frame with the quandl price series
Daily prices only
If there is no quandl price error
Watch out for the 100x per day limit
"""
if currency=="GBP":
## Return a pd of 1's from ... to present day
return pd.TimeSeries([1.0], index=[pd.datetime(2008,1,1)])
quandldef='CURRFX/%sGBP' % currency
data = Quandl.get(quandldef, authtoken=authtoken)
data=data['Rate']
return data