This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pip install cashflower |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
main = ModelPointSet(data=pd.DataFrame({ | |
"id": [1, 2, 3], | |
"sum_assured": [100_000, 50_000, 200_000], | |
"remaining_term": [36, 24, 60], | |
})) | |
fund = ModelPointSet(data=pd.DataFrame({ | |
"id": [1, 1, 3], | |
"fund_code": ["AX", "BP", "FY"], | |
"value": [10_000, 5_000, 12_000] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sqlite3 | |
conn = sqlite3.connect("model_point") | |
sql_query = pd.read_sql_query("SELECT * FROM policyholder", conn) | |
main = ModelPointSet(data=pd.DataFrame(sql_query)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
main = ModelPointSet(data=pd.read_csv("data.csv")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
main = ModelPointSet(data=pd.DataFrame({ | |
"id": [1, 2, 3], | |
"sum_assured": [100_000, 50_000, 200_000], | |
"remaining_term": [36, 24, 60], | |
})) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
t survival_rate expected_benefit net_single_premium | |
0 1.000000 0.00 9375.89 | |
1 0.997000 300.00 9422.77 | |
2 0.994009 299.10 9168.39 | |
3 0.991027 298.20 8913.63 | |
... | |
34 0.902891 271.68 808.58 | |
35 0.900182 270.87 539.58 | |
36 0.897482 270.05 270.05 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@variable() | |
def net_single_premium(t): | |
if t == settings["T_MAX_CALCULATION"]: | |
return expected_benefit(t) | |
return expected_benefit(t) + net_single_premium(t+1) * 1/(1+assumption["INTEREST_RATE"]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@variable() | |
def expected_benefit(t): | |
if t == 0: | |
return 0 | |
if t > main.get("remaining_term"): | |
return 0 | |
return survival_rate(t-1) * assumption["DEATH_PROB"] * main.get("sum_assured") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from cashflower import variable | |
from input import assumption, main | |
from settings import settings | |
@variable() | |
def survival_rate(t): | |
if t == 0: | |
return 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
from cashflower import ModelPointSet | |
main = ModelPointSet(data=pd.DataFrame({ | |
"id": [1], | |
"sum_assured": [100_000], | |
"remaining_term": [36], | |
})) |
NewerOlder