/
bvg.py
111 lines (87 loc) · 3.73 KB
/
bvg.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
108
109
110
111
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
# Objekt model
# Beinhaltet: vier Beitragssätze (vier Altersstufen), Zinssatz, Umwandlungssatz
# Beispiel: model = [0.07, 0.10, 0.15, 0.18, 0.01, 0.07]
legalminimum = [0.07, 0.10, 0.15, 0.18, 0.01, 0.068]
#examplesalary = list(range(40000, 80000, 1000))
def contribution(salary, year, model):
#Berechnet die BVG-Beiträge pro Jahr auf Basis des Jahreseinkommens
koordinationsabzug = 24675
versicherterLohn = max(min(84600, salary - koordinationsabzug), 0)
contribution = versicherterLohn * contributionRate(year, model)
return contribution
def contributionRate(year, model):
#Berechnet die Beitragsrate entsprechend dem Alter
#Problem: Je nach Plan unterschiedlich. Plan wird in Form der Liste model geliefert.
age = year+20
if age < 25:
contributionRate = 0
elif age >= 25 & age < 34:
contributionRate = model[0]
elif age >= 35 & age < 45:
contributionRate = model[1]
elif age >= 45 & age < 55:
contributionRate = model[2]
elif age >= 55:
contributionRate = model[3]
return contributionRate
def contributions(model, salary):
#Erstellt eine Liste mit den Beiträgen pro Jahr
contributions = []
for year in range(0,40):
contributions.append(contribution(salary[year], year, model))
return contributions
def pensionCapital(contributions, model):
#contributions muss eine Liste sein (Beiträge pro Jahr für eine bestimmte Person)
interestRate = model[4]
contributionWithInterest = 0
for annualcontribution in contributions:
contributionWithInterest = contributionWithInterest + annualcontribution * (1+interestRate)**(40-contributions.index(annualcontribution))
return contributionWithInterest
def pension(model, salary):
#Berechnet die jährliche Pension (Kapital x Umwandlungssatz)
umwandlungssatz = model[5]
pension = pensionCapital(contributions(model, salary), model) * umwandlungssatz
return int(pension)
def BVGModel(model):
# Erstellt eine Liste (allSalaries) aus unterschiedlichen Gehältern (salary)
allSalaries = []
alphas = []
betas = []
for alpha in range(0,100000, 1000):
for beta in range(0, 5000, 100):
salary = [alpha + beta * year if (alpha+beta*year) > 0 else 1 for year in range(0,40)]
for i in range(0, 15):
salary.append(pension(model, salary)) # Fügt dem Einkommen noch 15 Jahre Pension hinzu
coverage = pension(model, salary) / salary[39] # Berechnet den Deckungsgrad (Pension in Prozent des letzten Gehalts)
salary.append(round(coverage, 4))
allSalaries.append(salary)
alphas.append(alpha)
betas.append(beta)
summary = []
# Für jede Person: Anfangs- und Endgehalt, Pension (2 Mal), Deckungsgrad
for salary in allSalaries:
individualSummary =[salary[0], salary[39], salary[40], salary[41], salary[55]]
summary.append(individualSummary)
#print(summary)
#Liste mit allen Endgehältern
endSalaries=[salary[39] for salary in allSalaries]
#Liste mit allen Deckungsgraden
coverages=[salary[55] for salary in allSalaries]
# Pandas-DataFrame zur graphischen Darstellung
df = pd.DataFrame({'endsalary': endSalaries, 'coverage':coverages, 'alpha':alphas, 'beta':betas})
print(df[df.coverage > 0.16])
print(df[df.beta == 0])
return df
collectionOfModels = [
legalminimum,
[0.07, 0.10, 0.15, 0.18, 0.02, 0.068],
[0.07, 0.10, 0.15, 0.18, 0.03, 0.068],
[0.07, 0.10, 0.15, 0.18, 0.04, 0.068],
[0.07, 0.10, 0.15, 0.18, 0.05, 0.068],
[0.07, 0.10, 0.15, 0.18, 0.15, 0.18]
]
BVGModel(legalminimum)
plt.show()