Spaces:
Running
Running
Upload 17 files
Browse files- Gilroy-Regular.otf +0 -0
- app.py +1 -1
- modules/rebalancing.py +5 -3
- modules/utils.py +3 -3
- style.css +16 -3
Gilroy-Regular.otf
ADDED
Binary file (53.8 kB). View file
|
|
app.py
CHANGED
@@ -66,4 +66,4 @@ with gr.Blocks(css='style.css') as demo:
|
|
66 |
retirement_planning_output
|
67 |
]
|
68 |
)
|
69 |
-
demo.launch()
|
|
|
66 |
retirement_planning_output
|
67 |
]
|
68 |
)
|
69 |
+
demo.launch(share=True)
|
modules/rebalancing.py
CHANGED
@@ -160,6 +160,8 @@ def generate_rebalancing_analysis(portfolio, target_weights, total_value, main_c
|
|
160 |
|
161 |
# 전체 리밸런싱 후 새 포트폴리오 가치를 기반으로 비율 계산
|
162 |
total_new_stock_value = sum(adj[7] for adj in adjustments)
|
|
|
|
|
163 |
new_weights = {stock_code: (new_value / total_new_stock_value) * 100 for _, _, _, _, _, stock_code, _, new_value, _, _, _, _, _ in adjustments}
|
164 |
new_chart = plot_treemap(new_weights)
|
165 |
|
@@ -168,7 +170,7 @@ def generate_rebalancing_analysis(portfolio, target_weights, total_value, main_c
|
|
168 |
new_value_pct = (new_value / total_new_stock_value) * 100
|
169 |
adjustments[i] = (difference, current_value, target_weight, current_value_pct, trade_quantity, stock_code, price, new_value, trade_value, old_quantity, new_quantity, target_ratio, new_value_pct, currency)
|
170 |
|
171 |
-
cash_balance = new_total_value - total_new_stock_value
|
172 |
|
173 |
# 리밸런싱 분석 테이블 생성
|
174 |
result_message = f"""
|
@@ -181,7 +183,7 @@ def generate_rebalancing_analysis(portfolio, target_weights, total_value, main_c
|
|
181 |
<span style='font-size: 1.5rem; font-weight: bold; color: #1678fb'>{currency_symbol}{format_quantity(cash_balance)}</span>
|
182 |
cash balance
|
183 |
<hr style="margin: 1.5rem 0;">
|
184 |
-
<h3>
|
185 |
</div>
|
186 |
</div>
|
187 |
<br>
|
@@ -200,7 +202,7 @@ def generate_rebalancing_analysis(portfolio, target_weights, total_value, main_c
|
|
200 |
|
201 |
current_value_pct_str = f"{current_value_pct:.1f}%"
|
202 |
target_weight_str = f"<span class='highlight-edit'>{target_weight}</span>"
|
203 |
-
target_ratio_str = f"
|
204 |
trade_value_str = f"<span class='highlight-sky'>{format_quantity(trade_value)}</span>" if trade_value != 0 else ''
|
205 |
price_str = f"{currency_symbol}{price:,.0f}"
|
206 |
trade_quantity_str = f"<span class='highlight-sky'>{format_quantity(trade_quantity)}</span>" if trade_value != 0 else ''
|
|
|
160 |
|
161 |
# 전체 리밸런싱 후 새 포트폴리오 가치를 기반으로 비율 계산
|
162 |
total_new_stock_value = sum(adj[7] for adj in adjustments)
|
163 |
+
|
164 |
+
# 신규 상태 차트
|
165 |
new_weights = {stock_code: (new_value / total_new_stock_value) * 100 for _, _, _, _, _, stock_code, _, new_value, _, _, _, _, _ in adjustments}
|
166 |
new_chart = plot_treemap(new_weights)
|
167 |
|
|
|
170 |
new_value_pct = (new_value / total_new_stock_value) * 100
|
171 |
adjustments[i] = (difference, current_value, target_weight, current_value_pct, trade_quantity, stock_code, price, new_value, trade_value, old_quantity, new_quantity, target_ratio, new_value_pct, currency)
|
172 |
|
173 |
+
cash_balance = new_total_value - total_new_stock_value
|
174 |
|
175 |
# 리밸런싱 분석 테이블 생성
|
176 |
result_message = f"""
|
|
|
183 |
<span style='font-size: 1.5rem; font-weight: bold; color: #1678fb'>{currency_symbol}{format_quantity(cash_balance)}</span>
|
184 |
cash balance
|
185 |
<hr style="margin: 1.5rem 0;">
|
186 |
+
<h3>Adjusted Portfolio Allocation</h3>{new_chart}
|
187 |
</div>
|
188 |
</div>
|
189 |
<br>
|
|
|
202 |
|
203 |
current_value_pct_str = f"{current_value_pct:.1f}%"
|
204 |
target_weight_str = f"<span class='highlight-edit'>{target_weight}</span>"
|
205 |
+
target_ratio_str = f"{target_ratio * 100:.1f}%"
|
206 |
trade_value_str = f"<span class='highlight-sky'>{format_quantity(trade_value)}</span>" if trade_value != 0 else ''
|
207 |
price_str = f"{currency_symbol}{price:,.0f}"
|
208 |
trade_quantity_str = f"<span class='highlight-sky'>{format_quantity(trade_quantity)}</span>" if trade_value != 0 else ''
|
modules/utils.py
CHANGED
@@ -94,7 +94,7 @@ from io import BytesIO
|
|
94 |
import base64
|
95 |
|
96 |
def plot_treemap(data, color_map='viridis'):
|
97 |
-
labels =
|
98 |
sizes = list(data.values())
|
99 |
|
100 |
# 색상 맵을 설정
|
@@ -113,11 +113,11 @@ def plot_treemap(data, color_map='viridis'):
|
|
113 |
|
114 |
# 범례 생성
|
115 |
handles = [plt.Line2D([0], [0], marker='s', color='w', label=f'{label} ({size:.1f})',
|
116 |
-
markersize=
|
117 |
for label, size, color in zip(labels, sizes, colors)]
|
118 |
|
119 |
# 범례 추가, 제목 제거, 글자 크기를 키우고 범례 박스를 조정
|
120 |
-
ax.legend(handles=handles, loc='upper left', bbox_to_anchor=(1, 1), fontsize='
|
121 |
|
122 |
ax.set_xlim(0, 100)
|
123 |
ax.set_ylim(0, 100)
|
|
|
94 |
import base64
|
95 |
|
96 |
def plot_treemap(data, color_map='viridis'):
|
97 |
+
labels = [label.upper() for label in data.keys()] # 라벨을 대문자로 변환
|
98 |
sizes = list(data.values())
|
99 |
|
100 |
# 색상 맵을 설정
|
|
|
113 |
|
114 |
# 범례 생성
|
115 |
handles = [plt.Line2D([0], [0], marker='s', color='w', label=f'{label} ({size:.1f})',
|
116 |
+
markersize=50, markerfacecolor=color)
|
117 |
for label, size, color in zip(labels, sizes, colors)]
|
118 |
|
119 |
# 범례 추가, 제목 제거, 글자 크기를 키우고 범례 박스를 조정
|
120 |
+
ax.legend(handles=handles, loc='upper left', bbox_to_anchor=(1, 1), fontsize='35', frameon=False)
|
121 |
|
122 |
ax.set_xlim(0, 100)
|
123 |
ax.set_ylim(0, 100)
|
style.css
CHANGED
@@ -10,12 +10,25 @@
|
|
10 |
@import url('https://fonts.googleapis.com/css2?family=Baloo+Bhai+2:wght@400;700&display=swap');
|
11 |
@import url('https://fonts.googleapis.com/css2?family=Poor+Story&display=swap');
|
12 |
@import url("https://fonts.googleapis.com/css2?family=Source+Sans+Pro:wght@400;600&display=swap");
|
13 |
-
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
#col-container {
|
16 |
margin: 0 auto;
|
17 |
max-width: 100%;
|
18 |
-
font-family: '
|
19 |
text-transform: uppercase;
|
20 |
|
21 |
}
|
|
|
10 |
@import url('https://fonts.googleapis.com/css2?family=Baloo+Bhai+2:wght@400;700&display=swap');
|
11 |
@import url('https://fonts.googleapis.com/css2?family=Poor+Story&display=swap');
|
12 |
@import url("https://fonts.googleapis.com/css2?family=Source+Sans+Pro:wght@400;600&display=swap");
|
13 |
+
@import url('https://fonts.googleapis.com/css2?family=Patrick+Hand+SC&display=swap');
|
14 |
+
@import url('https://fonts.googleapis.com/css2?family=Luckiest+Guy&display=swap');
|
15 |
+
@import url('https://fonts.googleapis.com/css2?family=League+Spartan:wght@400;700&display=swap');
|
16 |
+
@import url('https://fonts.googleapis.com/css2?family=Edu+AU+VIC+WA+NT+Hand&display=swap');
|
17 |
+
@import url('https://fonts.googleapis.com/css2?family=Jost:wght@400;700&display=swap');
|
18 |
+
@import url('https://fonts.googleapis.com/css2?family=Quicksand:wght@300;400;500;700&display=swap');
|
19 |
+
@import url('https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;600;700&display=swap');
|
20 |
+
|
21 |
+
@font-face {
|
22 |
+
font-family: 'Gilroy';
|
23 |
+
src: url('Gilroy-Regular.otf') format('opentype');
|
24 |
+
font-weight: 400; /* Regular weight */
|
25 |
+
font-style: normal;
|
26 |
+
}
|
27 |
+
|
28 |
#col-container {
|
29 |
margin: 0 auto;
|
30 |
max-width: 100%;
|
31 |
+
font-family: 'Gilroy', 'Quicksand', 'ui-sans-serif', 'system-ui', 'sans-serif';
|
32 |
text-transform: uppercase;
|
33 |
|
34 |
}
|