cryman38 commited on
Commit
a4c127d
ยท
verified ยท
1 Parent(s): fd37a06

Upload 18 files

Browse files
interface/rebalancing_interface.py CHANGED
@@ -4,7 +4,7 @@ from modules.utils import currency_codes, current_time
4
 
5
  examples = [
6
  ["KRW", "458730 KRW 769 [4],\n368590 KRW 122 [1],", 0],
7
- ["KRW", "SCHD USD 8.753844 [8],\nQQQ USD 0.391143 [2],",0],
8
  ["KRW", "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]", 6693188]
9
  ]
10
 
@@ -21,7 +21,8 @@ holdings = gr.Textbox(
21
  lines=2,
22
  # info="Format: Ticker Currency Quantity [Target_Weight], ...",
23
  placeholder="Format: Ticker Currency Quantity [Target_Ratio], ...",
24
- value="458730 KRW 769 [4],\n368590 KRW 122 [1],"
 
25
  )
26
  title_cash = gr.Markdown("<h3 class='h3_title'>Contribution or withdrawal</h3>")
27
  cash_amount = gr.Number(
 
4
 
5
  examples = [
6
  ["KRW", "458730 KRW 769 [4],\n368590 KRW 122 [1],", 0],
7
+ ["KRW", "SCHD USD 9.044802 [8],\nQQQ USD 0.404082 [2],",0],
8
  ["KRW", "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]", 6693188]
9
  ]
10
 
 
21
  lines=2,
22
  # info="Format: Ticker Currency Quantity [Target_Weight], ...",
23
  placeholder="Format: Ticker Currency Quantity [Target_Ratio], ...",
24
+ value="458730 KRW 769 [4],\n368590 KRW 122 [1],",
25
+ show_copy_button = True
26
  )
27
  title_cash = gr.Markdown("<h3 class='h3_title'>Contribution or withdrawal</h3>")
28
  cash_amount = gr.Number(
interface/share_price_trend_interface.py CHANGED
@@ -17,7 +17,9 @@ stock_codes = gr.Textbox(
17
  period = gr.Slider(
18
  label="Number of Days",
19
  value=365,
20
- minimum=7
 
 
21
  )
22
 
23
  # Define output component
 
17
  period = gr.Slider(
18
  label="Number of Days",
19
  value=365,
20
+ minimum=7,
21
+ step = 1,
22
+ randomize = True
23
  )
24
 
25
  # Define output component
modules/rebalancing.py CHANGED
@@ -11,6 +11,9 @@ def parse_input(holdings, cash_amount):
11
  stock_inputs = []
12
  total_target_ratio = 0
13
 
 
 
 
14
  for line in lines:
15
  parts = line.split()
16
  if len(parts) == 4:
@@ -21,9 +24,22 @@ def parse_input(holdings, cash_amount):
21
  else:
22
  target_ratio = float(eval(target_ratio_expr.strip('[]').replace(' ', '')))
23
 
24
- stock_inputs.append((currency_code.upper(), stock_code, quantity, target_ratio))
 
 
 
 
 
 
 
 
 
 
25
  total_target_ratio += target_ratio
26
 
 
 
 
27
  return stock_inputs, cash_amount
28
  except Exception as e:
29
  raise ValueError(f"Input parsing error: {e}")
 
11
  stock_inputs = []
12
  total_target_ratio = 0
13
 
14
+ # ์ข…๋ชฉ ์ •๋ณด๋ฅผ ์ €์žฅํ•  ๋”•์…”๋„ˆ๋ฆฌ
15
+ stock_dict = {}
16
+
17
  for line in lines:
18
  parts = line.split()
19
  if len(parts) == 4:
 
24
  else:
25
  target_ratio = float(eval(target_ratio_expr.strip('[]').replace(' ', '')))
26
 
27
+ # ์ข…๋ชฉ ์ฝ”๋“œ๊ฐ€ ์ด๋ฏธ ๋”•์…”๋„ˆ๋ฆฌ์— ์กด์žฌํ•˜๋Š” ๊ฒฝ์šฐ, ์ˆ˜๋Ÿ‰๊ณผ ๋ชฉํ‘œ ๋น„์œจ์„ ํ•ฉ์‚ฐ
28
+ if stock_code in stock_dict:
29
+ stock_dict[stock_code]['quantity'] += quantity
30
+ stock_dict[stock_code]['target_ratio'] += target_ratio
31
+ else:
32
+ stock_dict[stock_code] = {
33
+ 'currency_code': currency_code.upper(),
34
+ 'quantity': quantity,
35
+ 'target_ratio': target_ratio
36
+ }
37
+
38
  total_target_ratio += target_ratio
39
 
40
+ stock_inputs = [(details['currency_code'], stock_code, details['quantity'], details['target_ratio'])
41
+ for stock_code, details in stock_dict.items()]
42
+
43
  return stock_inputs, cash_amount
44
  except Exception as e:
45
  raise ValueError(f"Input parsing error: {e}")
style.css CHANGED
@@ -52,7 +52,7 @@
52
  #col-container {
53
  margin: 0 auto;
54
  max-width: 100%;
55
- /* font-family: 'Quicksand', 'ui-sans-serif', 'system-ui', 'sans-serif'; */
56
  }
57
 
58
  .h3_title {
 
52
  #col-container {
53
  margin: 0 auto;
54
  max-width: 100%;
55
+ font-family: 'Quicksand', 'ui-sans-serif', 'system-ui', 'sans-serif';
56
  }
57
 
58
  .h3_title {