合约数据按日期倒序排列,最新在最前

This commit is contained in:
2026-07-24 22:24:39 +08:00
parent e65661ef94
commit 58e3e98031
2 changed files with 3 additions and 3 deletions
+2 -2
View File
@@ -59,7 +59,7 @@ def contract_detail(request: Request, contract: str, db: Session = Depends(get_d
bars = (
db.query(DailyBar)
.filter(DailyBar.contract == contract.upper())
.order_by(DailyBar.date)
.order_by(DailyBar.date.desc())
.all()
)
@@ -77,7 +77,7 @@ def contract_detail(request: Request, contract: str, db: Session = Depends(get_d
"has_amp": bar.amp_5d is not None,
})
latest = bars[-1] if bars else None
latest = bars[0] if bars else None
template = request.app.state.templates.get_template("contract.html")
return HTMLResponse(
+1 -1
View File
@@ -37,7 +37,7 @@
<table id="bars-table">
<tr><th>日期</th><th>星期</th><th>开盘</th><th>收盘</th><th>最高</th><th>最低</th><th>波幅</th><th>5日均振幅</th></tr>
{% for row in rows %}
<tr data-index="{{ loop.index0 }}" data-diff="{{ row.diff }}" data-date="{{ row.date }}" data-weekday="{{ row.weekday }}"{% if loop.revindex0 >= 7 %} class="extra-row" style="display:none;"{% endif %}>
<tr data-index="{{ loop.index0 }}" data-diff="{{ row.diff }}" data-date="{{ row.date }}" data-weekday="{{ row.weekday }}"{% if loop.index0 >= 7 %} class="extra-row" style="display:none;"{% endif %}>
<td>{{ row.date }}</td>
<td>{{ row.weekday }}</td>
<td>{{ row.open }}</td>