This file contains 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
Year | Cash flows | Currency | Interest rate | Discount factor | Present value | ||
---|---|---|---|---|---|---|---|
0 | 12000 | USD | 0.025 | 1.000 | 12000 | ||
1 | -2000 | USD | 0.025 | 0.976 | -1952 | ||
2 | -2000 | USD | 0.025 | 0.952 | -1904 | ||
3 | -2000 | USD | 0.025 | 0.929 | -1858 | ||
4 | -2000 | USD | 0.025 | 0.906 | -1812 | ||
5 | -2000 | USD | 0.025 | 0.884 | -1768 |
This file contains 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
Product | Year | Cash Flows | Interest rate | Currency | Discount factor | Present value | |
---|---|---|---|---|---|---|---|
Flood insurance | 0 | 24000 | 0.03 | USD | 1.0 | 24000 | |
Flood insurance | 1 | -2000 | 0.03 | USD | 0.975 | -1950 | |
Flood insurance | 2 | -2000 | 0.03 | USD | 0.948 | -1896 | |
Flood insurance | 3 | -2000 | 0.03 | USD | 0.92 | -1840 | |
Flood insurance | 4 | -2000 | 0.03 | USD | 0.892 | -1784 | |
Flood insurance | 5 | -2000 | 0.03 | USD | 0.863 | -1726 | |
Flood insurance | 6 | -2000 | 0.03 | USD | 0.833 | -1666 | |
Flood insurance | 7 | -2000 | 0.03 | USD | 0.802 | -1604 | |
Flood insurance | 8 | -2000 | 0.03 | USD | 0.771 | -1542 |
This file contains 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
Year | Interest rate | Currency | |
---|---|---|---|
0 | 0.025 | USD | |
1 | 0.026 | USD | |
2 | 0.027 | USD | |
3 | 0.028 | USD | |
4 | 0.029 | USD | |
5 | 0.03 | USD | |
6 | 0.031 | USD | |
7 | 0.032 | USD | |
8 | 0.033 | USD |
This file contains 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
Product | Present value | |
---|---|---|
Fire insurance | 993.1071221599855 | |
Flood insurance | 7094.239857819502 |
This file contains 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
Product | Year | Cash flows | Currency | Interest rate | Discount factor | Present value | |
---|---|---|---|---|---|---|---|
Flood insurance | 0 | 24000 | USD | 0.025 | 1.0 | 24000.0 | |
Flood insurance | 1 | -2000 | USD | 0.026 | 0.975 | -1949.318 | |
Flood insurance | 2 | -2000 | USD | 0.027 | 0.948 | -1896.222 | |
Flood insurance | 3 | -2000 | USD | 0.028 | 0.92 | -1840.987 | |
Flood insurance | 4 | -2000 | USD | 0.029 | 0.892 | -1783.892 | |
Flood insurance | 5 | -2000 | USD | 0.03 | 0.863 | -1725.218 | |
Flood insurance | 6 | -2000 | USD | 0.031 | 0.833 | -1665.244 | |
Flood insurance | 7 | -2000 | USD | 0.032 | 0.802 | -1604.25 | |
Flood insurance | 8 | -2000 | USD | 0.033 | 0.771 | -1542.508 |
This file contains 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
# Implementation with Koalas | |
import databricks.koalas as ks | |
# Read in the cash flows data and rate data as csv | |
cashflow_df = ks.read_csv(path_cashflow) | |
rate_df = ks.read_csv(path_rate) | |
# Calculate discount factor from the rates | |
rate_df["Discount factor"] = 1 / (1 + rate_df["Interest rate"])**rate_df["Year"] |
This file contains 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
# Groupby product and check the profitability | |
cf_with_rate_df = cf_with_rate_df.groupby("Product")[["Present value"]].sum().reset_index() |