import gradio as gr from modules.rebalancing import rebalancing_tool, load_css from modules.utils import get_currency_codes def rebalancing_interface_fn(main_currency, holdings, cash_amount, cash_ratio): result = rebalancing_tool(main_currency, holdings, cash_amount, cash_ratio) css = load_css() return css + result currency_codes = get_currency_codes() examples = [ ["KRW", "458730 KRW 580 8,\n368590 KRW 80 2", 507977, 0], ["KRW", "SCHD USD 500 8,\nQQQ USD 200 2", 0, 15] ] # Define Gradio components main_currency = gr.Dropdown( label="Main Currency", choices=currency_codes, value="KRW", info="Assets converted to main currency." ) holdings = gr.Textbox( label="Holdings", lines=2, info="Format: [ ticker currency quantity weight, ... ]", placeholder="e.g., SCHD USD 500 8, QQQ USD 200 2" ) cash_amount = gr.Number( label="Cash", value="", info="MAIN CURRENCY CASH" ) cash_ratio = gr.Slider( label="Cash Ratio (%)", minimum=0, maximum=100, step=1 ) portfolio_rebalancing_inputs = [main_currency, holdings, cash_amount, cash_ratio] output = gr.HTML() # Define the update function def update_output(main_currency, holdings, cash_amount, cash_ratio): return rebalancing_interface_fn(main_currency, holdings, cash_amount, cash_ratio)