Skip to content

Commit cb35483

Browse files
authored
Merge pull request #105 from jsabuco/master
Parametric premium sensitivity implemented.
2 parents 3ca3377 + dfba6bb commit cb35483

File tree

4 files changed

+76
-29
lines changed

4 files changed

+76
-29
lines changed

ensemble.py

+15-8
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,15 @@ def rake(hostname):
9090
wfile_11 = open(os.getcwd() + "/data/" + str(nums[str(counter)]) + "_premium.dat", "w")
9191
wfile_12 = open(os.getcwd() + "/data/" + str(nums[str(counter)]) + "_reinpremium.dat", "w")
9292
wfile_13 = open(os.getcwd() + "/data/" + str(nums[str(counter)]) + "_cumulative_bankruptcies.dat", "w")
93-
wfile_14 = open(os.getcwd() + "/data/" + str(nums[str(counter)]) + "_cumulative_unrecovered_claims.dat", "w")
94-
wfile_15 = open(os.getcwd() + "/data/" + str(nums[str(counter)]) + "_cumulative_claims.dat", "w")
95-
wfile_16 = open(os.getcwd() + "/data/record_" + str(nums[str(counter)]) + "_insurance_firms_cash.dat", "w")
96-
wfile_17 = open(os.getcwd() + "/data/record_" + str(nums[str(counter)]) + "_reinsurance_firms_cash.dat", "w")
97-
wfile_18 = open(os.getcwd() + "/data/" + str(nums[str(counter)]) + "_market_diffvar.dat", "w")
98-
wfile_19 = open(os.getcwd() + "/data/" + str(counter) + "_rc_schedule.dat", "w")
99-
wfile_20 = open(os.getcwd() + "/data/" + str(counter) + "_rc_damage.dat", "w")
100-
93+
wfile_14 = open(os.getcwd() + "/data/" + str(nums[str(counter)]) + "_cumulative_market_exits", "w")
94+
wfile_15 = open(os.getcwd() + "/data/" + str(nums[str(counter)]) + "_cumulative_unrecovered_claims.dat", "w")
95+
wfile_16 = open(os.getcwd() + "/data/" + str(nums[str(counter)]) + "_cumulative_claims.dat", "w")
96+
wfile_17 = open(os.getcwd() + "/data/record_" + str(nums[str(counter)]) + "_insurance_firms_cash.dat", "w")
97+
wfile_18 = open(os.getcwd() + "/data/record_" + str(nums[str(counter)]) + "_reinsurance_firms_cash.dat", "w")
98+
wfile_19 = open(os.getcwd() + "/data/" + str(nums[str(counter)]) + "_market_diffvar.dat", "w")
99+
wfile_20 = open(os.getcwd() + "/data/" + str(counter) + "_rc_schedule.dat", "w")
100+
wfile_21 = open(os.getcwd() + "/data/" + str(counter) + "_rc_damage.dat", "w")
101+
wfile_22 = open(os.getcwd() + "/data/" + str(counter) + "_no_riskmodels.dat", "w")
101102

102103

103104
"""Here the results of the simulations (typically run in the cloud) are collected"""
@@ -136,6 +137,10 @@ def rake(hostname):
136137
wfile_18.write(str(result[i][18]) + "\n")
137138
wfile_19.write(str(result[i][19]) + "\n")
138139
wfile_20.write(str(result[i][20]) + "\n")
140+
wfile_21.write(str(result[i][21]) + "\n")
141+
wfile_22.write(str(result[i][22]) + "\n")
142+
143+
139144

140145

141146

@@ -162,6 +167,8 @@ def rake(hostname):
162167
wfile_18.close()
163168
wfile_19.close()
164169
wfile_20.close()
170+
wfile_21.close()
171+
wfile_22.close()
165172

166173

167174
counter =counter + 1

insurancesimulation.py

+38-5
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ def iterate(self, t):
276276
# adjust market premiums
277277
sum_capital = sum([agent.get_cash() for agent in self.insurancefirms]) #TODO: include reinsurancefirms
278278
self.adjust_market_premium(capital=sum_capital)
279+
sum_capital = sum([agent.get_cash() for agent in self.reinsurancefirms]) # TODO: include reinsurancefirms
279280
self.adjust_reinsurance_market_premium(capital=sum_capital)
280281

281282
# pay obligations
@@ -397,6 +398,7 @@ def save_data(self):
397398
current_log['market_premium'] = self.market_premium
398399
current_log['market_reinpremium'] = self.reinsurance_market_premium
399400
current_log['cumulative_bankruptcies'] = self.cumulative_bankruptcies
401+
current_log['cumulative_market_exits'] = self.cumulative_market_exits
400402
current_log['cumulative_unrecovered_claims'] = self.cumulative_unrecovered_claims
401403
current_log['cumulative_claims'] = self.cumulative_claims #Log the cumulative claims received so far.
402404

