update pay ui
This commit is contained in:
58
app.py
58
app.py
@@ -4334,8 +4334,12 @@ def get_watchlist_realtime():
|
||||
raw_code = str(code).strip().upper()
|
||||
if '.' in raw_code:
|
||||
stock_code_full = raw_code
|
||||
elif raw_code.startswith('6'):
|
||||
stock_code_full = f"{raw_code}.SH" # 上海
|
||||
elif raw_code.startswith(('8', '9', '4')):
|
||||
stock_code_full = f"{raw_code}.BJ" # 北交所
|
||||
else:
|
||||
stock_code_full = f"{raw_code}.SH" if raw_code.startswith('6') else f"{raw_code}.SZ"
|
||||
stock_code_full = f"{raw_code}.SZ" # 深圳
|
||||
|
||||
# 获取最新分钟线数据(先查近7天,若无数据再兜底倒序取最近一条)
|
||||
query = """
|
||||
@@ -6881,7 +6885,12 @@ def get_stock_kline(stock_code):
|
||||
|
||||
# 确保股票代码包含后缀(ClickHouse 中数据带后缀)
|
||||
if '.' not in stock_code:
|
||||
stock_code = f"{stock_code}.SH" if stock_code.startswith('6') else f"{stock_code}.SZ"
|
||||
if stock_code.startswith('6'):
|
||||
stock_code = f"{stock_code}.SH" # 上海
|
||||
elif stock_code.startswith(('8', '9', '4')):
|
||||
stock_code = f"{stock_code}.BJ" # 北交所
|
||||
else:
|
||||
stock_code = f"{stock_code}.SZ" # 深圳
|
||||
|
||||
# 获取股票名称
|
||||
with engine.connect() as conn:
|
||||
@@ -6932,11 +6941,13 @@ def get_batch_kline_data():
|
||||
"""将股票代码标准化为带后缀格式(如 300274.SZ)"""
|
||||
if '.' in code:
|
||||
return code # 已经带后缀
|
||||
# 根据代码规则添加后缀:6开头为上海,其他为深圳
|
||||
if code.startswith(('6',)):
|
||||
return f"{code}.SH"
|
||||
# 根据代码规则添加后缀
|
||||
if code.startswith('6'):
|
||||
return f"{code}.SH" # 上海
|
||||
elif code.startswith(('8', '9', '4')):
|
||||
return f"{code}.BJ" # 北交所
|
||||
else:
|
||||
return f"{code}.SZ"
|
||||
return f"{code}.SZ" # 深圳
|
||||
|
||||
# 保留原始代码用于返回结果,同时创建标准化代码用于 ClickHouse 查询
|
||||
original_codes = codes
|
||||
@@ -7167,7 +7178,12 @@ def get_latest_minute_data(stock_code):
|
||||
|
||||
# 确保股票代码包含后缀
|
||||
if '.' not in stock_code:
|
||||
stock_code = f"{stock_code}.SH" if stock_code.startswith('6') else f"{stock_code}.SZ"
|
||||
if stock_code.startswith('6'):
|
||||
stock_code = f"{stock_code}.SH" # 上海
|
||||
elif stock_code.startswith(('8', '9', '4')):
|
||||
stock_code = f"{stock_code}.BJ" # 北交所
|
||||
else:
|
||||
stock_code = f"{stock_code}.SZ" # 深圳
|
||||
|
||||
# 获取股票名称
|
||||
with engine.connect() as conn:
|
||||
@@ -14443,7 +14459,12 @@ def get_latest_price_from_clickhouse(stock_code):
|
||||
|
||||
# 确保stock_code包含后缀
|
||||
if '.' not in stock_code:
|
||||
stock_code = f"{stock_code}.SH" if stock_code.startswith('6') else f"{stock_code}.SZ"
|
||||
if stock_code.startswith('6'):
|
||||
stock_code = f"{stock_code}.SH" # 上海
|
||||
elif stock_code.startswith(('8', '9', '4')):
|
||||
stock_code = f"{stock_code}.BJ" # 北交所
|
||||
else:
|
||||
stock_code = f"{stock_code}.SZ" # 深圳
|
||||
|
||||
# 1. 首先尝试获取最新的分钟数据(近30天)
|
||||
minute_query = """
|
||||
@@ -14506,7 +14527,12 @@ def get_next_minute_price(stock_code, order_time):
|
||||
|
||||
# 确保stock_code包含后缀
|
||||
if '.' not in stock_code:
|
||||
stock_code = f"{stock_code}.SH" if stock_code.startswith('6') else f"{stock_code}.SZ"
|
||||
if stock_code.startswith('6'):
|
||||
stock_code = f"{stock_code}.SH" # 上海
|
||||
elif stock_code.startswith(('8', '9', '4')):
|
||||
stock_code = f"{stock_code}.BJ" # 北交所
|
||||
else:
|
||||
stock_code = f"{stock_code}.SZ" # 深圳
|
||||
|
||||
# 获取下单后一分钟内的数据
|
||||
query = """
|
||||
@@ -14577,7 +14603,12 @@ def validate_and_get_stock_info(stock_input):
|
||||
if code6:
|
||||
# 如果能解析出6位代码,查询股票名称
|
||||
stock_name = name_from_input or _query_stock_name_by_code(code6)
|
||||
stock_code_full = f"{code6}.SH" if code6.startswith('6') else f"{code6}.SZ"
|
||||
if code6.startswith('6'):
|
||||
stock_code_full = f"{code6}.SH" # 上海
|
||||
elif code6.startswith(('8', '9', '4')):
|
||||
stock_code_full = f"{code6}.BJ" # 北交所
|
||||
else:
|
||||
stock_code_full = f"{code6}.SZ" # 深圳
|
||||
return stock_code_full, code6, stock_name
|
||||
|
||||
# 如果不是标准代码格式,尝试搜索
|
||||
@@ -14602,7 +14633,12 @@ def validate_and_get_stock_info(stock_input):
|
||||
if result:
|
||||
code6 = result.stock_code
|
||||
stock_name = result.stock_name
|
||||
stock_code_full = f"{code6}.SH" if code6.startswith('6') else f"{code6}.SZ"
|
||||
if code6.startswith('6'):
|
||||
stock_code_full = f"{code6}.SH" # 上海
|
||||
elif code6.startswith(('8', '9', '4')):
|
||||
stock_code_full = f"{code6}.BJ" # 北交所
|
||||
else:
|
||||
stock_code_full = f"{code6}.SZ" # 深圳
|
||||
return stock_code_full, code6, stock_name
|
||||
|
||||
return None, None, None
|
||||
|
||||
Reference in New Issue
Block a user