增加主力数据
This commit is contained in:
28
app.py
28
app.py
@@ -9123,11 +9123,10 @@ def get_stock_quote_detail(stock_code):
|
||||
'week52_high': None,
|
||||
'week52_low': None,
|
||||
|
||||
# 主力动态(预留字段)
|
||||
'main_net_inflow': None,
|
||||
'institution_holding': None,
|
||||
'buy_ratio': None,
|
||||
'sell_ratio': None,
|
||||
# 主力动态(数据来源:stock_main_capital_flow 表)
|
||||
'net_inflow': None, # 主力净流入量(万元)
|
||||
'main_inflow_ratio': None, # 主力净流入量占比(%)
|
||||
'net_active_buy_ratio': None, # 净主动买入额占比(%)
|
||||
|
||||
'update_time': None
|
||||
}
|
||||
@@ -9211,6 +9210,25 @@ def get_stock_quote_detail(stock_code):
|
||||
result_data['week52_high'] = float(w52.get('week52_high') or 0)
|
||||
result_data['week52_low'] = float(w52.get('week52_low') or 0)
|
||||
|
||||
# 3. 获取主力资金流向数据(取最新交易日)
|
||||
capital_flow_query = text("""
|
||||
SELECT
|
||||
net_inflow,
|
||||
net_active_buy_ratio,
|
||||
main_inflow_ratio
|
||||
FROM stock_main_capital_flow
|
||||
WHERE code = :stock_code
|
||||
ORDER BY trade_date DESC
|
||||
LIMIT 1
|
||||
""")
|
||||
|
||||
capital_flow_result = conn.execute(capital_flow_query, {'stock_code': base_code}).fetchone()
|
||||
if capital_flow_result:
|
||||
cf = row_to_dict(capital_flow_result)
|
||||
result_data['net_inflow'] = float(cf.get('net_inflow') or 0) if cf.get('net_inflow') is not None else None
|
||||
result_data['main_inflow_ratio'] = float(cf.get('main_inflow_ratio') or 0) if cf.get('main_inflow_ratio') is not None else None
|
||||
result_data['net_active_buy_ratio'] = float(cf.get('net_active_buy_ratio') or 0) if cf.get('net_active_buy_ratio') is not None else None
|
||||
|
||||
return jsonify({
|
||||
'success': True,
|
||||
'data': result_data
|
||||
|
||||
Reference in New Issue
Block a user