@@ -526,16 +528,47 @@ def shuffle_risks(self):
526528
np.random.shuffle(self.risks)
527529

528530
def adjust_market_premium(self, capital):
529-
self.market_premium = self.norm_premium * (self.simulation_parameters["upper_price_limit"] - capital / (self.simulation_parameters["initial_agent_cash"] * self.damage_distribution.mean() * self.simulation_parameters["no_risks"]))
531+
"""Adjust_market_premium Method.
532+
Accepts arguments
533+
capital: Type float. The total capital (cash) available in the insurance market (insurance only).
534+
No return value.
535+
This method adjusts the premium charged by insurance firms for the risks covered. The premium reduces linearly
536+
with the capital available in the insurance market and viceversa. The premium reduces until it reaches a minimum
537+
below which no insurer is willing to reduce further the price. This method is only called in the self.iterate()
538+
method of this class."""
539+
self.market_premium = self.norm_premium * (self.simulation_parameters["upper_price_limit"] - self.simulation_parameters["premium_sensitivity"] * capital / (self.simulation_parameters["initial_agent_cash"] * self.damage_distribution.mean() * self.simulation_parameters["no_risks"]))
530540
if self.market_premium < self.norm_premium * self.simulation_parameters["lower_price_limit"]:
531541
self.market_premium = self.norm_premium * self.simulation_parameters["lower_price_limit"]
532542

533543
def adjust_reinsurance_market_premium(self, capital):
534-
self.reinsurance_market_premium = self.market_premium
544+
"""Adjust_market_premium Method.
545+
Accepts arguments
546+
capital: Type float. The total capital (cash) available in the reinsurance market (reinsurance only).
547+
No return value.
548+
This method adjusts the premium charged by reinsurance firms for the risks covered. The premium reduces linearly
549+
with the capital available in the reinsurance market and viceversa. The premium reduces until it reaches a minimum
550+
below which no reinsurer is willing to reduce further the price. This method is only called in the self.iterate()
551+
method of this class."""
552+
self.reinsurance_market_premium = self.norm_premium * (self.simulation_parameters["upper_price_limit"] - self.simulation_parameters["reinpremium_sensitivity"] * capital / (self.simulation_parameters["initial_agent_cash"] * self.damage_distribution.mean() * self.simulation_parameters["no_risks"]))
553+
if self.reinsurance_market_premium < self.norm_premium * self.simulation_parameters["lower_price_limit"]:
554+
self.reinsurance_market_premium = self.norm_premium * self.simulation_parameters["lower_price_limit"]
535555

536556
def get_market_premium(self):
557+
"""Get_market_premium Method.
558+
Accepts no arguments.
559+
Returns:
560+
self.market_premium: Type float. The current insurance market premium.
561+
This method returns the current insurance market premium."""
537562
return self.market_premium
538563

564+
def get_market_reinpremium(self):
565+
"""Get_market_reinpremium Method.
566+
Accepts no arguments.
567+
Returns:
568+
self.reinsurance_market_premium: Type float. The current reinsurance market premium.
569+
This method returns the current reinsurance market premium."""
570+
return self.reinsurance_market_premium
571+
539572
def get_reinsurance_premium(self, np_reinsurance_deductible_fraction):
540573
# TODO: cut this out of the insurance market premium -> OBSOLETE??
541574
# TODO: make premiums dependend on the deductible per value (np_reinsurance_deductible_fraction) -> DONE.
@@ -682,15 +715,15 @@ def insurance_firm_market_entry(self, prob=-1, agent_type="InsuranceFirm"):
682715

683716
def record_bankruptcy(self):
684717
"""Record_bankruptcy Method.
685-
Accepts no arguments:
718+
Accepts no arguments.
686719
No return value.
687720
This method is called when a firm files for bankruptcy. It is only called from the method dissolve() from the
688721
class metainsuranceorg.py after the dissolution of the firm."""
689722
self.cumulative_bankruptcies += 1
690723

691724
def record_market_exit(self):
692725
"""Record_market_exit Method.
693-
Accepts no arguments:
726+
Accepts no arguments.
694727
No return value.
695728
This method is used to record the firms that leave the market due to underperforming conditions. It is only called
696729
from the method dissolve() from the class metainsuranceorg.py after the dissolution of the firm."""
@@ -787,7 +820,7 @@ def reinsurance_capital_entry(self): #This method determines the capital mar
787820

788821
def reset_pls(self):
789822
"""Reset_pls Method.
790-
Accepts no arguments:
823+
Accepts no arguments.
791824
No return value.
792825
This method reset all the profits and losses of all insurance firms, reinsurance firms and catbonds."""
793826
for insurancefirm in self.insurancefirms:

