update pay ui

This commit is contained in:
2025-12-02 19:44:46 +08:00
parent dbc99fe492
commit 2feb4938c1
4 changed files with 16 additions and 42 deletions

15
app.py
View File

@@ -5913,11 +5913,12 @@ def get_stock_quotes():
# 使用 IN 子句一次查询所有股票,避免逐只循环查询
try:
# 批量查询价格和涨跌幅数据(使用窗口函数)
# 涨跌幅基于当日开盘价计算:(最新价 - 开盘价) / 开盘价 * 100
batch_price_query = """
WITH first_prices AS (
WITH open_prices AS (
SELECT
code,
close as first_price,
open as open_price,
ROW_NUMBER() OVER (PARTITION BY code ORDER BY timestamp ASC) as rn
FROM stock_minute
WHERE code IN %(codes)s
@@ -5935,12 +5936,12 @@ def get_stock_quotes():
AND timestamp <= %(end)s
)
SELECT
fp.code,
op.code,
lp.last_price,
(lp.last_price - fp.first_price) / fp.first_price * 100 as change_pct
FROM first_prices fp
INNER JOIN last_prices lp ON fp.code = lp.code
WHERE fp.rn = 1 AND lp.rn = 1
(lp.last_price - op.open_price) / op.open_price * 100 as change_pct
FROM open_prices op
INNER JOIN last_prices lp ON op.code = lp.code
WHERE op.rn = 1 AND lp.rn = 1
"""
batch_data = client.execute(batch_price_query, {