Spaces:
Running
Running
Upload rebalancing.py
Browse files- modules/rebalancing.py +7 -7
modules/rebalancing.py
CHANGED
@@ -200,8 +200,8 @@ def generate_rebalancing_analysis(portfolio, target_ratios, total_value, main_cu
|
|
200 |
Buy_or_Sell = f"<span></span>"
|
201 |
|
202 |
# highlight-sky 鞝侅毄 鞐秬 瓴办爼
|
203 |
-
trade_value_display = f"
|
204 |
-
trade_quantity_display = f"
|
205 |
|
206 |
new_value = current_value + trade_value
|
207 |
new_quantity = stock_data['quantity'] + trade_quantity
|
@@ -252,7 +252,7 @@ def generate_rebalancing_analysis(portfolio, target_ratios, total_value, main_cu
|
|
252 |
<th class="table-header-bg-after">% Asset Allocation</th>
|
253 |
</tr>
|
254 |
<tr style="font-weight: bold;">
|
255 |
-
<td>Total</td>
|
256 |
<td>{format_value(sum(adj['current_value'] for adj in adjustments))}</td>
|
257 |
<td>{sum(adj['current_value'] for adj in adjustments) / total_value * 100:.1f}%</td>
|
258 |
<td></td>
|
@@ -267,14 +267,14 @@ def generate_rebalancing_analysis(portfolio, target_ratios, total_value, main_cu
|
|
267 |
<tbody>
|
268 |
{''.join(
|
269 |
f"<tr>"
|
270 |
-
f"<td>{adj['stock_code'].upper()}</td>"
|
271 |
f"<td>{format_value(adj['current_value'])}</td>"
|
272 |
f"<td>{adj['current_value_pct'] * 100:.1f}%</td>"
|
273 |
-
f"<td style='text-align: center !important;'
|
274 |
f"<td style='text-align: center !important;'>{adj['Buy_or_Sell']}</td>"
|
275 |
-
f"<td>{adj['trade_value_display']}</td>"
|
276 |
f"<td>{adj['price']:,.2f}</td>"
|
277 |
-
f"<td>{adj['trade_quantity_display']}</td>"
|
278 |
f"<td>{format_value(adj['new_value'])}</td>"
|
279 |
f"<td>{adj['new_value_pct'] * 100:.1f}%</td>"
|
280 |
f"</tr>"
|
|
|
200 |
Buy_or_Sell = f"<span></span>"
|
201 |
|
202 |
# highlight-sky 鞝侅毄 鞐秬 瓴办爼
|
203 |
+
trade_value_display = f"{format_value(trade_value)}" if trade_value != 0 else ""
|
204 |
+
trade_quantity_display = f"{format_quantity(trade_quantity)}" if trade_quantity != 0 else ""
|
205 |
|
206 |
new_value = current_value + trade_value
|
207 |
new_quantity = stock_data['quantity'] + trade_quantity
|
|
|
252 |
<th class="table-header-bg-after">% Asset Allocation</th>
|
253 |
</tr>
|
254 |
<tr style="font-weight: bold;">
|
255 |
+
<td style='text-align: left !important;'>Total</td>
|
256 |
<td>{format_value(sum(adj['current_value'] for adj in adjustments))}</td>
|
257 |
<td>{sum(adj['current_value'] for adj in adjustments) / total_value * 100:.1f}%</td>
|
258 |
<td></td>
|
|
|
267 |
<tbody>
|
268 |
{''.join(
|
269 |
f"<tr>"
|
270 |
+
f"<td style='text-align: left !important;'>{adj['stock_code'].upper()}</td>"
|
271 |
f"<td>{format_value(adj['current_value'])}</td>"
|
272 |
f"<td>{adj['current_value_pct'] * 100:.1f}%</td>"
|
273 |
+
f"<td class='table-data-bg-edit' style='text-align: center !important;'>{adj['target_weight'] * 100:.0f}%</td>"
|
274 |
f"<td style='text-align: center !important;'>{adj['Buy_or_Sell']}</td>"
|
275 |
+
f"<td class='table-data-bg-sky'>{adj['trade_value_display']}</td>"
|
276 |
f"<td>{adj['price']:,.2f}</td>"
|
277 |
+
f"<td class='table-data-bg-sky'>{adj['trade_quantity_display']}</td>"
|
278 |
f"<td>{format_value(adj['new_value'])}</td>"
|
279 |
f"<td>{adj['new_value_pct'] * 100:.1f}%</td>"
|
280 |
f"</tr>"
|