isleconfig.py

+3
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@
4141
"capacity_target_increment_threshold": 1.2,
4242
"capacity_target_decrement_factor": 24/25.,
4343
"capacity_target_increment_factor": 25/24.,
44+
#Premium sensitivity parameters
45+
"premium_sensitivity": 8, #This parameter represents how sensitive is the variation of the insurance premium with respect of the capital of the market. Higher means more sensitive.
46+
"reinpremium_sensitivity": 8, #This parameter represents how sensitive is the variation of the reinsurance premium with respect of the capital of the market. Higher means more sensitive.
4447
#Balanced portfolio parameters
4548
"insurers_balance_ratio": 0.1, # This ratio represents how low we want to keep the standard deviation of the cash reserved below the mean for insurers. Lower means more balanced.
4649
"reinsurers_balance_ratio": 20, # This ratio represents how low we want to keep the standard deviation of the cash reserved below the mean for reinsurers. Lower means more balanced. (Deactivated for the moment)

logger.py

+20-16
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ def __init__(self, no_riskmodels=None, rc_event_schedule_initial=None, rc_event_
3131
self.history_logs['total_contracts'] = []
3232
self.history_logs['total_operational'] = []
3333
self.history_logs['cumulative_bankruptcies'] = [] # TODO: should we not have that for both insurance firms and reinsurance firms?
34+
self.history_logs['cumulative_market_exits'] = [] # TODO: should we not have that for both insurance firms and reinsurance firms?
3435
self.history_logs['cumulative_claims'] = [] #Here are stored the total cumulative claims received by the whole insurance sector until a certain time.
3536
self.history_logs['cumulative_unrecovered_claims'] = []
3637

@@ -89,14 +90,15 @@ def obtain_log(self): #This function allows to return in a list all the data g
8990
[11]: 'market_premium'
9091
[12]: 'market_reinpremium'
9192
[13]: 'cumulative_bankruptcies'
92-
[14]: 'cumulative_unrecovered_claims'
93-
[15]: 'cumulative_claims'
94-
[16]: 'insurance_firms_cash'
95-
[17]: 'reinsurance_firms_cash'
96-
[18]: 'market_diffvar'
97-
[19]: rc_event_schedule_initial
98-
[20]: rc_event_damage_initial
99-
[21]: number_riskmodels
93+
[14]: 'cumulative_market_exits'
94+
[15]: 'cumulative_unrecovered_claims'
95+
[16]: 'cumulative_claims'
96+
[17]: 'insurance_firms_cash'
97+
[18]: 'reinsurance_firms_cash'
98+
[19]: 'market_diffvar'
99+
[20]: rc_event_schedule_initial
100+
[21]: rc_event_damage_initial
101+
[22]: number_riskmodels
100102
"""
101103

102104
log = []
@@ -115,6 +117,7 @@ def obtain_log(self): #This function allows to return in a list all the data g
115117
log.append(self.history_logs['market_premium'])
116118
log.append(self.history_logs['market_reinpremium'])
117119
log.append(self.history_logs['cumulative_bankruptcies'])
120+
log.append(self.history_logs['cumulative_market_exits'])
118121
log.append(self.history_logs['cumulative_unrecovered_claims'])
119122
log.append(self.history_logs['cumulative_claims'])
120123
log.append(self.history_logs['insurance_firms_cash'])
@@ -169,14 +172,15 @@ def restore_logger_object(self, log):
169172
self.history_logs['market_premium'] = log [11]
170173
self.history_logs['market_reinpremium'] = log [12]
171174
self.history_logs['cumulative_bankruptcies'] = log [13]
172-
self.history_logs['cumulative_unrecovered_claims'] = log [14]
173-
self.history_logs['cumulative_claims'] = log [15]
174-
self.history_logs['insurance_firms_cash'] = log [16]
175-
self.history_logs['reinsurance_firms_cash'] = log [17]
176-
self.history_logs['market_diffvar'] = log [18]
177-
self.rc_event_schedule_initial = log[19]
178-
self.rc_event_damage_initial = log[20]
179-
self.number_riskmodels = log[21]
175+
self.history_logs['cumulative_market_exits'] = log[14]
176+
self.history_logs['cumulative_unrecovered_claims'] = log [15]
177+
self.history_logs['cumulative_claims'] = log [16]
178+
self.history_logs['insurance_firms_cash'] = log [17]
179+
self.history_logs['reinsurance_firms_cash'] = log [18]
180+
self.history_logs['market_diffvar'] = log [19]
181+
self.rc_event_schedule_initial = log[20]
182+
self.rc_event_damage_initial = log[21]
183+
self.number_riskmodels = log[22]
180184

181185

182186
def save_log(self, background_run):

0 commit comments

Comments
 (0)