community增加事件详情

This commit is contained in:
2026-01-08 17:27:29 +08:00
parent 955bf9e34b
commit e3b13324a3
2 changed files with 164 additions and 84 deletions

54
app.py
View File

@@ -10758,28 +10758,19 @@ def get_calendar_combined_data():
def get_zt_theme_scatter():
"""获取题材流星图数据(散点图)
基于词频关键词合并同义概念,统计最近5个交易日数据
基于词频关键词合并同义概念,统计指定日期的数据
参数:
date: 指定日期YYYYMMDD格式可选默认最新
days: 用于计算趋势的天数默认5
返回:
{
success: true,
data: {
latestDate: "2026-01-07",
themes: [
{
label: "光刻胶",
color: "#F59E0B",
x: 5, // 最高连板数(辨识度)
y: 12, // 涨停家数(热度)
countTrend: 3, // 较前日变化
boardTrend: 1, // 连板变化
status: "rising", // rising/declining/lurking/clustering
history: [...], // 5日历史数据
stocks: [...], // 今日涨停股票
matchedSectors: [] // 匹配的原始板块名
},
...
]
currentDate: "2026-01-07",
availableDates: ["20260107", "20260106", ...], // 可选日期列表
themes: [...]
}
}
"""
@@ -10808,8 +10799,9 @@ def get_zt_theme_scatter():
'增持', '回购', '解禁', '减持', '限售股', '转债']
try:
days = request.args.get('days', 5, type=int)
days = min(max(days, 1), 10) # 限制1-10天
target_date = request.args.get('date', '') # 指定日期
trend_days = request.args.get('days', 5, type=int)
trend_days = min(max(trend_days, 1), 10) # 限制1-10天
# 查找数据目录
possible_paths = [
@@ -10836,10 +10828,27 @@ def get_zt_theme_scatter():
with open(dates_file, 'r', encoding='utf-8') as f:
dates_data = json.load(f)
recent_dates = dates_data.get('dates', [])[:days]
all_dates = dates_data.get('dates', [])
if not all_dates:
return jsonify({'success': False, 'error': '无可用日期数据'}), 404
# 获取最近一个月的日期列表约22个交易日
available_dates = all_dates[:25]
# 确定当前查看的日期
if target_date:
# 找到目标日期在列表中的位置
target_idx = next((i for i, d in enumerate(all_dates) if d['date'] == target_date), 0)
else:
target_idx = 0 # 默认最新
# 获取从目标日期开始的 trend_days 天数据(用于计算趋势)
recent_dates = all_dates[target_idx:target_idx + trend_days]
if not recent_dates:
return jsonify({'success': False, 'error': '无可用日期数据'}), 404
current_date_info = recent_dates[0]
# 读取每日数据
daily_data_list = []
daily_dir = os.path.join(zt_dir, 'daily')
@@ -10893,7 +10902,7 @@ def get_zt_theme_scatter():
# 处理每个主题
themes = []
latest_date = daily_data_list[0]['formatted_date']
current_date = current_date_info.get('formatted_date', '')
for theme_config in THEME_KEYWORDS:
# 收集每日数据
@@ -10974,7 +10983,8 @@ def get_zt_theme_scatter():
return jsonify({
'success': True,
'data': {
'latestDate': latest_date,
'currentDate': current_date,
'availableDates': [{'date': d['date'], 'formatted': d['formatted_date']} for d in available_dates],
'themes': themes,
}
})