update pay function

This commit is contained in:
2025-11-30 13:38:29 +08:00
parent 14ab2f62f3
commit 05aa0c89f0
9 changed files with 3972 additions and 59 deletions

View File

@@ -836,11 +836,22 @@ async def get_stock_minute_data(
try:
client = get_clickhouse_client()
# 标准化股票代码(去除后缀)
stock_code = code.split('.')[0] if '.' in code else code
# 标准化股票代码ClickHouse 分钟数据使用带后缀格式
# 6开头 -> .SH (上海), 0/3开头 -> .SZ (深圳), 其他 -> .BJ (北京)
if '.' in code:
# 已经有后缀,直接使用
stock_code = code
else:
# 需要添加后缀
if code.startswith('6'):
stock_code = f"{code}.SH"
elif code.startswith('0') or code.startswith('3'):
stock_code = f"{code}.SZ"
else:
stock_code = f"{code}.BJ"
# 构建查询
query = """
# 构建查询 - 使用字符串格式化ClickHouse 参数化语法兼容性问题)
query = f"""
SELECT
code,
timestamp,
@@ -851,24 +862,19 @@ async def get_stock_minute_data(
volume,
amt
FROM stock_minute
WHERE code = %(code)s
WHERE code = '{stock_code}'
"""
params = {'code': stock_code}
if start_time:
query += " AND timestamp >= %(start_time)s"
params['start_time'] = start_time
query += f" AND timestamp >= '{start_time}'"
if end_time:
query += " AND timestamp <= %(end_time)s"
params['end_time'] = end_time
query += f" AND timestamp <= '{end_time}'"
query += " ORDER BY timestamp DESC LIMIT %(limit)s"
params['limit'] = limit
query += f" ORDER BY timestamp DESC LIMIT {limit}"
# 执行查询
result = client.execute(query, params, with_column_types=True)
result = client.execute(query, with_column_types=True)
rows = result[0]
columns = [col[0] for col in result[1]]