Spaces:
Build error
Build error
Download interfaces.py from cryman38/mytest2_app: direct link, hf CLI and curl.
- Browser
- Download file 3.27 kB
-
https://huggingface.co/spaces/cryman38/mytest2_app/resolve/main/interfaces.py
- Command line
-
hf download hf://spaces/cryman38/mytest2_app/interfaces.py
-
curl -L -o interfaces.py https://huggingface.co/spaces/cryman38/mytest2_app/resolve/main/interfaces.py
3.27 kB
| 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 | |
| ) | |