fix: 修复6个数据和代码问题

1. 修复 _generate_plain_summary position key 不匹配 (20d→d20, pct→range_pct)
2. 修复 mairui_api.py 日期解析不一致及 float(None) 崩溃风险
3. 修复 fund_flow_analyzer.py 麦蕊回退数据 close_price=0 导致量价背离误判
4. 修复 db_get_fund_flow_history 缺少完整字段和日期过滤
5. 修复 scheduler.py 连接池泄漏 (conn.close() → put_db(conn))
6. 修复多处北交所股票代码映射缺失 (8/9开头→bj)
This commit is contained in:
freedakgmail
2026-07-22 07:20:44 +08:00
parent 9a5e24ccd6
commit 40ce519188
7 changed files with 84 additions and 37 deletions
+4 -2
View File
@@ -45,7 +45,7 @@ def get_stock_name(stock_code):
# 腾讯财经API获取股票名称
try:
import requests as _req
tcode = ('sh' if stock_code.startswith('6') else 'sz') + stock_code
tcode = ('sh' if stock_code.startswith('6') else 'bj' if stock_code.startswith(('8', '9')) else 'sz') + stock_code
_r = _req.get(f'http://qt.gtimg.cn/q={tcode}', timeout=5,
headers={'Referer': 'https://finance.qq.com'})
if _r.status_code == 200 and '\"' in _r.text:
@@ -119,6 +119,8 @@ def get_stock_fund_flow(stock_code, start_date, end_date, force_refresh=False):
market = 'sh'
elif stock_code.startswith('0') or stock_code.startswith('3'):
market = 'sz'
elif stock_code.startswith('8') or stock_code.startswith('9'):
market = 'bj'
else:
return None, None, "无法识别股票代码所属市场"
@@ -313,7 +315,7 @@ def get_realtime_price(stock_code):
# 备用方案2:使用腾讯财经API(腾讯云可用)
try:
import requests as _req
tcode = ('sh' if stock_code.startswith('6') else 'sz') + stock_code
tcode = ('sh' if stock_code.startswith('6') else 'bj' if stock_code.startswith(('8', '9')) else 'sz') + stock_code
_r = _req.get(f'http://qt.gtimg.cn/q={tcode}', timeout=5,
headers={'Referer': 'https://finance.qq.com'})
if _r.status_code == 200 and '\"' in _r.text: