Spaces:
Running
Running
import gradio as gr | |
from modules.rebalancing import rebalancing_tool | |
from modules.utils import currency_codes, current_time | |
examples = [ | |
["KRW", "458730 KRW 921 [8],\n368590 KRW 134 [2],\n458730 KRW 95 [8],\n368590 KRW 14 [2],", 0], | |
["KRW", "SCHD USD 54.440238 [8],\nQQQ USD 0.795350 [2],",0], | |
["USD", "AAPL USD 500 [20], \nMSFT USD 300 [15], \nGOOGL USD 400 [10], \nAMZN USD 50 [5], \nTSLA USD 200 [10], \nNVDA USD 250 [10], \nNFLX USD 150 [10], \nQQQ USD 450 [5], \nADBE USD 100 [10], \nPYPL USD 50 [5]", 10000] | |
] | |
# 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="Portfolio [Target]", | |
lines=2, | |
# info="Format: Ticker Currency Quantity [Target_Weight], ...", | |
placeholder="Format: Ticker Currency Quantity [Target_Ratio], ...", | |
value="SCHD USD 354 [8],\nQQQ USD 4 [2]", | |
show_copy_button = True | |
) | |
cash_amount = gr.Number( | |
label="Contribution or withdrawal amount", | |
value=1000000 | |
) | |
allow_sales = gr.Checkbox( | |
value=True, | |
label="If checked, the table below will display both buy and sell transactions. If unchecked, only buy transactions will be shown." | |
) | |
input = [main_currency, holdings, cash_amount, allow_sales] | |
output = gr.HTML() | |
component_rows = [holdings, [cash_amount, allow_sales], [main_currency]] | |
# Define the update function | |
def update_output(*args): | |
return rebalancing_tool(*args) | |