-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy path14-stockParse.py
More file actions
86 lines (71 loc) · 2.48 KB
/
14-stockParse.py
File metadata and controls
86 lines (71 loc) · 2.48 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# quandl stock data
import quandl
import numpy
import matplotlib.pyplot as plt
import private as pr
# you will need to add your key to the private file
quandl.ApiConfig.api_key = pr.quandl_key
quandl.ApiConfig.api_version = '2015-04-09'
# get: database code / dataset code
#data = quandl.get('LBMA/GOLD', start_date='2018-08-01', end_data='2018-09-01', returns='numpy')
data = quandl.get('LBMA/GOLD', start_date='2018-01-01', end_data='2018-09-01')
#print(data)
gdate = []
gvalue = []
gx = []
for d in range(len(data)):
date, value = data.index[d],data["EURO (PM)"][d]
#print(date,value)
gdate.append(date)
gvalue.append(value)
gx.append(value + 12.5)
#print(gdate,gvalue)
gold = {}
gold["date"] = gdate
gold["value"] = gvalue
plt.ylabel("Gold [€]")
#using original array works
#plt.plot(data.index,data["EURO (PM)"])
#this works too, if iterated over items
plt.plot(gold["date"],gold["value"],label="value")
plt.xlabel("year")
plt.legend()
plt.show()
rural = quandl.get("WWDI/USA_SP_RUR_TOTL")
urban = quandl.get("WWDI/USA_SP_URB_TOTL")
plt.subplot(2, 1, 1)
plt.plot(rural.index,rural)
plt.xticks(rural.index[0::3],[])
plt.title("American Population")
plt.ylabel("Rural [%]")
plt.subplot(2, 1, 2)
plt.plot(urban.index,urban)
plt.xlabel("year")
plt.ylabel("Urban [%]")
plt.show()
## European Commission Annual Macro-Economic Database
##
##Annual macro-economic database of the European Commission's Directorate General for Economic and Financial Affairs (DG ECFIN).
##
## Free
##
##AMECO / FRA_1_0_0_0_ZUTN Unemployment rate: total; Member States: definition EUROSTAT - (Percentage of active population) - France
##AMECO / DEU_1_0_0_0_ZUTN Unemployment rate: total; Member States: definition EUROSTAT - (Percentage of active population) - Germany
##AMECO / GRC_1_0_0_0_ZUTN Unemployment rate: total; Member States: definition EUROSTAT - (Percentage of active population) - Greece
fr = quandl.get("AMECO/FRA_1_0_0_0_ZUTN",start_date="2000-01-01")
de = quandl.get("AMECO/DEU_1_0_0_0_ZUTN",start_date="2000-01-01")
gr = quandl.get("AMECO/GRC_1_0_0_0_ZUTN",start_date="2000-01-01")
plt.subplot(3, 1, 1)
plt.plot(fr.index,fr)
plt.xticks(fr.index[0::3],[])
plt.title("Unemployment rate")
plt.ylabel("FR [%]")
plt.subplot(3, 1, 2)
plt.plot(de.index,de)
plt.xlabel("year")
plt.ylabel("DE [%]")
plt.subplot(3, 1, 3)
plt.plot(de.index,gr)
plt.xlabel("year")
plt.ylabel("GR [%]")
plt.show()