feat(mock): 市场统计 API 增加昨日对比数据
- /api/market/statistics 返回 yesterday 字段 - 包含昨日市值、成交额、涨跌家数 - 支持前端计算环比变化率 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -582,19 +582,38 @@ export const marketHandlers = [
|
||||
|
||||
console.log('[Mock Market] 获取市场统计数据:', { date: tradeDate });
|
||||
|
||||
// 生成今日数据
|
||||
const todayMarketCap = parseFloat((Math.random() * 5000 + 80000).toFixed(2));
|
||||
const todayAmount = parseFloat((Math.random() * 3000 + 8000).toFixed(2));
|
||||
const todayRising = Math.floor(Math.random() * 1500 + 1500);
|
||||
const todayFalling = Math.floor(Math.random() * 1500 + 1000);
|
||||
|
||||
// 生成昨日数据(用于对比)
|
||||
const yesterdayMarketCap = parseFloat((todayMarketCap * (0.98 + Math.random() * 0.04)).toFixed(2));
|
||||
const yesterdayAmount = parseFloat((todayAmount * (0.85 + Math.random() * 0.3)).toFixed(2));
|
||||
const yesterdayRising = Math.floor(todayRising * (0.7 + Math.random() * 0.6));
|
||||
const yesterdayFalling = Math.floor(todayFalling * (0.7 + Math.random() * 0.6));
|
||||
|
||||
return HttpResponse.json({
|
||||
success: true,
|
||||
summary: {
|
||||
total_market_cap: parseFloat((Math.random() * 5000 + 80000).toFixed(2)), // 80000-85000亿
|
||||
total_amount: parseFloat((Math.random() * 3000 + 8000).toFixed(2)), // 8000-11000亿
|
||||
avg_pe: parseFloat((Math.random() * 5 + 12).toFixed(2)), // 12-17
|
||||
avg_pb: parseFloat((Math.random() * 0.5 + 1.3).toFixed(2)), // 1.3-1.8
|
||||
rising_stocks: Math.floor(Math.random() * 1500 + 1500), // 1500-3000
|
||||
falling_stocks: Math.floor(Math.random() * 1500 + 1000), // 1000-2500
|
||||
unchanged_stocks: Math.floor(Math.random() * 200 + 100) // 100-300
|
||||
total_market_cap: todayMarketCap,
|
||||
total_amount: todayAmount,
|
||||
avg_pe: parseFloat((Math.random() * 5 + 12).toFixed(2)),
|
||||
avg_pb: parseFloat((Math.random() * 0.5 + 1.3).toFixed(2)),
|
||||
rising_stocks: todayRising,
|
||||
falling_stocks: todayFalling,
|
||||
unchanged_stocks: Math.floor(Math.random() * 200 + 100)
|
||||
},
|
||||
// 昨日对比数据
|
||||
yesterday: {
|
||||
total_market_cap: yesterdayMarketCap,
|
||||
total_amount: yesterdayAmount,
|
||||
rising_stocks: yesterdayRising,
|
||||
falling_stocks: yesterdayFalling
|
||||
},
|
||||
trade_date: tradeDate,
|
||||
available_dates: availableDates.slice(0, 20) // 返回最近20个交易日
|
||||
available_dates: availableDates.slice(0, 20)
|
||||
});
|
||||
}),
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user