Source code for solvency2.model.BaseProj
"""Base Space for the :mod:`~simplelife.model.Projection` Space.
This Space serves as a base Space for :mod:`~simplelife.model.Projection`
Space, and it contains Cells for cashflow projection.
.. rubric:: Projects
This module is included in the following projects.
* :mod:`simplelife`
* :mod:`nestedlife`
.. rubric:: References
This Cells is this Space reference the following attributes.
The attributes are not defined in this Space, but defined in its
sub Space, :mod:`~simplelife.model.Projection`
Attributes:
pol: Alias to :mod:`~simplelife.model.Projection.Policy` space
asmp: Alias to :mod:`~simplelife.model.Projection.Assumptions` space
.. blockdiag::
blockdiag {
default_node_color="#D5E8D4";
default_linecolor="#628E47";
BaseProj[style=dotted]
BaseProj <- OuterProj [hstyle=generalization]
PresentValue[style=dotted]
PresentValue <- OuterProj [hstyle=generalization];
}
"""
from modelx.serialize.jsonvalues import *
_formula = None
_bases = []
_allow_none = None
_spaces = []
# ---------------------------------------------------------------------------
# Cells
[docs]def AccumCF(t):
"""Accumulated cashflows"""
if t == 0:
return 0
else:
return (AccumCF(t-1)
+ IntAccumCF(t-1)
+ NetInsurCF(t-1))
[docs]def AttAge(t):
"""Attained age at time ``t``"""
return pol.IssueAge() + t
[docs]def BenefitAccDth(t):
"""Accidental death benefits"""
return SizeBenefitAccDth(t) * PolsAccDeath(t)
[docs]def BenefitAccHosp(t):
"""Accidental hospitalization benefits"""
return SizeBenefitAccHosp(t) * PolsAccHosp(t)
[docs]def BenefitAnn(t):
"""Annuity benefits"""
return SizeBenefitAnn(t) * PolsAnnuity(t)
[docs]def BenefitDeath(t):
"""Death benefits"""
return SizeBenefitDeath(t) * PolsDeath(t)
[docs]def BenefitLiving(t):
"""Living benefits"""
return SizeBenefitLiving(t) * PolsLiving(t)
[docs]def BenefitMat(t):
"""Matuirty benefits"""
return SizeBenefitMat(t) * PolsMaturity(t)
[docs]def BenefitOther(t):
"""Other benefits"""
return SizeBenefitOther(t) * PolsOther(t)
[docs]def BenefitSickHosp(t):
"""Sickness hospitalization benefits"""
return SizeBenefitSickHosp(t) * PolsSickHosp(t)
[docs]def BenefitSurg(t):
"""Surgery benefits"""
return SizeBenefitSurg(t) * PolsSurg(t)
[docs]def BenefitSurr(t):
"""Surrender benefits"""
return SizeBenefitSurr(t) * PolsSurr(t)
[docs]def BenefitTotal(t):
"""Benefit Total"""
return (BenefitMat(t)
+ BenefitDeath(t)
+ BenefitAccDth(t)
+ BenefitSurr(t)
+ BenefitAnn(t)
+ BenefitAccHosp(t)
+ BenefitSickHosp(t)
+ BenefitSurg(t)
+ BenefitLiving(t)
+ BenefitOther(t))
[docs]def ChangeRsrv(t):
"""Change in reserve"""
return ReserveTotal_End(t+1) - ReserveTotal_End(t)
[docs]def ExpsAcq(t):
"""Acquisition expenses"""
return SizeExpsAcq(t) * (PolsNewBiz(t) + PolsRenewal(t))
[docs]def ExpsAcqTotal(t):
"""Commissions and acquisition expenses"""
return ExpsCommTotal(t) + ExpsAcq(t)
[docs]def ExpsCommInit(t):
"""Initial commissions"""
return SizeExpsCommInit(t) * PolsIF_Beg1(t)
[docs]def ExpsCommRen(t):
"""Renewal commissions"""
return SizeExpsCommRen(t) * PolsIF_Beg1(t)
[docs]def ExpsCommTotal(t):
"""Commissions Total"""
return ExpsCommInit(t) + ExpsCommRen(t)
[docs]def ExpsMaint(t):
"""Maintenance expenses"""
return SizeExpsMaint(t) * PolsIF_Beg1(t)
[docs]def ExpsMaintTotal(t):
"""Total maintenance expenses including other expenses"""
return ExpsMaint(t) + ExpsOther(t)
[docs]def ExpsOther(t):
"""Other expenses"""
return 0
[docs]def ExpsTotal(t):
"""Total expenses"""
return (ExpsCommInit(t)
+ ExpsCommRen(t)
+ ExpsAcq(t)
+ ExpsMaint(t)
+ ExpsOther(t))
[docs]def IncomeTotal(t):
"""Income Total"""
return PremIncome(t) + InvstIncome(t)
[docs]def InsurIF_Beg1(t):
"""Insurance in-force: Beginning of period 1"""
return PolsIF_Beg1(t) * SizeSumAssured(t)
[docs]def InsurIF_End(t):
"""Insurance in-force: End of period"""
return PolsIF_End(t) * SizeSumAssured(t)
[docs]def IntAccumCF(t):
"""Intrest on accumulated cashflows"""
return (AccumCF(t)
+ PremIncome(t)
- ExpsTotal(t)) * DiscRate(t)
[docs]def InvstIncome(t):
"""Investment income"""
return SizeInvstIncome(t) * PolsIF_Beg1(t)
[docs]def NetInsurCF(t):
"""Net liability cashflow"""
return (PremIncome(t)
- BenefitTotal(t)
- ExpsTotal(t))
[docs]def PolsAccDeath(t):
"""Number of policies: Accidental death"""
return 0
[docs]def PolsAccHosp(t):
"""Number of policies: Accidental Hospitalization"""
return 0
[docs]def PolsAnnuity(t):
"""Number of policies: Annuity"""
return 0
[docs]def PolsDeath(t):
"""Number of policies: Death"""
return PolsIF_Beg1(t) * asmp.BaseMortRate(AttAge(t)) * asmp.MortFactor(t)
[docs]def PolsIF_AftMat(t):
"""Number of policies: Maturity"""
return PolsIF_End(t) - PolsMaturity(t)
[docs]def PolsIF_Beg(t):
"""Number of policies: Beginning of period"""
return PolsIF_AftMat(t)
[docs]def PolsIF_Beg1(t):
"""Number of policies: Beginning of period 1"""
return PolsIF_Beg(t) + PolsRenewal(t) + PolsNewBiz(t)
[docs]def PolsIF_End(t):
"""Number of policies: End of period"""
if t == 0:
return 0 # pol.PolicyCount
else:
return PolsIF_Beg1(t-1) - PolsDeath(t-1) - PolsSurr(t-1)
[docs]def PolsLiving(t):
"""Number of policies: Living benefits"""
return 0
[docs]def PolsMaturity(t):
"""Number of policies: Maturity"""
if t == pol.PolicyTerm():
return PolsIF_End(t)
else:
return 0
[docs]def PolsNewBiz(t):
"""Number of policies: New business"""
return pol.PolicyCount() if t == 0 else 0
[docs]def PolsOther(t):
"""Number of policies: Other benefits"""
return 0
[docs]def PolsRenewal(t):
"""Number of policies: Renewal policies"""
return 0
[docs]def PolsSickHosp(t):
"""Number of policies: Sickness Hospitalization"""
return 0
[docs]def PolsSurg(t):
"""Number of policies: Surgery"""
return 0
[docs]def PolsSurr(t):
"""Number of policies: Surrender"""
return PolsIF_Beg1(t) * asmp.SurrRate(t)
[docs]def PremIncome(t):
"""Premium income"""
return SizePremium(t) * PolsIF_Beg1(t)
[docs]def ProfitBefTax(t):
"""Profit before Tax"""
return (PremIncome(t)
+ InvstIncome(t)
- BenefitTotal(t)
- ExpsTotal(t)
- ChangeRsrv(t))
[docs]def ReserveHospRsrvEnd(t):
"""Hospitalization reserve: End of period"""
return 0
[docs]def ReservePremRsrvEnd(t):
"""Premium reserve: End of period"""
return SizeReservePremRsrvEnd(t) * PolsIF_End(t)
[docs]def ReserveTotal_End(t):
"""Total reserve: End of period"""
return (ReservePremRsrvEnd(t)
+ ReserveUernPremEnd(t)
+ ReserveHospRsrvEnd(t))
[docs]def ReserveUernPremEnd(t):
"""Unearned Premium: End of period"""
return 0
[docs]def SizeAnnPrem(t):
"""Annualized premium per policy at time ``t``"""
return SizeSumAssured(t) * pol.AnnPremRate()
[docs]def SizeBenefitAccDth(t):
"""Accidental death benefit per policy"""
return 0
[docs]def SizeBenefitAccHosp(t):
"""Accidental hospitalization benefit per policy"""
return 0
[docs]def SizeBenefitAnn(t):
"""Annuity benefit per policy"""
return 0
[docs]def SizeBenefitDeath(t):
"""Death benefit per policy"""
return SizeSumAssured(t)
[docs]def SizeBenefitLiving(t):
"""Living benefit per policy"""
return 0
[docs]def SizeBenefitMat(t):
"""Maturity benefit per policy"""
return 0
[docs]def SizeBenefitOther(t):
"""Other benefit per policy"""
return 0
[docs]def SizeBenefitSickHosp(t):
"""Sickness hospitalization benefit per policy"""
return 0
[docs]def SizeBenefitSurg(t):
"""Surgery benefit per policy"""
return 0
[docs]def SizeBenefitSurr(t):
"""Surrender benefit per policy"""
return SizeSumAssured(t) * (pol.CashValueRate(t)
+ pol.CashValueRate(t+1)) / 2
[docs]def SizeExpsAcq(t):
"""Acquisition expense per policy at time t"""
if t == 0:
return (SizeAnnPrem(t) * asmp.ExpsAcqAnnPrem()
+ (SizeSumAssured(t) * asmp.ExpsAcqSA() + asmp.ExpsAcqPol())
* InflFactor(t) / InflFactor(0))
else:
return 0
[docs]def SizeExpsCommInit(t):
"""Initial commission per policy at time t"""
if t == 0:
return SizePremium(t) * asmp.CommInitPrem() * (1 + asmp.CnsmpTax())
else:
return 0
[docs]def SizeExpsCommRen(t):
"""Renewal commission per policy at time t"""
if t == 0:
return 0
elif t < asmp.CommRenTerm():
return SizePremium(t) * asmp.CommRenPrem() * (1 + asmp.CnsmpTax())
else:
return 0
[docs]def SizeExpsMaint(t):
"""Maintenance expense per policy at time t"""
return (SizeAnnPrem(t) * asmp.ExpsMaintAnnPrem()
+ (SizeSumAssured(t) * asmp.ExpsMaintSA() + asmp.ExpsMaintPol())
* InflFactor(t))
[docs]def SizeExpsOther(t):
"""Other expenses per policy at time t"""
return 0
[docs]def SizeInvstIncome(t):
"""Investment Income per policy from t to t+1"""
return (SizeReserveTotalAftMat(t) + SizePremium(t)) * InvstRetRate(t)
[docs]def SizePremium(t):
"""Premium income per policy from t to t+1"""
return SizeSumAssured(t) * pol.GrossPremRate() * pol.PremFreq()
[docs]def SizeReservePremRsrvAftMat(t):
"""Premium reserve per policy: After maturity"""
return SizeSumAssured(t) * pol.ReserveNLP_Rate('VAL', t)
[docs]def SizeReservePremRsrvEnd(t):
"""Premium reserve per policy: End of period"""
return SizeSumAssured(t) * pol.ReserveNLP_Rate('VAL', t)
[docs]def SizeReserveTotalAftMat(t):
"""Total reserve per policy: After maturity"""
return (SizeReservePremRsrvAftMat(t)
+ SizeReserveUernPremAftMat(t))
[docs]def SizeReserveUernPremAftMat(t):
"""Unearned premium: After maturity"""
return 0 # SizeSumAssured(t) * polset.UnernPremRate(polset, tt, True)
[docs]def SizeReserveUernPremEnd(t):
"""Unearned reserve per policy: End of period"""
return 0 # SizeSumAssured(t) * pol.UnernPremRate(polset, tt)
[docs]def SizeSumAssured(t):
"""Sum assured per policy at time ``t``"""
return pol.SumAssured()
def last_t():
return min(asmp.LastAge() - pol.IssueAge(), pol.PolicyTerm())
def InflFactor(t):
return scen[ScenID].InflFactor(t)