Spaces:
Sleeping
Sleeping
File size: 3,272 Bytes
580d8e5 aaa66d0 580d8e5 aaa66d0 580d8e5 aaa66d0 580d8e5 aaa66d0 580d8e5 aaa66d0 580d8e5 aaa66d0 580d8e5 aaa66d0 580d8e5 aaa66d0 580d8e5 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
import gradio as gr
from utils.css import load_css
from utils.portfolio import rebalancing_tool
from utils.plotting import plot_stock_prices
from utils.cost_averaging import gradio_cost_averaging
from utils.retirement import retirement_planning_tool
def portfolio_interface(input_text, cash_amount, cash_ratio, default_currency):
result = rebalancing_tool(input_text, cash_amount, cash_ratio, default_currency)
css = load_css()
return css + result
portfolio_inputs = [
gr.Textbox(label="π₯ Holdings", lines=2, placeholder="Format: [ Ticker Currency Quantity Weight, ... ]", value="SCHD USD 500 8,\nQQQ USD 20 2"),
gr.Number(label="πͺ΅ Cash", value=0),
gr.Slider(label="βοΈ Cash Ratio (%)", value=15, minimum=0, maximum=100, step=1),
gr.Radio(label="π± Default Currency", choices=["KRW", "USD", "EUR", "JPY", "GBP", "AUD", "CAD", "CHF", "CNY", "INR", "BRL", "ZAR", "SGD", "HKD"], value="KRW")
]
portfolio_interface = gr.Interface(
fn=portfolio_interface,
inputs=portfolio_inputs,
outputs=gr.HTML(),
live=True
)
def compare_interface(stock_codes, period):
result = plot_stock_prices(stock_codes, period)
css = load_css()
return css + result
compare_inputs = [
gr.Textbox(label="π Stock Codes", lines=2, placeholder="Enter stock codes separated by comma (e.g., AAPL,GOOGL,MSFT)", value="SCHD,QQQ"),
gr.Textbox(label="π Period (days)", value=90)
]
compare_interface = gr.Interface(
fn=compare_interface,
inputs=compare_inputs,
outputs=gr.HTML(),
live=False
)
def cost_averaging_interface(old_avg_price, old_quantity, new_price, new_quantity):
result = gradio_cost_averaging(old_avg_price, old_quantity, new_price, new_quantity)
css = load_css()
return css + result
cost_averaging_interface = gr.Interface(
fn=cost_averaging_interface,
inputs=[
gr.Number(label="First Purchase Price", value=100000),
gr.Number(label="First Purchase Quantity", value=10),
gr.Number(label="Second Purchase Price", value=50000),
gr.Number(label="Second Purchase Quantity", value="")
],
outputs=gr.HTML(),
live=True
)
def retirement_planning_interface(*args):
result = retirement_planning_tool(*args)
css = load_css()
return css + result
retirement_planning_interface = gr.Interface(
fn=retirement_planning_interface,
inputs=[
gr.Slider(label="Current Age (15-60 Years)", value=15, minimum=15, maximum=60, step=1),
gr.Slider(label="Retirement Age (Upto 70 Years)", value=55, minimum=15, maximum=70, step=1),
gr.Number(label="Current Investment ()", value=10000000),
gr.Number(label="Monthly Investment ()", value=500000),
gr.Number(label="Expected Return On Investment (Pre-retirement) (%)", value=8),
gr.Number(label="Expected Return On Investment (Post-retirement) (%)", value=8),
gr.Number(label="Expected Dividend Yield (Pre-retirement) (%)", value=3.3),
gr.Number(label="Expected Dividend Yield (Post-retirement) (%)", value=3.3),
gr.Checkbox(label="Reinvest Dividends", value=True),
gr.Slider(label="Life Expectancy (Upto 100 Years)", value=80, minimum=30, maximum=100, step=1)
],
outputs=gr.HTML(),
live=True
)
|