功能细节优化

This commit is contained in:
2026-06-15 01:26:39 +08:00
parent e524a3589a
commit 964c17c200
33 changed files with 6990 additions and 210 deletions

View File

@@ -12,7 +12,7 @@ import akshare_service as svc
import config
from db import get_session
from models import (DailyQuote, DragonTiger, FundFlowDaily, IndexDaily, JobRun,
SectorDaily, Security, SentimentDaily, StockMetric)
SectorDaily, SectorLeader, Security, SentimentDaily, StockMetric)
try:
import akshare as ak
@@ -229,6 +229,25 @@ def ingest_sectors():
return n
def ingest_sector_leaders():
"""入库各板块前5龙头股按成交额"""
d = _today()
data = svc.get_all_sector_leaders(top_n=5)
rows = []
for sector, stocks in data.get("sectors", {}).items():
for i, s in enumerate(stocks):
rows.append({"date": d, "sector": sector, "code": s["code"],
"name": s["name"], "pct": s["pct"],
"price": s["price"], "amount": s["amount"], "rank": i + 1})
if not rows:
return 0
with get_session() as s:
n = _upsert(s, SectorLeader, rows, ["date", "sector", "code"],
["name", "pct", "price", "amount", "rank"])
s.commit()
return n
def ingest_fund_flow():
data = svc.get_fund_flow()
d = _today()
@@ -280,6 +299,7 @@ def run_daily_ingest(universe=None, with_quotes=True):
summary["securities"] = ingest_securities()
summary["indices"] = ingest_indices()
summary["sectors"] = ingest_sectors()
summary["sector_leaders"] = ingest_sector_leaders()
summary["fund_flow"] = ingest_fund_flow()
summary["sentiment"] = ingest_sentiment()
summary["dragon"] = ingest_dragon()