Spaces:
Running
Running
Upload 16 files
Browse files- app.py +50 -36
- interface/.DS_Store +0 -0
- interface/retirement_planning_interface.py +6 -21
- modules/.DS_Store +0 -0
- modules/retirement_planning.py +1 -1
app.py
CHANGED
|
@@ -3,9 +3,7 @@ from interface.rebalancing_interface import examples, rebalancing_inputs, output
|
|
| 3 |
from interface.share_price_trend_interface import share_price_trend_inputs, output as share_price_trend_output, update_output as share_price_trend_update_output
|
| 4 |
from interface.dollar_cost_averaging_interface import dollar_cost_averaging_inputs, output as dollar_cost_averaging_output, update_output as dollar_cost_averaging_update_output, markdown1 as dollar_cost_averaging_markdown1, old_price, old_quantity, markdown2 as dollar_cost_averaging_markdown2, new_price, new_quantity
|
| 5 |
from interface.retirement_planning_interface import (
|
| 6 |
-
current_age, retirement_age, life_expectancy, monthly_income_required, inflation_rate,
|
| 7 |
-
current_investment, monthly_investment, monthly_increase_in_investment, # ์ถ๊ฐ๋ ์
๋ ฅ ๋ณ์
|
| 8 |
-
pre_retirement_roi, pre_retirement_dividend_yield, reinvest_dividends, post_retirement_roi, post_retirement_dividend_yield, output as retirement_output, update_output as retirement_update_output
|
| 9 |
)
|
| 10 |
from interface.about_interface import render as render_about_tab
|
| 11 |
|
|
@@ -94,47 +92,63 @@ with gr.Blocks(css='style.css') as demo:
|
|
| 94 |
with gr.TabItem("RETIREMENT PLANNING"):
|
| 95 |
with gr.Row(): # Use Row to place inputs and output side by side
|
| 96 |
with gr.Column(): # Column for inputs
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
)
|
| 125 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 126 |
retirement_output.render()
|
| 127 |
|
| 128 |
# Add change event handlers for retirement planning inputs
|
| 129 |
for input_component in [
|
| 130 |
-
current_age, retirement_age, life_expectancy, monthly_income_required, inflation_rate, current_investment, monthly_investment, monthly_increase_in_investment,
|
| 131 |
-
pre_retirement_roi, pre_retirement_dividend_yield, reinvest_dividends, post_retirement_roi, post_retirement_dividend_yield
|
| 132 |
]:
|
| 133 |
input_component.change(
|
| 134 |
fn=retirement_update_output,
|
| 135 |
inputs=[
|
| 136 |
-
current_age, retirement_age, life_expectancy, monthly_income_required, inflation_rate, current_investment, monthly_investment, monthly_increase_in_investment,
|
| 137 |
-
pre_retirement_roi, pre_retirement_dividend_yield, reinvest_dividends, post_retirement_roi, post_retirement_dividend_yield
|
| 138 |
],
|
| 139 |
outputs=retirement_output
|
| 140 |
)
|
|
|
|
| 3 |
from interface.share_price_trend_interface import share_price_trend_inputs, output as share_price_trend_output, update_output as share_price_trend_update_output
|
| 4 |
from interface.dollar_cost_averaging_interface import dollar_cost_averaging_inputs, output as dollar_cost_averaging_output, update_output as dollar_cost_averaging_update_output, markdown1 as dollar_cost_averaging_markdown1, old_price, old_quantity, markdown2 as dollar_cost_averaging_markdown2, new_price, new_quantity
|
| 5 |
from interface.retirement_planning_interface import (
|
| 6 |
+
current_age, retirement_age, life_expectancy, monthly_income_required, inflation_rate, current_investment, monthly_investment, monthly_increase_in_investment, reinvest_dividends, pre_retirement_roi, pre_retirement_dividend_yield, post_retirement_roi, post_retirement_dividend_yield, output as retirement_output, update_output as retirement_update_output
|
|
|
|
|
|
|
| 7 |
)
|
| 8 |
from interface.about_interface import render as render_about_tab
|
| 9 |
|
|
|
|
| 92 |
with gr.TabItem("RETIREMENT PLANNING"):
|
| 93 |
with gr.Row(): # Use Row to place inputs and output side by side
|
| 94 |
with gr.Column(): # Column for inputs
|
| 95 |
+
|
| 96 |
+
gr.Markdown("### Personal Information")
|
| 97 |
+
with gr.Row():
|
| 98 |
+
|
| 99 |
+
current_age.render()
|
| 100 |
+
retirement_age.render()
|
| 101 |
+
life_expectancy.render()
|
| 102 |
+
monthly_income_required.render()
|
| 103 |
+
inflation_rate.render()
|
| 104 |
+
|
| 105 |
+
gr.Markdown("### Investment Information")
|
| 106 |
+
with gr.Row():
|
| 107 |
+
current_investment.render()
|
| 108 |
+
monthly_investment.render()
|
| 109 |
+
monthly_increase_in_investment.render() # ์ถ๊ฐ๋ ์
๋ ฅ
|
| 110 |
+
reinvest_dividends.render()
|
| 111 |
+
|
| 112 |
+
gr.Markdown("### Investment Returns")
|
| 113 |
+
with gr.Row():
|
| 114 |
+
pre_retirement_roi.render()
|
| 115 |
+
pre_retirement_dividend_yield.render()
|
| 116 |
+
# retirement_markdown.render()
|
| 117 |
+
post_retirement_roi.render()
|
| 118 |
+
post_retirement_dividend_yield.render()
|
| 119 |
+
|
| 120 |
+
|
| 121 |
+
# # Add the ClearButton below the inputs
|
| 122 |
+
# clear_button = gr.ClearButton(value="Clear")
|
| 123 |
+
# clear_button.click(
|
| 124 |
+
# fn=lambda: [None] * len([
|
| 125 |
+
# current_age, retirement_age, life_expectancy, monthly_income_required, inflation_rate, current_investment, monthly_investment, monthly_increase_in_investment, reinvest_dividends, pre_retirement_roi, pre_retirement_dividend_yield, post_retirement_roi, post_retirement_dividend_yield
|
| 126 |
+
# ]),
|
| 127 |
+
# inputs=[],
|
| 128 |
+
# outputs=[
|
| 129 |
+
# current_age, retirement_age, life_expectancy, monthly_income_required, inflation_rate, current_investment, monthly_investment, monthly_increase_in_investment, reinvest_dividends, pre_retirement_roi, pre_retirement_dividend_yield, post_retirement_roi, post_retirement_dividend_yield
|
| 130 |
+
# ]
|
| 131 |
+
# )
|
| 132 |
+
# # Add the Submit Button below the ClearButton
|
| 133 |
+
# submit_button = gr.Button(value="Run", variant="primary")
|
| 134 |
+
# submit_button.click(
|
| 135 |
+
# fn=retirement_update_output,
|
| 136 |
+
# inputs=[
|
| 137 |
+
# current_age, retirement_age, life_expectancy, monthly_income_required, inflation_rate, current_investment, monthly_investment, monthly_increase_in_investment, reinvest_dividends, pre_retirement_roi, pre_retirement_dividend_yield, post_retirement_roi, post_retirement_dividend_yield
|
| 138 |
+
# ],
|
| 139 |
+
# outputs=retirement_output
|
| 140 |
+
# )
|
| 141 |
+
with gr.Column():
|
| 142 |
retirement_output.render()
|
| 143 |
|
| 144 |
# Add change event handlers for retirement planning inputs
|
| 145 |
for input_component in [
|
| 146 |
+
current_age, retirement_age, life_expectancy, monthly_income_required, inflation_rate, current_investment, monthly_investment, monthly_increase_in_investment, reinvest_dividends, pre_retirement_roi, pre_retirement_dividend_yield, post_retirement_roi, post_retirement_dividend_yield
|
|
|
|
| 147 |
]:
|
| 148 |
input_component.change(
|
| 149 |
fn=retirement_update_output,
|
| 150 |
inputs=[
|
| 151 |
+
current_age, retirement_age, life_expectancy, monthly_income_required, inflation_rate, current_investment, monthly_investment, monthly_increase_in_investment, reinvest_dividends, pre_retirement_roi, pre_retirement_dividend_yield, post_retirement_roi, post_retirement_dividend_yield
|
|
|
|
| 152 |
],
|
| 153 |
outputs=retirement_output
|
| 154 |
)
|
interface/.DS_Store
ADDED
|
Binary file (6.15 kB). View file
|
|
|
interface/retirement_planning_interface.py
CHANGED
|
@@ -3,16 +3,10 @@ from modules.utils import load_css
|
|
| 3 |
from modules.retirement_planning import retirement_planning
|
| 4 |
|
| 5 |
def retirement_planning_interface_fn(
|
| 6 |
-
current_age, retirement_age, life_expectancy, monthly_income_required, inflation_rate,
|
| 7 |
-
current_investment, monthly_investment, monthly_increase_in_investment, # ์ถ๊ฐ๋ ์ธ์
|
| 8 |
-
pre_retirement_roi, pre_retirement_dividend_yield, reinvest_dividends,
|
| 9 |
-
post_retirement_roi, post_retirement_dividend_yield
|
| 10 |
):
|
| 11 |
result = retirement_planning(
|
| 12 |
-
current_age, retirement_age, life_expectancy, monthly_income_required, inflation_rate,
|
| 13 |
-
current_investment, monthly_investment, monthly_increase_in_investment, # ์ถ๊ฐ๋ ์ธ์
|
| 14 |
-
pre_retirement_roi, pre_retirement_dividend_yield, reinvest_dividends,
|
| 15 |
-
post_retirement_roi, post_retirement_dividend_yield
|
| 16 |
)
|
| 17 |
css = load_css()
|
| 18 |
return css + result
|
|
@@ -21,17 +15,14 @@ def retirement_planning_interface_fn(
|
|
| 21 |
current_age = gr.Slider(label="Current Age (15-60 Years)", value=15, minimum=15, maximum=60, step=1)
|
| 22 |
retirement_age = gr.Slider(label="Retirement Age (Upto 70 Years)", value=55, minimum=15, maximum=70, step=1)
|
| 23 |
life_expectancy = gr.Slider(label="Life Expectancy (Upto 100 Years)", value=80, minimum=30, maximum=100, step=1)
|
| 24 |
-
monthly_income_required = gr.Number(label="Monthly Income Required In Retirement Years (
|
| 25 |
inflation_rate = gr.Number(label="Expected Inflation Rate (%)", value=3)
|
| 26 |
current_investment = gr.Number(label="Current Investment", value=10000000)
|
| 27 |
monthly_investment = gr.Number(label="Monthly Investment", value=500000)
|
| 28 |
monthly_increase_in_investment = gr.Number(label="Monthly Increase in Investment", value=0) # ์ถ๊ฐ๋ ์
๋ ฅ
|
|
|
|
| 29 |
pre_retirement_roi = gr.Number(label="Expected Return On Investment (Pre-retirement) (%)", value=8)
|
| 30 |
pre_retirement_dividend_yield = gr.Number(label="Expected Dividend Yield (Pre-retirement) (%)", value=3.3)
|
| 31 |
-
reinvest_dividends = gr.Checkbox(label="Reinvest Dividends", value=True)
|
| 32 |
-
|
| 33 |
-
# ์ํด ํ ์
๋ ฅ
|
| 34 |
-
markdown = gr.Markdown("### Post-retirement")
|
| 35 |
post_retirement_roi = gr.Number(label="Expected Return On Investment (Post-retirement) (%)", value=8)
|
| 36 |
post_retirement_dividend_yield = gr.Number(label="Expected Dividend Yield (Post-retirement) (%)", value=3.3)
|
| 37 |
|
|
@@ -39,14 +30,8 @@ output = gr.HTML()
|
|
| 39 |
|
| 40 |
# Define the update function
|
| 41 |
def update_output(
|
| 42 |
-
current_age, retirement_age, life_expectancy, monthly_income_required, inflation_rate,
|
| 43 |
-
current_investment, monthly_investment, monthly_increase_in_investment, # ์ถ๊ฐ๋ ์ธ์
|
| 44 |
-
pre_retirement_roi, pre_retirement_dividend_yield, reinvest_dividends,
|
| 45 |
-
post_retirement_roi, post_retirement_dividend_yield
|
| 46 |
):
|
| 47 |
return retirement_planning_interface_fn(
|
| 48 |
-
current_age, retirement_age, life_expectancy, monthly_income_required, inflation_rate,
|
| 49 |
-
current_investment, monthly_investment, monthly_increase_in_investment, # ์ถ๊ฐ๋ ์ธ์
|
| 50 |
-
pre_retirement_roi, pre_retirement_dividend_yield, reinvest_dividends,
|
| 51 |
-
post_retirement_roi, post_retirement_dividend_yield
|
| 52 |
)
|
|
|
|
| 3 |
from modules.retirement_planning import retirement_planning
|
| 4 |
|
| 5 |
def retirement_planning_interface_fn(
|
| 6 |
+
current_age, retirement_age, life_expectancy, monthly_income_required, inflation_rate, current_investment, monthly_investment, monthly_increase_in_investment, reinvest_dividends, pre_retirement_roi, pre_retirement_dividend_yield, post_retirement_roi, post_retirement_dividend_yield
|
|
|
|
|
|
|
|
|
|
| 7 |
):
|
| 8 |
result = retirement_planning(
|
| 9 |
+
current_age, retirement_age, life_expectancy, monthly_income_required, inflation_rate, current_investment, monthly_investment, monthly_increase_in_investment, reinvest_dividends, pre_retirement_roi, pre_retirement_dividend_yield, post_retirement_roi, post_retirement_dividend_yield
|
|
|
|
|
|
|
|
|
|
| 10 |
)
|
| 11 |
css = load_css()
|
| 12 |
return css + result
|
|
|
|
| 15 |
current_age = gr.Slider(label="Current Age (15-60 Years)", value=15, minimum=15, maximum=60, step=1)
|
| 16 |
retirement_age = gr.Slider(label="Retirement Age (Upto 70 Years)", value=55, minimum=15, maximum=70, step=1)
|
| 17 |
life_expectancy = gr.Slider(label="Life Expectancy (Upto 100 Years)", value=80, minimum=30, maximum=100, step=1)
|
| 18 |
+
monthly_income_required = gr.Number(label="Monthly Income Required In Retirement Years (CPP)", value=2000000)
|
| 19 |
inflation_rate = gr.Number(label="Expected Inflation Rate (%)", value=3)
|
| 20 |
current_investment = gr.Number(label="Current Investment", value=10000000)
|
| 21 |
monthly_investment = gr.Number(label="Monthly Investment", value=500000)
|
| 22 |
monthly_increase_in_investment = gr.Number(label="Monthly Increase in Investment", value=0) # ์ถ๊ฐ๋ ์
๋ ฅ
|
| 23 |
+
reinvest_dividends = gr.Checkbox(label="Reinvest Dividends", value=True)
|
| 24 |
pre_retirement_roi = gr.Number(label="Expected Return On Investment (Pre-retirement) (%)", value=8)
|
| 25 |
pre_retirement_dividend_yield = gr.Number(label="Expected Dividend Yield (Pre-retirement) (%)", value=3.3)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
post_retirement_roi = gr.Number(label="Expected Return On Investment (Post-retirement) (%)", value=8)
|
| 27 |
post_retirement_dividend_yield = gr.Number(label="Expected Dividend Yield (Post-retirement) (%)", value=3.3)
|
| 28 |
|
|
|
|
| 30 |
|
| 31 |
# Define the update function
|
| 32 |
def update_output(
|
| 33 |
+
current_age, retirement_age, life_expectancy, monthly_income_required, inflation_rate, current_investment, monthly_investment, monthly_increase_in_investment, reinvest_dividends, pre_retirement_roi, pre_retirement_dividend_yield, post_retirement_roi, post_retirement_dividend_yield
|
|
|
|
|
|
|
|
|
|
| 34 |
):
|
| 35 |
return retirement_planning_interface_fn(
|
| 36 |
+
current_age, retirement_age, life_expectancy, monthly_income_required, inflation_rate, current_investment, monthly_investment, monthly_increase_in_investment, reinvest_dividends, pre_retirement_roi, pre_retirement_dividend_yield, post_retirement_roi, post_retirement_dividend_yield
|
|
|
|
|
|
|
|
|
|
| 37 |
)
|
modules/.DS_Store
ADDED
|
Binary file (6.15 kB). View file
|
|
|
modules/retirement_planning.py
CHANGED
|
@@ -15,9 +15,9 @@ def retirement_planning(
|
|
| 15 |
current_investment=None,
|
| 16 |
monthly_investment=None,
|
| 17 |
monthly_increase_in_investment=None, # ์ถ๊ฐ๋ ์
๋ ฅ
|
|
|
|
| 18 |
pre_retirement_roi=None,
|
| 19 |
pre_retirement_dividend_yield=None,
|
| 20 |
-
reinvest_dividends=None,
|
| 21 |
post_retirement_roi=None,
|
| 22 |
post_retirement_dividend_yield=None
|
| 23 |
):
|
|
|
|
| 15 |
current_investment=None,
|
| 16 |
monthly_investment=None,
|
| 17 |
monthly_increase_in_investment=None, # ์ถ๊ฐ๋ ์
๋ ฅ
|
| 18 |
+
reinvest_dividends=None,
|
| 19 |
pre_retirement_roi=None,
|
| 20 |
pre_retirement_dividend_yield=None,
|
|
|
|
| 21 |
post_retirement_roi=None,
|
| 22 |
post_retirement_dividend_yield=None
|
| 23 |
):
|