You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

223 lines
7.0 KiB

// 模拟数据
// 期货品种列表
export const futuresList = [
// 金属类
{ code: 'AU', name: '金', type: '金属' },
{ code: 'AG', name: '银', type: '金属' },
{ code: 'CU', name: '铜', type: '金属' },
{ code: 'NI', name: '镍', type: '金属' },
{ code: 'SN', name: '锡', type: '金属' },
{ code: 'AL', name: '铝', type: '金属' },
{ code: 'ZN', name: '锌', type: '金属' },
// 建材类
{ code: 'FG', name: '玻璃', type: '建材' },
{ code: 'SJS', name: '烧碱', type: '建材' },
{ code: 'SCA', name: '纯碱', type: '建材' },
{ code: 'JM', name: '焦煤', type: '建材' },
{ code: 'RB', name: '螺纹钢', type: '建材' },
{ code: 'ALO', name: '氧化铝', type: '建材' },
// 能源化工类
{ code: 'MA', name: '甲醇', type: '能源化工' },
{ code: 'PVC', name: 'PVC', type: '能源化工' },
{ code: 'FU', name: '燃油', type: '能源化工' },
{ code: 'SC', name: '原油', type: '能源化工' },
{ code: 'L', name: '橡胶', type: '能源化工' },
{ code: 'NR', name: '20号胶', type: '能源化工' },
{ code: 'BU', name: '沥青', type: '能源化工' },
{ code: 'LU', name: '低硫燃油', type: '能源化工' },
// 农产品类
{ code: 'P', name: '棕榈油', type: '农产品' },
// 新能源类
{ code: 'LC', name: '碳酸锂', type: '新能源' },
{ code: 'SI', name: '工业硅', type: '新能源' },
{ code: 'PGS', name: '多晶硅', type: '新能源' },
// 金融类
{ code: 'IC', name: '中证500', type: '金融' },
{ code: 'IM', name: '中证1000', type: '金融' },
{ code: 'IH', name: '上证50', type: '金融' }
];
// 生成随机数据的工具函数
const generateRandomPrice = (base, volatility) => {
return +(base + (Math.random() - 0.5) * 2 * volatility).toFixed(2);
};
const generateRandomChange = () => {
return +(Math.random() * 10 - 5).toFixed(2);
};
const generateRandomWinRate = () => {
return Math.floor(Math.random() * 50) + 30;
};
const generateRandomATR = () => {
return +(Math.random() * 5 + 0.5).toFixed(2);
};
const generateRandomADX = () => {
return Math.floor(Math.random() * 60) + 10;
};
const getADXStatus = (adx) => {
if (adx < 20) return '无趋势/震荡';
if (adx < 40) return '弱趋势';
return '强趋势';
};
const getTrendDirection = () => {
const directions = ['看多', '看空', '观望'];
return directions[Math.floor(Math.random() * directions.length)];
};
const getTrendStatus = (direction) => {
if (direction === '看多') return '多头趋势';
if (direction === '看空') return '空头趋势';
return '震荡';
};
const generateRandomRSI = () => {
return Math.floor(Math.random() * 80) + 10;
};
// 生成品种详细数据
export const generateFutureData = (code, name) => {
const currentPrice = generateRandomPrice(2000, 500);
const changePercent = generateRandomChange();
const atr = generateRandomATR();
const adx = generateRandomADX();
const winRate = generateRandomWinRate();
const trends = {
'5MIN': {
direction: getTrendDirection(),
status: getTrendStatus(getTrendDirection()),
rsi: generateRandomRSI()
},
'30MIN': {
direction: getTrendDirection(),
status: getTrendStatus(getTrendDirection()),
rsi: generateRandomRSI()
},
'1HOUR': {
direction: getTrendDirection(),
status: getTrendStatus(getTrendDirection()),
rsi: generateRandomRSI()
},
'1DAY': {
direction: getTrendDirection(),
status: getTrendStatus(getTrendDirection()),
rsi: generateRandomRSI()
}
};
const indicators = {
macd: ['金叉向上', '死叉向下', '走平'][Math.floor(Math.random() * 3)],
rsi: `${generateRandomRSI()}(中性)`,
bollinger: ['触及上轨', '触及下轨', '中轨附近'][Math.floor(Math.random() * 3)],
kdj: ['金叉向上', '死叉向下', '走平'][Math.floor(Math.random() * 3)]
};
const entry = currentPrice;
const stopLoss = entry * (1 - 0.02 * (Math.random() + 0.5));
const target = entry * (1 + 0.03 * (Math.random() + 0.5));
const resistance = entry * (1 + 0.05 * (Math.random() + 0.5));
const support = entry * (1 - 0.05 * (Math.random() + 0.5));
const overallViews = ['观望', '中线', '多头排列', '空头排列', '震荡'];
const overallView = overallViews[Math.floor(Math.random() * overallViews.length)];
return {
code,
name,
fullName: `${name}-${code}605`,
currentPrice,
changePercent,
atr,
adx,
adxStatus: getADXStatus(adx),
winRate,
trends,
indicators,
tradingAdvice: {
entry: +entry.toFixed(2),
stopLoss: +stopLoss.toFixed(2),
target: +target.toFixed(2),
resistance: +resistance.toFixed(2),
support: +support.toFixed(2)
},
riskLevel: ['低', '中等', '高'][Math.floor(Math.random() * 3)],
volatility: ['低', '中等', '高'][Math.floor(Math.random() * 3)],
overallView,
aiAnalysis: `MACD:${indicators.macd} | RSI:${indicators.rsi} | 布林带:${indicators.bollinger}`
};
};
// 生成多个品种的概览数据
export const generateFuturesOverview = () => {
return futuresList.map(item => {
const data = generateFutureData(item.code, item.name);
return {
code: data.code,
name: data.name,
currentPrice: data.currentPrice,
changePercent: data.changePercent,
winRate: data.winRate,
atr: data.atr,
adx: data.adx,
adxStatus: data.adxStatus,
trends: data.trends,
tradingAdvice: data.tradingAdvice,
overallView: data.overallView,
aiAnalysis: data.aiAnalysis
};
});
};
// 风险预警数据
export const riskAlerts = [
{ id: 1, title: '原油波动加剧', level: '高', message: '原油价格近期波动较大,建议控制仓位' },
{ id: 2, title: '螺纹钢换月提醒', level: '中等', message: '螺纹钢主力合约即将换月,请注意移仓' },
{ id: 3, title: '市场情绪偏空', level: '中等', message: '多数品种技术指标显示空头信号,建议谨慎操作' },
{ id: 4, title: '铜库存下降', level: '低', message: '铜库存持续下降,可能影响价格走势' }
];
// AI市场研判
export const aiMarketAnalysis = {
overallTrend: '震荡偏弱',
keyFactors: ['原油价格波动', '宏观经济数据', '政策面变化'],
recommendations: ['控制仓位', '关注原油走势', '做好止损'],
confidence: 75
};
// K线图模拟数据
export const generateKlineData = (days = 30) => {
const data = [];
let price = 2000;
for (let i = 0; i < days; i++) {
const open = price;
const high = open + Math.random() * 50;
const low = open - Math.random() * 50;
const close = low + Math.random() * (high - low);
const volume = Math.floor(Math.random() * 100000) + 10000;
data.push({
time: new Date(Date.now() - (days - i) * 24 * 60 * 60 * 1000).getTime() / 1000,
open: +open.toFixed(2),
high: +high.toFixed(2),
low: +low.toFixed(2),
close: +close.toFixed(2),
volume
});
price = close;
}
return data;
};