- STRUCTURE.md 添加 MarketDataView Panel 拆分记录 - 更新目录结构说明,包含 panels/ 子目录 - 更新 company.js 和 market.js mock 数据 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
198 lines
9.4 KiB
JavaScript
198 lines
9.4 KiB
JavaScript
// src/mocks/data/market.js
|
||
// 市场行情相关的 Mock 数据
|
||
|
||
// 生成市场数据
|
||
export const generateMarketData = (stockCode) => {
|
||
const basePrice = 13.50; // 基准价格(平安银行约13.5元)
|
||
|
||
return {
|
||
stockCode,
|
||
|
||
// 成交数据 - 必须包含K线所需的字段
|
||
tradeData: {
|
||
success: true,
|
||
data: Array(30).fill(null).map((_, i) => {
|
||
const open = basePrice + (Math.random() - 0.5) * 0.5;
|
||
const close = basePrice + (Math.random() - 0.5) * 0.5;
|
||
const high = Math.max(open, close) + Math.random() * 0.3;
|
||
const low = Math.min(open, close) - Math.random() * 0.3;
|
||
return {
|
||
date: new Date(Date.now() - (29 - i) * 24 * 60 * 60 * 1000).toISOString().split('T')[0],
|
||
open: parseFloat(open.toFixed(2)),
|
||
close: parseFloat(close.toFixed(2)),
|
||
high: parseFloat(high.toFixed(2)),
|
||
low: parseFloat(low.toFixed(2)),
|
||
volume: Math.floor(Math.random() * 500000000) + 100000000, // 1-6亿股
|
||
amount: Math.floor(Math.random() * 7000000000) + 1300000000, // 13-80亿元
|
||
turnover_rate: parseFloat((Math.random() * 2 + 0.5).toFixed(2)), // 0.5-2.5%
|
||
change_percent: parseFloat((Math.random() * 6 - 3).toFixed(2)), // -3% to +3%
|
||
pe_ratio: parseFloat((Math.random() * 3 + 4).toFixed(2)) // 4-7
|
||
};
|
||
})
|
||
},
|
||
|
||
// 资金流向 - 融资融券数据数组
|
||
fundingData: {
|
||
success: true,
|
||
data: Array(30).fill(null).map((_, i) => ({
|
||
date: new Date(Date.now() - (29 - i) * 24 * 60 * 60 * 1000).toISOString().split('T')[0],
|
||
financing: {
|
||
balance: Math.floor(Math.random() * 5000000000) + 10000000000, // 融资余额
|
||
buy: Math.floor(Math.random() * 500000000) + 100000000, // 融资买入
|
||
repay: Math.floor(Math.random() * 500000000) + 80000000 // 融资偿还
|
||
},
|
||
securities: {
|
||
balance: Math.floor(Math.random() * 100000000) + 50000000, // 融券余额
|
||
sell: Math.floor(Math.random() * 10000000) + 5000000, // 融券卖出
|
||
repay: Math.floor(Math.random() * 10000000) + 3000000 // 融券偿还
|
||
}
|
||
}))
|
||
},
|
||
|
||
// 大单统计 - 包含 daily_stats 数组
|
||
bigDealData: {
|
||
success: true,
|
||
data: [],
|
||
daily_stats: Array(10).fill(null).map((_, i) => ({
|
||
date: new Date(Date.now() - (9 - i) * 24 * 60 * 60 * 1000).toISOString().split('T')[0],
|
||
big_buy: Math.floor(Math.random() * 300000000) + 100000000,
|
||
big_sell: Math.floor(Math.random() * 300000000) + 80000000,
|
||
medium_buy: Math.floor(Math.random() * 200000000) + 60000000,
|
||
medium_sell: Math.floor(Math.random() * 200000000) + 50000000,
|
||
small_buy: Math.floor(Math.random() * 100000000) + 30000000,
|
||
small_sell: Math.floor(Math.random() * 100000000) + 25000000
|
||
}))
|
||
},
|
||
|
||
// 异动分析 - 包含 grouped_data 数组
|
||
unusualData: {
|
||
success: true,
|
||
data: [],
|
||
grouped_data: Array(5).fill(null).map((_, i) => ({
|
||
date: new Date(Date.now() - (4 - i) * 24 * 60 * 60 * 1000).toISOString().split('T')[0],
|
||
events: [
|
||
{ time: '14:35:22', type: '快速拉升', change: '+2.3%', description: '5分钟内上涨2.3%' },
|
||
{ time: '11:28:45', type: '大单买入', amount: '5680万', description: '单笔大单买入' },
|
||
{ time: '10:15:30', type: '量比异动', ratio: '3.2', description: '量比达到3.2倍' }
|
||
],
|
||
count: 3
|
||
}))
|
||
},
|
||
|
||
// 股权质押 - 匹配 PledgeData[] 类型
|
||
pledgeData: {
|
||
success: true,
|
||
data: Array(12).fill(null).map((_, i) => {
|
||
const date = new Date();
|
||
date.setMonth(date.getMonth() - (11 - i));
|
||
return {
|
||
end_date: date.toISOString().split('T')[0].slice(0, 7) + '-01',
|
||
unrestricted_pledge: Math.floor(Math.random() * 1000000000) + 500000000,
|
||
restricted_pledge: Math.floor(Math.random() * 200000000) + 50000000,
|
||
total_pledge: Math.floor(Math.random() * 1200000000) + 550000000,
|
||
total_shares: 19405918198,
|
||
pledge_ratio: parseFloat((Math.random() * 3 + 6).toFixed(2)), // 6-9%
|
||
pledge_count: Math.floor(Math.random() * 50) + 100 // 100-150
|
||
};
|
||
})
|
||
},
|
||
|
||
// 市场摘要 - 匹配 MarketSummary 类型
|
||
summaryData: {
|
||
success: true,
|
||
data: {
|
||
stock_code: stockCode,
|
||
stock_name: stockCode === '000001' ? '平安银行' : '示例股票',
|
||
latest_trade: {
|
||
close: basePrice,
|
||
change_percent: 1.89,
|
||
volume: 345678900,
|
||
amount: 4678900000,
|
||
turnover_rate: 1.78,
|
||
pe_ratio: 4.96
|
||
},
|
||
latest_funding: {
|
||
financing_balance: 5823000000,
|
||
securities_balance: 125600000
|
||
},
|
||
latest_pledge: {
|
||
pledge_ratio: 8.25
|
||
}
|
||
}
|
||
},
|
||
|
||
// 涨停分析 - 返回数组格式,每个元素对应一个交易日
|
||
riseAnalysisData: {
|
||
success: true,
|
||
data: Array(30).fill(null).map((_, i) => {
|
||
const tradeDate = new Date(Date.now() - (29 - i) * 24 * 60 * 60 * 1000).toISOString().split('T')[0];
|
||
const isLimitUp = Math.random() < 0.05; // 5%概率涨停
|
||
return {
|
||
trade_date: tradeDate,
|
||
is_limit_up: isLimitUp,
|
||
limit_up_price: (basePrice * 1.10).toFixed(2),
|
||
current_price: (basePrice + (Math.random() - 0.5) * 0.5).toFixed(2),
|
||
distance_to_limit: (Math.random() * 10).toFixed(2), // %
|
||
consecutive_days: isLimitUp ? Math.floor(Math.random() * 3) + 1 : 0,
|
||
reason: isLimitUp ? '业绩超预期' : '',
|
||
concept_tags: ['银行', '深圳国资', 'MSCI', '沪深300'],
|
||
analysis: isLimitUp ? '股价触及涨停板,资金流入明显' : '股价正常波动,交投活跃'
|
||
};
|
||
})
|
||
},
|
||
|
||
// 最新分时数据 - 匹配 MinuteData 类型
|
||
latestMinuteData: {
|
||
success: true,
|
||
data: (() => {
|
||
const minuteData = [];
|
||
// 上午 9:30-11:30 (120分钟)
|
||
for (let i = 0; i < 120; i++) {
|
||
const hour = 9 + Math.floor((30 + i) / 60);
|
||
const min = (30 + i) % 60;
|
||
const time = `${hour.toString().padStart(2, '0')}:${min.toString().padStart(2, '0')}`;
|
||
const randomChange = (Math.random() - 0.5) * 0.1;
|
||
const open = parseFloat((basePrice + randomChange).toFixed(2));
|
||
const close = parseFloat((basePrice + randomChange + (Math.random() - 0.5) * 0.05).toFixed(2));
|
||
const high = parseFloat(Math.max(open, close, open + Math.random() * 0.05).toFixed(2));
|
||
const low = parseFloat(Math.min(open, close, close - Math.random() * 0.05).toFixed(2));
|
||
minuteData.push({
|
||
time,
|
||
open,
|
||
close,
|
||
high,
|
||
low,
|
||
volume: Math.floor(Math.random() * 2000000) + 500000,
|
||
amount: Math.floor(Math.random() * 30000000) + 5000000
|
||
});
|
||
}
|
||
// 下午 13:00-15:00 (120分钟)
|
||
for (let i = 0; i < 120; i++) {
|
||
const hour = 13 + Math.floor(i / 60);
|
||
const min = i % 60;
|
||
const time = `${hour.toString().padStart(2, '0')}:${min.toString().padStart(2, '0')}`;
|
||
const randomChange = (Math.random() - 0.5) * 0.1;
|
||
const open = parseFloat((basePrice + randomChange).toFixed(2));
|
||
const close = parseFloat((basePrice + randomChange + (Math.random() - 0.5) * 0.05).toFixed(2));
|
||
const high = parseFloat(Math.max(open, close, open + Math.random() * 0.05).toFixed(2));
|
||
const low = parseFloat(Math.min(open, close, close - Math.random() * 0.05).toFixed(2));
|
||
minuteData.push({
|
||
time,
|
||
open,
|
||
close,
|
||
high,
|
||
low,
|
||
volume: Math.floor(Math.random() * 1500000) + 400000,
|
||
amount: Math.floor(Math.random() * 25000000) + 4000000
|
||
});
|
||
}
|
||
return minuteData;
|
||
})(),
|
||
code: stockCode,
|
||
name: stockCode === '000001' ? '平安银行' : '示例股票',
|
||
trade_date: new Date().toISOString().split('T')[0],
|
||
type: '1min'
|
||
}
|
||
};
|
||
};
|