Spaces:
Build error
Build error
Upload app.py
Browse files
app.py
CHANGED
|
@@ -341,7 +341,7 @@ def gradio_cost_averaging(old_avg_price, old_quantity, new_price, new_quantity):
|
|
| 341 |
<div style="box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); border-radius: 8px; padding: 48px; position: relative; width: 100%; padding: 24px;">
|
| 342 |
<div>
|
| 343 |
<div style="margin-bottom: 24px;">
|
| 344 |
-
<div style="font-size: 24px; margin-bottom: 24px;">Average Price</div>
|
| 345 |
<div style="font-size: 24px; font-weight: bold; color: #1c75bc;">
|
| 346 |
<span></span>
|
| 347 |
<span>{new_avg_price:,.0f}</span>
|
|
@@ -351,7 +351,7 @@ def gradio_cost_averaging(old_avg_price, old_quantity, new_price, new_quantity):
|
|
| 351 |
</div>
|
| 352 |
<div>
|
| 353 |
<div style="margin-bottom: 24px;">
|
| 354 |
-
<div style="font-size: 24px; margin-bottom: 24px;">Total Quantity</div>
|
| 355 |
<div style="font-size: 24px; font-weight: bold; color: #1c75bc;">
|
| 356 |
<span>{total_shares:,.0f}</span>
|
| 357 |
</div>
|
|
@@ -360,7 +360,7 @@ def gradio_cost_averaging(old_avg_price, old_quantity, new_price, new_quantity):
|
|
| 360 |
</div>
|
| 361 |
<div>
|
| 362 |
<div style="margin-bottom: 24px;">
|
| 363 |
-
<div style="font-size: 24px; margin-bottom: 24px;">Total Investment</div>
|
| 364 |
<div style="font-size: 24px; font-weight: bold; color: #1c75bc;">
|
| 365 |
<span></span>
|
| 366 |
<span>{total_investment:,.0f}</span>
|
|
@@ -371,7 +371,7 @@ def gradio_cost_averaging(old_avg_price, old_quantity, new_price, new_quantity):
|
|
| 371 |
<div style='display: flex; justify-content: space-around; align-items: center;'>
|
| 372 |
<div style='text-align: center;'>
|
| 373 |
<div style="margin-bottom: 24px;">
|
| 374 |
-
<div style="font-size: 24px; margin-bottom: 24px;"></div>
|
| 375 |
<div style="font-size: 24px; font-weight: bold; color: #1c75bc;">
|
| 376 |
<p></p>
|
| 377 |
<p>{current_return_class}</p>
|
|
@@ -379,10 +379,10 @@ def gradio_cost_averaging(old_avg_price, old_quantity, new_price, new_quantity):
|
|
| 379 |
</div>
|
| 380 |
</div>
|
| 381 |
</div>
|
| 382 |
-
<div style='text-align: center; margin-bottom: 24px; font-size: 24px;'>โ</div>
|
| 383 |
<div style='text-align: center;'>
|
| 384 |
<div style="margin-bottom: 24px;">
|
| 385 |
-
<div style="font-size: 24px; margin-bottom: 24px;"></div>
|
| 386 |
<div style="font-size: 24px; font-weight: bold; color: #1c75bc;">
|
| 387 |
<p></p>
|
| 388 |
<p>{new_return_class}</p>
|
|
@@ -422,7 +422,7 @@ portfolio_interface = gr.Interface(
|
|
| 422 |
# ["SCHD USD 400 8,\nQQQ USD 40 2", 1000000, 25],
|
| 423 |
# ["458730 krw 571 8,\n368590 krw 80 2,\nSCHD USD 400 8,\nQQQ USD 40 2", 1000000, 25]
|
| 424 |
# ],
|
| 425 |
-
live=
|
| 426 |
)
|
| 427 |
|
| 428 |
# Define the interface for the Compare tab
|
|
@@ -444,11 +444,11 @@ compare_interface = gr.Interface(
|
|
| 444 |
# ["458730,368590", 90],
|
| 445 |
# ["AAPL,GOOGL,MSFT", 90]
|
| 446 |
# ],
|
| 447 |
-
live=
|
| 448 |
)
|
| 449 |
|
| 450 |
# Define the interface for the Cost Averaging tab
|
| 451 |
-
def cost_averaging_interface(
|
| 452 |
result = gradio_cost_averaging(old_avg_price, old_quantity, new_price, new_quantity)
|
| 453 |
return result
|
| 454 |
|
|
@@ -457,30 +457,28 @@ def cost_averaging_interface(markdown1, old_avg_price, old_quantity, markdown2,
|
|
| 457 |
cost_averaging_interface = gr.Interface(
|
| 458 |
fn=cost_averaging_interface,
|
| 459 |
inputs= [
|
| 460 |
-
gr.Markdown("### ๐ First Purchase"),
|
| 461 |
gr.Number(label="Old Price", value=78.15),
|
| 462 |
-
gr.Number(label="Quantity", value=6.024272),
|
| 463 |
-
gr.Markdown("### ๐ฆ Second Purchase"),
|
| 464 |
gr.Number(label="New Price", value=77.11),
|
| 465 |
-
gr.Number(label="Quantity", value=1)
|
| 466 |
],
|
| 467 |
outputs=gr.HTML(),
|
| 468 |
# examples = [
|
| 469 |
# [78.15, 6.024272, 77.11, 1]
|
| 470 |
# ],
|
| 471 |
-
live=
|
| 472 |
)
|
| 473 |
|
| 474 |
-
def retirement_planning_interface(current_age, retirement_age, current_investment, monthly_investment, pre_retirement_roi, post_retirement_roi, pre_retirement_dividend_yield, post_retirement_dividend_yield, reinvest_dividends, life_expectancy):
|
| 475 |
# NoneType์ผ ๋ 0์ผ๋ก ์ฒ๋ฆฌ
|
| 476 |
current_age = current_age if current_age is not None else 0
|
| 477 |
retirement_age = retirement_age if retirement_age is not None else 0
|
| 478 |
current_investment = current_investment if current_investment is not None else 0
|
| 479 |
monthly_investment = monthly_investment if monthly_investment is not None else 0
|
|
|
|
| 480 |
pre_retirement_roi = pre_retirement_roi if pre_retirement_roi is not None else 0
|
| 481 |
post_retirement_roi = post_retirement_roi if post_retirement_roi is not None else 0
|
| 482 |
pre_retirement_dividend_yield = pre_retirement_dividend_yield if pre_retirement_dividend_yield is not None else 0
|
| 483 |
-
post_retirement_dividend_yield = post_retirement_dividend_yield if post_retirement_dividend_yield is not None else 0
|
| 484 |
life_expectancy = life_expectancy if life_expectancy is not None else 0
|
| 485 |
|
| 486 |
# ์ํด ์ ํ์ ๋
์ ๊ณ์ฐ
|
|
@@ -500,6 +498,8 @@ def retirement_planning_interface(current_age, retirement_age, current_investmen
|
|
| 500 |
total_investment = (total_investment + monthly_investment) * (1 + monthly_return_pre)
|
| 501 |
if reinvest_dividends:
|
| 502 |
total_investment += total_investment * (pre_retirement_dividend_yield / 100 / 12)
|
|
|
|
|
|
|
| 503 |
|
| 504 |
# ์ํด ์์ ์์ ์ ์ด ํฌ์์ก๊ณผ ์ฐ๊ฐ ๋ฐฐ๋น ์์ต ์ ์ฅ
|
| 505 |
investment_at_retirement = total_investment
|
|
@@ -529,30 +529,29 @@ def retirement_planning_interface(current_age, retirement_age, current_investmen
|
|
| 529 |
<div style="box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); border-radius: 8px; padding: 48px; position: relative; width: 100%; padding: 24px;">
|
| 530 |
<div>
|
| 531 |
<div style="margin-bottom: 24px;">
|
| 532 |
-
<div style="font-size: 24px; margin-bottom: 24px;">Total
|
| 533 |
<div style="font-size: 24px; font-weight: bold; color: #1c75bc;">
|
| 534 |
-
<span></span>
|
| 535 |
-
<span>โฉ{investment_at_retirement:,.0f}</span>
|
| 536 |
</div>
|
| 537 |
-
<hr style="margin:
|
| 538 |
</div>
|
| 539 |
</div>
|
| 540 |
<div>
|
| 541 |
<div style="margin-bottom: 24px;">
|
| 542 |
-
<div style="font-size: 24px; margin-bottom: 24px;">Annual
|
| 543 |
<div style="font-size: 24px; font-weight: bold; color: #1c75bc;">
|
| 544 |
-
<span>โฉ{annual_dividend_at_retirement:,.0f}</span>
|
| 545 |
</div>
|
| 546 |
-
<hr style="margin:
|
| 547 |
</div>
|
| 548 |
</div>
|
| 549 |
<div>
|
| 550 |
<div style="margin-bottom: 24px;">
|
| 551 |
-
<div style="font-size: 24px; margin-bottom: 24px;">Monthly
|
| 552 |
<div style="font-size: 24px; font-weight: bold; color: #1c75bc;">
|
| 553 |
-
<span>โฉ{monthly_dividend_at_retirement:,.0f}</span>
|
| 554 |
</div>
|
| 555 |
-
<hr style="margin:
|
| 556 |
</div>
|
| 557 |
</div>
|
| 558 |
</div>
|
|
@@ -563,8 +562,8 @@ def retirement_planning_interface(current_age, retirement_age, current_investmen
|
|
| 563 |
<tr>
|
| 564 |
<th style='border: 1px solid #ddd; padding: 8px;'>Age</th>
|
| 565 |
<th style='border: 1px solid #ddd; padding: 8px;'>Total Investment</th>
|
| 566 |
-
<th style='border: 1px solid #ddd; padding: 8px;'>Annual Dividend
|
| 567 |
-
<th style='border: 1px solid #ddd; padding: 8px;'>Monthly Dividend
|
| 568 |
</tr>
|
| 569 |
</thead>
|
| 570 |
<tbody>
|
|
@@ -596,6 +595,7 @@ retirement_planning_inputs = [
|
|
| 596 |
gr.Slider(label="Retirement Age (Upto 70 Years)", value=55, minimum=15, maximum=70, step=1),
|
| 597 |
gr.Number(label="Current Investment (โฉ)", value=10000000),
|
| 598 |
gr.Number(label="Monthly Investment (โฉ)", value=500000),
|
|
|
|
| 599 |
gr.Number(label="Expected Return On Investment (Pre-retirement) (%)", value=8),
|
| 600 |
gr.Number(label="Expected Return On Investment (Post-retirement) (%)", value=8),
|
| 601 |
gr.Number(label="Expected Dividend Yield (Pre-retirement) (%)", value=3.3),
|
|
|
|
| 341 |
<div style="box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); border-radius: 8px; padding: 48px; position: relative; width: 100%; padding: 24px;">
|
| 342 |
<div>
|
| 343 |
<div style="margin-bottom: 24px;">
|
| 344 |
+
<div style="font-size: 24px;margin-top: 24px; margin-bottom: 24px;">Average Price</div>
|
| 345 |
<div style="font-size: 24px; font-weight: bold; color: #1c75bc;">
|
| 346 |
<span></span>
|
| 347 |
<span>{new_avg_price:,.0f}</span>
|
|
|
|
| 351 |
</div>
|
| 352 |
<div>
|
| 353 |
<div style="margin-bottom: 24px;">
|
| 354 |
+
<div style="font-size: 24px;margin-top: 24px; margin-bottom: 24px;">Total Quantity</div>
|
| 355 |
<div style="font-size: 24px; font-weight: bold; color: #1c75bc;">
|
| 356 |
<span>{total_shares:,.0f}</span>
|
| 357 |
</div>
|
|
|
|
| 360 |
</div>
|
| 361 |
<div>
|
| 362 |
<div style="margin-bottom: 24px;">
|
| 363 |
+
<div style="font-size: 24px;margin-top: 24px; margin-bottom: 24px;">Total Investment</div>
|
| 364 |
<div style="font-size: 24px; font-weight: bold; color: #1c75bc;">
|
| 365 |
<span></span>
|
| 366 |
<span>{total_investment:,.0f}</span>
|
|
|
|
| 371 |
<div style='display: flex; justify-content: space-around; align-items: center;'>
|
| 372 |
<div style='text-align: center;'>
|
| 373 |
<div style="margin-bottom: 24px;">
|
| 374 |
+
<div style="font-size: 24px;margin-top: 24px; margin-bottom: 24px;"></div>
|
| 375 |
<div style="font-size: 24px; font-weight: bold; color: #1c75bc;">
|
| 376 |
<p></p>
|
| 377 |
<p>{current_return_class}</p>
|
|
|
|
| 379 |
</div>
|
| 380 |
</div>
|
| 381 |
</div>
|
| 382 |
+
<div style='text-align: center;margin-top: 24px; margin-bottom: 24px; font-size: 24px;'>โ</div>
|
| 383 |
<div style='text-align: center;'>
|
| 384 |
<div style="margin-bottom: 24px;">
|
| 385 |
+
<div style="font-size: 24px;margin-top: 24px; margin-bottom: 24px;"></div>
|
| 386 |
<div style="font-size: 24px; font-weight: bold; color: #1c75bc;">
|
| 387 |
<p></p>
|
| 388 |
<p>{new_return_class}</p>
|
|
|
|
| 422 |
# ["SCHD USD 400 8,\nQQQ USD 40 2", 1000000, 25],
|
| 423 |
# ["458730 krw 571 8,\n368590 krw 80 2,\nSCHD USD 400 8,\nQQQ USD 40 2", 1000000, 25]
|
| 424 |
# ],
|
| 425 |
+
live=True
|
| 426 |
)
|
| 427 |
|
| 428 |
# Define the interface for the Compare tab
|
|
|
|
| 444 |
# ["458730,368590", 90],
|
| 445 |
# ["AAPL,GOOGL,MSFT", 90]
|
| 446 |
# ],
|
| 447 |
+
live=True
|
| 448 |
)
|
| 449 |
|
| 450 |
# Define the interface for the Cost Averaging tab
|
| 451 |
+
def cost_averaging_interface(old_avg_price, old_quantity, new_price, new_quantity):
|
| 452 |
result = gradio_cost_averaging(old_avg_price, old_quantity, new_price, new_quantity)
|
| 453 |
return result
|
| 454 |
|
|
|
|
| 457 |
cost_averaging_interface = gr.Interface(
|
| 458 |
fn=cost_averaging_interface,
|
| 459 |
inputs= [
|
|
|
|
| 460 |
gr.Number(label="Old Price", value=78.15),
|
| 461 |
+
gr.Number(label="Old Quantity", value=6.024272),
|
|
|
|
| 462 |
gr.Number(label="New Price", value=77.11),
|
| 463 |
+
gr.Number(label="New Quantity", value=1)
|
| 464 |
],
|
| 465 |
outputs=gr.HTML(),
|
| 466 |
# examples = [
|
| 467 |
# [78.15, 6.024272, 77.11, 1]
|
| 468 |
# ],
|
| 469 |
+
live=True
|
| 470 |
)
|
| 471 |
|
| 472 |
+
def retirement_planning_interface(current_age, retirement_age, current_investment, monthly_investment, annual_increase_rate, pre_retirement_roi, post_retirement_roi, pre_retirement_dividend_yield, post_retirement_dividend_yield, reinvest_dividends, life_expectancy):
|
| 473 |
# NoneType์ผ ๋ 0์ผ๋ก ์ฒ๋ฆฌ
|
| 474 |
current_age = current_age if current_age is not None else 0
|
| 475 |
retirement_age = retirement_age if retirement_age is not None else 0
|
| 476 |
current_investment = current_investment if current_investment is not None else 0
|
| 477 |
monthly_investment = monthly_investment if monthly_investment is not None else 0
|
| 478 |
+
annual_increase_rate = annual_increase_rate if annual_increase_rate is not None else 0
|
| 479 |
pre_retirement_roi = pre_retirement_roi if pre_retirement_roi is not None else 0
|
| 480 |
post_retirement_roi = post_retirement_roi if post_retirement_roi is not None else 0
|
| 481 |
pre_retirement_dividend_yield = pre_retirement_dividend_yield if pre_retirement_dividend_yield is not None else 0
|
|
|
|
| 482 |
life_expectancy = life_expectancy if life_expectancy is not None else 0
|
| 483 |
|
| 484 |
# ์ํด ์ ํ์ ๋
์ ๊ณ์ฐ
|
|
|
|
| 498 |
total_investment = (total_investment + monthly_investment) * (1 + monthly_return_pre)
|
| 499 |
if reinvest_dividends:
|
| 500 |
total_investment += total_investment * (pre_retirement_dividend_yield / 100 / 12)
|
| 501 |
+
# ๋งค๋
๋ง๋ง๋ค ์๊ฐ ํฌ์์ก ์ฆ๊ฐ
|
| 502 |
+
monthly_investment += monthly_investment * (annual_increase_rate / 100)
|
| 503 |
|
| 504 |
# ์ํด ์์ ์์ ์ ์ด ํฌ์์ก๊ณผ ์ฐ๊ฐ ๋ฐฐ๋น ์์ต ์ ์ฅ
|
| 505 |
investment_at_retirement = total_investment
|
|
|
|
| 529 |
<div style="box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); border-radius: 8px; padding: 48px; position: relative; width: 100%; padding: 24px;">
|
| 530 |
<div>
|
| 531 |
<div style="margin-bottom: 24px;">
|
| 532 |
+
<div style="font-size: 24px; margin-top: 24px; margin-bottom: 24px;">Total Investment:</div>
|
| 533 |
<div style="font-size: 24px; font-weight: bold; color: #1c75bc;">
|
| 534 |
+
<span style='color: #1678fb'>โฉ {investment_at_retirement:,.0f}</span>
|
|
|
|
| 535 |
</div>
|
| 536 |
+
<hr style="margin: 1.5rem 0;">
|
| 537 |
</div>
|
| 538 |
</div>
|
| 539 |
<div>
|
| 540 |
<div style="margin-bottom: 24px;">
|
| 541 |
+
<div style="font-size: 24px;margin-top: 24px; margin-bottom: 24px;">Annual Dividend:</div>
|
| 542 |
<div style="font-size: 24px; font-weight: bold; color: #1c75bc;">
|
| 543 |
+
<span style='color: #1678fb'>โฉ {annual_dividend_at_retirement:,.0f}</span>
|
| 544 |
</div>
|
| 545 |
+
<hr style="margin: 1.5rem 0;">
|
| 546 |
</div>
|
| 547 |
</div>
|
| 548 |
<div>
|
| 549 |
<div style="margin-bottom: 24px;">
|
| 550 |
+
<div style="font-size: 24px;margin-top: 24px; margin-bottom: 24px;">Monthly Dividend:</div>
|
| 551 |
<div style="font-size: 24px; font-weight: bold; color: #1c75bc;">
|
| 552 |
+
<span style='color: #1678fb'>โฉ {monthly_dividend_at_retirement:,.0f}</span>
|
| 553 |
</div>
|
| 554 |
+
<hr style="margin: 1.5rem 0;">
|
| 555 |
</div>
|
| 556 |
</div>
|
| 557 |
</div>
|
|
|
|
| 562 |
<tr>
|
| 563 |
<th style='border: 1px solid #ddd; padding: 8px;'>Age</th>
|
| 564 |
<th style='border: 1px solid #ddd; padding: 8px;'>Total Investment</th>
|
| 565 |
+
<th style='border: 1px solid #ddd; padding: 8px;'>Annual Dividend</th>
|
| 566 |
+
<th style='border: 1px solid #ddd; padding: 8px;'>Monthly Dividend</th>
|
| 567 |
</tr>
|
| 568 |
</thead>
|
| 569 |
<tbody>
|
|
|
|
| 595 |
gr.Slider(label="Retirement Age (Upto 70 Years)", value=55, minimum=15, maximum=70, step=1),
|
| 596 |
gr.Number(label="Current Investment (โฉ)", value=10000000),
|
| 597 |
gr.Number(label="Monthly Investment (โฉ)", value=500000),
|
| 598 |
+
gr.Number(label="Annual Increase in Monthly Investment (%)", value=0), # ์ฐ๊ฐ ์ฆ๊ฐ์จ
|
| 599 |
gr.Number(label="Expected Return On Investment (Pre-retirement) (%)", value=8),
|
| 600 |
gr.Number(label="Expected Return On Investment (Post-retirement) (%)", value=8),
|
| 601 |
gr.Number(label="Expected Dividend Yield (Pre-retirement) (%)", value=3.3),
|