-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathplotter_pl_timescale.py
107 lines (83 loc) · 2.84 KB
/
plotter_pl_timescale.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
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import matplotlib.pyplot as plt
import numpy as np
def get_data(name):
rfile = open(name, "r")
out = [eval(k) for k in rfile]
rfile.close()
return out
contracts = get_data("data/contracts.dat")
op = get_data("data/operational.dat")
cash = get_data("data/cash.dat")
# pl = get_data("data/profitslosses.dat")
reincontracts = get_data("data/reincontracts.dat")
reinop = get_data("data/reinoperational.dat")
reincash = get_data("data/reincash.dat")
# reinpl = get_data("data/reinprofitslosses.dat")
premium = get_data("data/premium.dat")
catbop = get_data("data/catbonds_number.dat")
c_s = []
o_s = []
h_s = []
p_s = []
pl_s = []
c_re = []
o_re= []
h_re = []
pl_re = []
o_cb = []
p_e = []
for i in range(len(contracts[0])): #for every time period i
cs = np.mean([item[i] for item in contracts])
#pls = np.mean([item[i] for item in pl])
os = np.median([item[i] for item in op])
hs = np.median([item[i] for item in cash])
c_s.append(cs)
o_s.append(os)
h_s.append(hs)
if i>0:
pls = np.mean([item[i]-item[i-1] for item in cash])
plre = np.mean([item[i]-item[i-1] for item in reincash])
pl_s.append(pls)
pl_re.append(plre)
cre = np.mean([item[i] for item in reincontracts])
ore = np.median([item[i] for item in reinop])
hre = np.median([item[i] for item in reincash])
c_re.append(cre)
o_re.append(ore)
h_re.append(hre)
ocb = np.median([item[i] for item in catbop])
o_cb.append(ocb)
p_s = np.median([item[i] for item in premium])
p_e.append(p_s)
maxlen_plots = max(len(pl_s), len(pl_re), len(o_s), len(o_re), len(p_e))
xticks = np.arange(200, maxlen_plots, step=120)
fig0 = plt.figure()
ax3 = fig0.add_subplot(511)
ax3.plot(range(len(pl_s))[200:], pl_s[200:],"b")
ax3.set_ylabel("Profits, Losses")
ax3.set_xticks(xticks)
ax3.set_xticklabels(["${0:d}$".format(int((xtc-200)/12)) for xtc in xticks])
ax7 = fig0.add_subplot(512)
ax7.plot(range(len(pl_re))[200:], pl_re[200:],"r")
ax7.set_ylabel("Profits, Losses (Reins.)")
ax7.set_xticks(xticks)
ax7.set_xticklabels(["${0:d}$".format(int((xtc-200)/12)) for xtc in xticks])
ax1 = fig0.add_subplot(513)
ax1.plot(range(len(o_s))[200:], o_s[200:],"b")
ax1.set_ylabel("Active firms")
ax1.set_xticks(xticks)
ax1.set_xticklabels(["${0:d}$".format(int((xtc-200)/12)) for xtc in xticks])
ax5 = fig0.add_subplot(514)
ax5.plot(range(len(o_re))[200:], o_re[200:],"r")
ax5.set_ylabel("Active reins. firms")
ax5.set_xticks(xticks)
ax5.set_xticklabels(["${0:d}$".format(int((xtc-200)/12)) for xtc in xticks])
ax9 = fig0.add_subplot(515)
ax9.plot(range(len(p_e))[200:], p_e[200:],"k")
ax9.set_ylabel("Premium")
ax9.set_xlabel("Years")
ax9.set_xticks(xticks)
ax9.set_xticklabels(["${0:d}$".format(int((xtc-200)/12)) for xtc in xticks])
plt.savefig("data/single_replication_new.pdf")
plt.show()
raise SystemExit