Spaces:
Running
Running
Upload 16 files
Browse files
interface/rebalancing_interface.py
CHANGED
@@ -1,7 +1,6 @@
|
|
1 |
import gradio as gr
|
2 |
from modules.rebalancing import rebalancing_tool
|
3 |
from modules.utils import currency_codes, current_time
|
4 |
-
from datetime import datetime
|
5 |
|
6 |
examples = [
|
7 |
["KRW", "458730 KRW 580 [8],\n368590 KRW 80 [2],", 507977],
|
@@ -15,7 +14,7 @@ main_currency = gr.Dropdown(
|
|
15 |
value="KRW",
|
16 |
# info="Assets converted to main currency"
|
17 |
)
|
18 |
-
|
19 |
holdings = gr.Textbox(
|
20 |
label="Portfolio [Ratio]",
|
21 |
lines=1,
|
@@ -23,20 +22,19 @@ holdings = gr.Textbox(
|
|
23 |
placeholder="Format: Ticker Currency Quantity [Target_Weight], ...",
|
24 |
value="SCHD USD 7 [3], 458730 KRW 580 [4], 368590 KRW 80 [1],"
|
25 |
)
|
26 |
-
title_cash = gr.Markdown("<h3 class='h3_title'>
|
27 |
cash_amount = gr.Number(
|
28 |
-
label="
|
29 |
value=507977
|
30 |
)
|
31 |
allow_sales = gr.Checkbox(
|
32 |
-
label="Allow Sales",
|
33 |
value=True,
|
34 |
-
|
35 |
)
|
36 |
|
37 |
input = [main_currency, holdings, cash_amount, allow_sales]
|
38 |
output = gr.HTML()
|
39 |
-
component_rows = [
|
40 |
|
41 |
# Define the update function
|
42 |
def update_output(*args):
|
|
|
1 |
import gradio as gr
|
2 |
from modules.rebalancing import rebalancing_tool
|
3 |
from modules.utils import currency_codes, current_time
|
|
|
4 |
|
5 |
examples = [
|
6 |
["KRW", "458730 KRW 580 [8],\n368590 KRW 80 [2],", 507977],
|
|
|
14 |
value="KRW",
|
15 |
# info="Assets converted to main currency"
|
16 |
)
|
17 |
+
title_setup = gr.Markdown(f"""<h3 class='h3_title'>Portfolio Holdings</h3>""")
|
18 |
holdings = gr.Textbox(
|
19 |
label="Portfolio [Ratio]",
|
20 |
lines=1,
|
|
|
22 |
placeholder="Format: Ticker Currency Quantity [Target_Weight], ...",
|
23 |
value="SCHD USD 7 [3], 458730 KRW 580 [4], 368590 KRW 80 [1],"
|
24 |
)
|
25 |
+
title_cash = gr.Markdown("<h3 class='h3_title'>Contribution or withdrawal</h3>")
|
26 |
cash_amount = gr.Number(
|
27 |
+
label="amount",
|
28 |
value=507977
|
29 |
)
|
30 |
allow_sales = gr.Checkbox(
|
|
|
31 |
value=True,
|
32 |
+
label="If checked, the table below will display both buy and sell transactions. If unchecked, only buy transactions will be shown."
|
33 |
)
|
34 |
|
35 |
input = [main_currency, holdings, cash_amount, allow_sales]
|
36 |
output = gr.HTML()
|
37 |
+
component_rows = [title_setup, main_currency, holdings, title_cash, cash_amount, allow_sales]
|
38 |
|
39 |
# Define the update function
|
40 |
def update_output(*args):
|
modules/rebalancing.py
CHANGED
@@ -1,12 +1,8 @@
|
|
1 |
-
import requests
|
2 |
-
import pytz
|
3 |
import math
|
4 |
-
import pandas as pd
|
5 |
import FinanceDataReader as fdr
|
6 |
import yfinance as yf
|
7 |
-
from datetime import datetime
|
8 |
from concurrent.futures import ThreadPoolExecutor
|
9 |
-
from modules.utils import load_css, get_currency_symbol, format_quantity, plot_treemap
|
10 |
|
11 |
def parse_input(holdings, cash_amount):
|
12 |
try:
|
@@ -24,7 +20,7 @@ def parse_input(holdings, cash_amount):
|
|
24 |
if target_ratio_expr.strip() == '[]':
|
25 |
target_ratio = 0
|
26 |
else:
|
27 |
-
target_ratio = float(target_ratio_expr.strip('[]').replace(' ', ''))
|
28 |
|
29 |
# ์๋์ ์ ์๋ก ๋ด๋ฆผ ์ฒ๋ฆฌ
|
30 |
quantity = math.floor(quantity)
|
|
|
|
|
|
|
1 |
import math
|
|
|
2 |
import FinanceDataReader as fdr
|
3 |
import yfinance as yf
|
|
|
4 |
from concurrent.futures import ThreadPoolExecutor
|
5 |
+
from modules.utils import load_css, get_currency_symbol, format_quantity, plot_treemap
|
6 |
|
7 |
def parse_input(holdings, cash_amount):
|
8 |
try:
|
|
|
20 |
if target_ratio_expr.strip() == '[]':
|
21 |
target_ratio = 0
|
22 |
else:
|
23 |
+
target_ratio = float(eval(target_ratio_expr.strip('[]').replace(' ', '')))
|
24 |
|
25 |
# ์๋์ ์ ์๋ก ๋ด๋ฆผ ์ฒ๋ฆฌ
|
26 |
quantity = math.floor(quantity)
|