数据同步页增加持仓天数展示,修复持仓同步无法拉取历史数据的问题
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -113,12 +113,6 @@ def sync_positions_bg(contract_code: str) -> bool:
|
||||
.filter(DailyBar.contract == code)
|
||||
.order_by(DailyBar.date).all()
|
||||
]
|
||||
# Only sync dates within or after existing position date range;
|
||||
# akshare may not have data for very old dates
|
||||
if existing_dates:
|
||||
min_pos = min(existing_dates)
|
||||
missing = [d for d in bar_dates if d not in existing_dates and d >= min_pos]
|
||||
else:
|
||||
missing = [d for d in bar_dates if d not in existing_dates]
|
||||
total_missing = len(missing)
|
||||
|
||||
|
||||
@@ -31,9 +31,16 @@ def admin_page(request: Request, db: Session = Depends(get_db)):
|
||||
.filter(DailyBar.contract == c.code)
|
||||
.count()
|
||||
)
|
||||
pos_days = len({
|
||||
r[0] for r in
|
||||
db.query(PositionRanking.date)
|
||||
.filter(PositionRanking.contract_code == c.code)
|
||||
.distinct().all()
|
||||
})
|
||||
contract_list.append({
|
||||
"id": c.id, "code": c.code, "name": c.name,
|
||||
"is_active": c.is_active, "bar_count": bar_count,
|
||||
"pos_days": pos_days,
|
||||
})
|
||||
|
||||
product_data.append({
|
||||
|
||||
@@ -59,11 +59,12 @@
|
||||
</div>
|
||||
<div class="product-body" style="display:none;">
|
||||
<table style="font-size:0.84rem;">
|
||||
<tr><th style="text-align:left;padding:8px 14px;">合约</th><th style="text-align:center;padding:8px 14px;">数据条数</th><th style="text-align:center;padding:8px 14px;">状态</th><th style="text-align:center;padding:8px 14px;">操作</th></tr>
|
||||
<tr><th style="text-align:left;padding:8px 14px;">合约</th><th style="text-align:center;padding:8px 14px;">行情</th><th style="text-align:center;padding:8px 14px;">持仓</th><th style="text-align:center;padding:8px 14px;">状态</th><th style="text-align:center;padding:8px 14px;">操作</th></tr>
|
||||
{% for c in p.contracts %}
|
||||
<tr>
|
||||
<td style="text-align:left;padding:6px 14px;"><strong>{{ c.code }}</strong></td>
|
||||
<td style="text-align:center;padding:6px 14px;">{{ c.bar_count }}</td>
|
||||
<td style="text-align:center;padding:6px 14px;">{{ c.pos_days }}</td>
|
||||
<td style="text-align:center;padding:6px 14px;">
|
||||
{% if c.is_active %}<span class="badge badge-up">启用</span>{% else %}<span class="badge badge-down">停用</span>{% endif %}
|
||||
</td>
|
||||
|
||||
Reference in New Issue
Block a user