Spaces:
Running
Running
Upload 16 files
Browse files
interface/dollar_cost_averaging_interface.py
CHANGED
@@ -7,11 +7,11 @@ examples = [
|
|
7 |
# Define the inputs
|
8 |
title = gr.Markdown("<h2 style='margin: 5px'>Dollar Cost Averaging Calculator</h2>")
|
9 |
first_purchase = gr.Markdown("<h3 class='h3_title'>FIRST PURCHASE</h3>")
|
10 |
-
old_price = gr.
|
11 |
-
old_quantity = gr.
|
12 |
second_purchase = gr.Markdown("<h3 class='h3_title'>SECOND PURCHASE</h3>")
|
13 |
-
new_price = gr.
|
14 |
-
new_quantity = gr.
|
15 |
|
16 |
input = [old_price, old_quantity, new_price, new_quantity]
|
17 |
output = gr.HTML()
|
|
|
7 |
# Define the inputs
|
8 |
title = gr.Markdown("<h2 style='margin: 5px'>Dollar Cost Averaging Calculator</h2>")
|
9 |
first_purchase = gr.Markdown("<h3 class='h3_title'>FIRST PURCHASE</h3>")
|
10 |
+
old_price = gr.Number(label="Old Price", value=18150)
|
11 |
+
old_quantity = gr.Number(label="Quantity", value=95)
|
12 |
second_purchase = gr.Markdown("<h3 class='h3_title'>SECOND PURCHASE</h3>")
|
13 |
+
new_price = gr.Number(label="New Price", value=17705)
|
14 |
+
new_quantity = gr.Number(label="Quantity", value=0)
|
15 |
|
16 |
input = [old_price, old_quantity, new_price, new_quantity]
|
17 |
output = gr.HTML()
|
interface/retirement_planning_interface.py
CHANGED
@@ -28,8 +28,8 @@ post_retirement_dividend_yield = gr.Number(label="Dividend Yield (Post-retiremen
|
|
28 |
input = [current_age, retirement_age, life_expectancy, monthly_income_required, inflation_rate, current_investment, monthly_investment, annual_increase_in_monthly_investment, reinvest_dividends, pre_retirement_roi, post_retirement_roi, pre_retirement_dividend_yield, post_retirement_dividend_yield]
|
29 |
output = gr.HTML()
|
30 |
component_rows = [
|
31 |
-
current_age, retirement_age, life_expectancy,[monthly_income_required, inflation_rate],
|
32 |
-
current_investment, monthly_investment, annual_increase_in_monthly_investment, [reinvest_dividends],
|
33 |
[pre_retirement_roi, post_retirement_roi], [pre_retirement_dividend_yield, post_retirement_dividend_yield]
|
34 |
]
|
35 |
|
|
|
28 |
input = [current_age, retirement_age, life_expectancy, monthly_income_required, inflation_rate, current_investment, monthly_investment, annual_increase_in_monthly_investment, reinvest_dividends, pre_retirement_roi, post_retirement_roi, pre_retirement_dividend_yield, post_retirement_dividend_yield]
|
29 |
output = gr.HTML()
|
30 |
component_rows = [
|
31 |
+
[current_age, retirement_age, life_expectancy],[monthly_income_required, inflation_rate],
|
32 |
+
[current_investment, monthly_investment, annual_increase_in_monthly_investment], [reinvest_dividends],
|
33 |
[pre_retirement_roi, post_retirement_roi], [pre_retirement_dividend_yield, post_retirement_dividend_yield]
|
34 |
]
|
35 |
|
modules/dollar_cost_averaging.py
CHANGED
@@ -49,16 +49,16 @@ def dollar_cost_averaging(old_avg_price, old_quantity, new_price, new_quantity):
|
|
49 |
emoji_return = ""
|
50 |
|
51 |
if new_return > 0:
|
52 |
-
new_return_class = f"<span style='color: #4caf50;
|
53 |
elif new_return < 0:
|
54 |
-
new_return_class = f"<span style='color: #f44336;
|
55 |
else:
|
56 |
new_return_class = f"<span><strong>0</strong></span>"
|
57 |
|
58 |
if old_return > 0:
|
59 |
-
old_return_class = f"<span style='color: #4caf50;
|
60 |
elif old_return < 0:
|
61 |
-
old_return_class = f"<span style='color: #f44336;
|
62 |
else:
|
63 |
old_return_class = f"<span><strong>0</strong></span>"
|
64 |
|
@@ -67,28 +67,30 @@ def dollar_cost_averaging(old_avg_price, old_quantity, new_price, new_quantity):
|
|
67 |
<div class="wrap-text">
|
68 |
<div>
|
69 |
<div style="margin-bottom: 1.5rem;">
|
70 |
-
<!--
|
71 |
-
<div style="font-size: 1.5rem; margin-top: 1.5rem; margin-bottom: 1.5rem;">
|
72 |
-
<div style="font-size: 1.5rem;">
|
73 |
-
|
|
|
74 |
</div>
|
75 |
<hr style="margin: 1.5rem 0;">
|
76 |
</div>
|
77 |
-
</div>
|
78 |
-
|
79 |
<div style="margin-bottom: 1.5rem;">
|
80 |
-
<!--
|
81 |
<div style="font-size: 1.5rem; margin-top: 1.5rem; margin-bottom: 1.5rem;">Average Price</div>
|
82 |
-
<div style="font-size: 1.5rem;
|
83 |
-
<span style='color: #1678fb'>{new_avg_price:,.0f}</span>
|
|
|
84 |
</div>
|
85 |
<hr style="margin: 1.5rem 0;">
|
86 |
</div>
|
87 |
-
</div>
|
88 |
<div>
|
89 |
<div style="margin-bottom: 1.5rem;">
|
90 |
<!-- μΆκ° ν¬μ κΈμ‘ νμ -->
|
91 |
-
<div style="font-size: 1.5rem; margin-top: 1.5rem; margin-bottom: 1.5rem;">
|
92 |
<div style="font-size: 1.5rem; font-weight: bold; color: #1c75bc;">
|
93 |
<span style='color: #1678fb'>{additional_investment:,.0f}</span>
|
94 |
</div>
|
|
|
49 |
emoji_return = ""
|
50 |
|
51 |
if new_return > 0:
|
52 |
+
new_return_class = f"<span style='color: #4caf50;'>{new_return:+,.2f}%</span>"
|
53 |
elif new_return < 0:
|
54 |
+
new_return_class = f"<span style='color: #f44336;'>{new_return:,.2f}%</span>"
|
55 |
else:
|
56 |
new_return_class = f"<span><strong>0</strong></span>"
|
57 |
|
58 |
if old_return > 0:
|
59 |
+
old_return_class = f"<span style='color: #4caf50;'>{old_return:+,.2f}%</span>"
|
60 |
elif old_return < 0:
|
61 |
+
old_return_class = f"<span style='color: #f44336;'>{old_return:,.2f}%</span>"
|
62 |
else:
|
63 |
old_return_class = f"<span><strong>0</strong></span>"
|
64 |
|
|
|
67 |
<div class="wrap-text">
|
68 |
<div>
|
69 |
<div style="margin-bottom: 1.5rem;">
|
70 |
+
<!-- μ΄μ μμ΅λ₯ νμ -->
|
71 |
+
<div style="font-size: 1.5rem; margin-top: 1.5rem; margin-bottom: 1.5rem;">Old Price</div>
|
72 |
+
<div style="font-size: 1.5rem; color: #1c75bc;">
|
73 |
+
<span style='color: #1678fb; font-weight: bold;'>{old_avg_price:,.0f}</span>
|
74 |
+
<span style='font-size: 1rem;'>{old_return_class}</span>
|
75 |
</div>
|
76 |
<hr style="margin: 1.5rem 0;">
|
77 |
</div>
|
78 |
+
</div>
|
79 |
+
<div>
|
80 |
<div style="margin-bottom: 1.5rem;">
|
81 |
+
<!-- μλ‘μ΄ μμ΅λ₯ νμ -->
|
82 |
<div style="font-size: 1.5rem; margin-top: 1.5rem; margin-bottom: 1.5rem;">Average Price</div>
|
83 |
+
<div style="font-size: 1.5rem; color: #1c75bc;">
|
84 |
+
<span style='color: #1678fb; font-weight: bold;'>{new_avg_price:,.0f}</span>
|
85 |
+
<span style='font-size: 1rem;'>{new_return_class}</span>
|
86 |
</div>
|
87 |
<hr style="margin: 1.5rem 0;">
|
88 |
</div>
|
89 |
+
</div>
|
90 |
<div>
|
91 |
<div style="margin-bottom: 1.5rem;">
|
92 |
<!-- μΆκ° ν¬μ κΈμ‘ νμ -->
|
93 |
+
<div style="font-size: 1.5rem; margin-top: 1.5rem; margin-bottom: 1.5rem;">Additional Investment</div>
|
94 |
<div style="font-size: 1.5rem; font-weight: bold; color: #1c75bc;">
|
95 |
<span style='color: #1678fb'>{additional_investment:,.0f}</span>
|
96 |
</div>
|
modules/rebalancing.py
CHANGED
@@ -117,38 +117,7 @@ def generate_portfolio_info(portfolio, total_value, main_currency):
|
|
117 |
{currunt_weights_chart}
|
118 |
</div>
|
119 |
"""
|
120 |
-
|
121 |
-
# <div class='table-container wrap-text'>
|
122 |
-
# <table>
|
123 |
-
# <thead>
|
124 |
-
# <tr><th>Stock Code</th><th>Current Weight (%)</th><th>Current Value</th></tr>
|
125 |
-
# </thead>
|
126 |
-
# <tbody>
|
127 |
-
# {''.join(
|
128 |
-
# f"<tr><td>{stock_code.upper()}</td><td>{details['weight'] * 100:.1f}%</td><td>{currency_symbol}{format_value(details['value'])}</td></tr>"
|
129 |
-
# for stock_code, details in holdings_totals.items()
|
130 |
-
# )}
|
131 |
-
# </tbody>
|
132 |
-
# </table>
|
133 |
-
# </div>
|
134 |
-
|
135 |
-
# <br>
|
136 |
-
# <h3>Your Portfolio by Currency</h3>
|
137 |
-
# {currency_weights_chart}
|
138 |
-
# <br>
|
139 |
-
# <div class='table-container wrap-text'>
|
140 |
-
# <table>
|
141 |
-
# <thead>
|
142 |
-
# <tr><th>Currency</th><th>Total Weight (%)</th><th>Total Value</th></tr>
|
143 |
-
# </thead>
|
144 |
-
# <tbody>
|
145 |
-
# {''.join(
|
146 |
-
# f"<tr><td>{currency.upper()}</td><td>{details['weight']* 100:.1f}%</td><td>{currency_symbol}{format_value(details['value'])}</td></tr>"
|
147 |
-
# for currency, details in currency_totals.items()
|
148 |
-
# )}
|
149 |
-
# </tbody>
|
150 |
-
# </table>
|
151 |
-
# </div>
|
152 |
return portfolio_info
|
153 |
|
154 |
def generate_rebalancing_analysis(portfolio, target_ratios, total_value, main_currency, cash_amount, allow_selling):
|
|
|
117 |
{currunt_weights_chart}
|
118 |
</div>
|
119 |
"""
|
120 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
121 |
return portfolio_info
|
122 |
|
123 |
def generate_rebalancing_analysis(portfolio, target_ratios, total_value, main_currency, cash_amount, allow_selling):
|