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
+12 -8
View File
@@ -245,17 +245,21 @@ def get_fund_flow(stock_code, days=3):
flow_data = []
for item in data:
# 计算主力净流入 = 主买大单+主买特大单 - 主卖大单-主卖特大单
main_buy = float(item.get('zmbddcje', 0)) + float(item.get('zmbtdcje', 0))
main_sell = float(item.get('zmsddcje', 0)) + float(item.get('zmstdcje', 0))
main_buy = float(item.get('zmbddcje', 0) or 0) + float(item.get('zmbtdcje', 0) or 0)
main_sell = float(item.get('zmsddcje', 0) or 0) + float(item.get('zmstdcje', 0) or 0)
main_net = main_buy - main_sell
# 日期解析:与 fund_flow_analyzer.py 保持一致,用字符串截取
t_str = str(item.get('t', ''))
date_str = t_str[:10] if t_str else ''
flow_data.append({
'date': datetime.fromtimestamp(item.get('t', 0)).strftime('%Y-%m-%d') if item.get('t') else '',
'date': date_str,
'main_net_inflow': main_net,
'super_buy': float(item.get('zmbtdcje', 0)),
'super_sell': float(item.get('zmstdcje', 0)),
'big_buy': float(item.get('zmbddcje', 0)),
'big_sell': float(item.get('zmsddcje', 0)),
'super_buy': float(item.get('zmbtdcje', 0) or 0),
'super_sell': float(item.get('zmstdcje', 0) or 0),
'big_buy': float(item.get('zmbddcje', 0) or 0),
'big_sell': float(item.get('zmsddcje', 0) or 0),
})
return {'success': True, 'data': flow_data}