update
This commit is contained in:
+37
-2
@@ -302,6 +302,22 @@ class _DataStore:
|
||||
elif ot == 24 and '空' not in tags: tags.append('空')
|
||||
return tags
|
||||
|
||||
def pool_action_tags(self, stock_code: str) -> list[str]:
|
||||
"""某标的的股票池待执行标记(eliminate/liquidate)"""
|
||||
plain = _plain(stock_code)
|
||||
from core.scoring.models import PendingPoolAction
|
||||
rows = list(PendingPoolAction
|
||||
.select(PendingPoolAction.action_type)
|
||||
.where(PendingPoolAction.stock_code == plain)
|
||||
.dicts())
|
||||
tags = []
|
||||
for r in rows:
|
||||
if r['action_type'] == 'eliminate' and '淘汰' not in tags:
|
||||
tags.append('淘汰')
|
||||
elif r['action_type'] == 'liquidate' and '沉寂' not in tags:
|
||||
tags.append('沉寂')
|
||||
return tags
|
||||
|
||||
|
||||
# ══════════════════════════════════════════════════════════════
|
||||
# GridPanel — 网格策略持仓表格
|
||||
@@ -326,7 +342,7 @@ class _GridPanel:
|
||||
|
||||
def _rebuild(self):
|
||||
# (width, expand): 0=固定宽, >0=弹性比重; 新增排名列(50px)
|
||||
_C = [(35, 0), (0, 2), (70, 1), (0, 2), (50, 1), (55, 1), (50, 0), (60, 1), (0, 1)]
|
||||
_C = [(35, 0), (0, 2), (70, 1), (80, 1), (50, 1), (55, 1), (50, 0), (60, 1), (0, 1)]
|
||||
H = ["ID", "股票", "市场价", "网格基准", "持仓", "成本", "排名", "状态", "操作"]
|
||||
header = []
|
||||
for h, (w, e) in zip(H, _C):
|
||||
@@ -414,7 +430,26 @@ class _GridPanel:
|
||||
on_click=lambda e, tt=t: self._dialogs.confirm_remove(tt)),
|
||||
]
|
||||
|
||||
cells_text = [str(tid), f'{t.stock_code} {t.stock_name}',
|
||||
# 股票列:名称 + 标记标签
|
||||
pool_tags = self._data.pool_action_tags(t.stock_code)
|
||||
tag_chips = []
|
||||
if pool_tags:
|
||||
# 有淘汰/沉寂时,显示操作标签,不显示默认标签
|
||||
for tag in pool_tags:
|
||||
color = '#E67E22' if tag == '淘汰' else '#E74C3C'
|
||||
tag_chips.append(ft.Container(
|
||||
_text(tag, color='white', bold=True, size=10),
|
||||
bgcolor=color, border_radius=4, padding=ft.Padding(2, 1, 2, 1),
|
||||
))
|
||||
else:
|
||||
# 无操作标签时,显示默认"网格"标签
|
||||
tag_chips.append(ft.Container(
|
||||
_text('网格', color='white', bold=True, size=10),
|
||||
bgcolor='#2E7D32', border_radius=4, padding=ft.Padding(2, 1, 2, 1),
|
||||
))
|
||||
name_cell = ft.Row([_text(f'{t.stock_code} {t.stock_name}')] + tag_chips, spacing=4)
|
||||
|
||||
cells_text = [str(tid), name_cell,
|
||||
f'{mp:.3f}', gcell,
|
||||
str(t.current_position),
|
||||
f'{self._data.avgPrices.get(tid, 0):.3f}',
|
||||
|
||||
Reference in New Issue
Block a user