6. Rating algorithm parts 1 & 2 Flashcards
Where does the pricing algorithm sit in the model?
The pricing algorithm in hx Renew is written in Python and the rating.py file controls how the model will recalculate values when in use.
How do you get parameters in the rating algorithm?
- Add the following line after import hx
from algorithms.json_parameter_files.parameters import get_parameters - Then e.g.
industries = get_parameters(‘industry.json’)
We can then reference this value like so:
hxd.model_base_rate.calculated = industries[hxd.industry] - hxd. stands for hx data and is the way to access any of the variables defined in your data schema.
- In order to get a value for the key we use the syntax dictionary_name[hxd.key]
- When assigning to the model base rate, we have used the syntax .calculated. This is because we set the model base rate to be an override.
- With overrides you can also use .selected. If the value has been overwritten by the user, this will equal the value they have provided, if not it will be equal to the calculated value. This allows the overwritten value to flow through to other calculations that may depend on it
How do you access children of a structure?
hxd.structure_name.child_name
How do you access data from a csv for use in the ratings algorithm?
- Instead of reading and saving the data into a dictionary, we will store it in a pandas DataFrame. The syntax hx.params is used followed by the table name. This will read the table and store it in a pandas DataFrame, which can then be accessed and manipulated. e.g.
sor_table = hx.params.size_of_risk
How do you get the last value from a list?
lookup_value][column_to_return].iloc[-1]
What is the Riebesell function?
The Riebesell function is a commonly used curve for calculating increased limit factors (ILFs) in the absence of reliable claims data. Given a calibrated base limit and constant factor (z), we can use Riebesell ILFs to price higher levels of insurance coverage beyond the base limit. x is the limit to evaluate the ilf at.
def riebesell(riebesell_base_limit, riebesell_z, limit):
ilf = (limit / riebesell_base_limit) ** math.log(1 + riebesell_z, 2) return ilf
How might you use a for loop to calculate sections for each layer?
for layer in hxd.layers:
ilf_attach = riebesell(riebesell_base_limit, riebesell_z, layer.excess)
ilf_exhaust = riebesell(riebesell_base_limit, riebesell_z, layer.limit + layer.excess)
layer.ilf = ilf_exhaust - ilf_attach
Calculated Premium layer.calculated_premium = hxd.technical_premium * layer.ilf #ULR if layer.calculated_premium is not None and layer.charged_premium is not None and layer.calculated_premium >0 and layer.charged_premium >0: layer.ulr = base_model_ulr * layer.calculated_premium / layer.charged_premium
What is the ILF attachment point?
ilf_attach = riebesell(riebesell_base_limit, riebesell_z, layer.excess)
What is the ILF exhaust point?
ilf_exhaust = riebesell(riebesell_base_limit, riebesell_z, layer.limit + layer.excess)
How do you calculate totals for layers?
- To calculate the totals, you are going to use list comprehensions, which is a concise way of looping through an iterable and returning a list.
- List comprehension syntax is:
[expression for item in list if conditional]
For example:
hxd.layer_totals.calculated_premium = sum([layer.calculated_premium for layer in hxd.layers if layer.calculated_premium is not None and layer.selected])
What are the hx_core values that the ratings algorithm needs to calculate?
hxd.hx_core.model_premium = hxd.layer_totals.calculated_premium
hxd.hx_core.charged_premium = hxd.layer_totals.charged_premium
hxd.hx_core.ulr = hxd.layer_totals.ulr
hxd.hx_core.premium_currency = hxd.currency
BLANK