合约数据按日期倒序排列,最新在最前
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user