去掉mock数据
This commit is contained in:
parent
398dfdf487
commit
7366bf66fa
@ -125,7 +125,7 @@ export function mapBaiduQuotationToQuote(result: BaiduQuotationResult): QuoteDat
|
|||||||
buyRatio,
|
buyRatio,
|
||||||
sellRatio,
|
sellRatio,
|
||||||
intraday: parseIntraday(result),
|
intraday: parseIntraday(result),
|
||||||
// K 线按需加载,映射分时时不带入 mock/旧缓存
|
// K 线按需加载,映射分时时不带入旧缓存
|
||||||
candles: { day: [], week: [], month: [] },
|
candles: { day: [], week: [], month: [] },
|
||||||
orderBook: { asks, bids },
|
orderBook: { asks, bids },
|
||||||
trades: parseTrades(result),
|
trades: parseTrades(result),
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import { ElMessage } from 'element-plus'
|
import { ElMessage } from 'element-plus'
|
||||||
import type { AiAdvice } from '../types'
|
import type { AiAdvice } from '../types'
|
||||||
import { aiAdviceMock } from '../mocks/aiAdvice'
|
|
||||||
import { fetchDeepSeekAdvice } from '../api/deepseek/analyze'
|
import { fetchDeepSeekAdvice } from '../api/deepseek/analyze'
|
||||||
import type { AiAnalysisPayload } from '../api/deepseek/types'
|
import type { AiAnalysisPayload } from '../api/deepseek/types'
|
||||||
import { useQuotaStore, type KlinePeriod } from '../stores/quota'
|
import { useQuotaStore, type KlinePeriod } from '../stores/quota'
|
||||||
@ -9,8 +8,19 @@ import { useSettingsStore } from '../stores/settings'
|
|||||||
|
|
||||||
const KLINE_PERIODS: KlinePeriod[] = ['day', 'week', 'month']
|
const KLINE_PERIODS: KlinePeriod[] = ['day', 'week', 'month']
|
||||||
|
|
||||||
|
function emptyAdvice(): AiAdvice {
|
||||||
|
return {
|
||||||
|
action: '—',
|
||||||
|
direction: 'neutral',
|
||||||
|
confidence: 0,
|
||||||
|
summary: '点击「一键获取建议」获取 AI 分析',
|
||||||
|
reasons: [],
|
||||||
|
updatedAt: '',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function useAiAdvice() {
|
export function useAiAdvice() {
|
||||||
const data = ref<AiAdvice>(structuredClone(aiAdviceMock))
|
const data = ref<AiAdvice>(emptyAdvice())
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
const error = ref<unknown>(null)
|
const error = ref<unknown>(null)
|
||||||
const quota = useQuotaStore()
|
const quota = useQuotaStore()
|
||||||
|
|||||||
@ -1,15 +0,0 @@
|
|||||||
import type { AiAdvice } from '../types'
|
|
||||||
|
|
||||||
export const aiAdviceMock: AiAdvice = {
|
|
||||||
action: '观望',
|
|
||||||
direction: 'neutral',
|
|
||||||
confidence: 62,
|
|
||||||
summary: '短线偏弱但未破关键支撑,建议观望等待方向确认。',
|
|
||||||
reasons: [
|
|
||||||
'分时均线上方承压,反弹动能不足',
|
|
||||||
'五档卖压略大于买盘,内外盘接近均衡',
|
|
||||||
'机构多空头部持仓变动分化,缺乏单边合力',
|
|
||||||
'相关新闻偏中性,未见明确驱动',
|
|
||||||
],
|
|
||||||
updatedAt: '2026-07-21 11:30:12',
|
|
||||||
}
|
|
||||||
@ -1,4 +0,0 @@
|
|||||||
import type { NewsItem } from '../types'
|
|
||||||
|
|
||||||
/** 首屏占位;打开页面后由百度 getfuturesnews 覆盖 */
|
|
||||||
export const newsMock: NewsItem[] = []
|
|
||||||
@ -1,117 +0,0 @@
|
|||||||
import type { PositionRow, PositionsData, ProfitRow } from '../types'
|
|
||||||
|
|
||||||
function makeList(names: string[], base: number): PositionRow[] {
|
|
||||||
return names.map((name, i) => {
|
|
||||||
const qty = Math.floor(base * (0.22 - i * 0.012) + Math.random() * 2000)
|
|
||||||
const change = Math.floor((Math.random() - 0.45) * 800)
|
|
||||||
return {
|
|
||||||
rank: i + 1,
|
|
||||||
name,
|
|
||||||
qty,
|
|
||||||
change,
|
|
||||||
percent: 0,
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function withPercent(list: PositionRow[]): PositionRow[] {
|
|
||||||
const total = list.reduce((s, x) => s + x.qty, 0)
|
|
||||||
return list.map((x) => ({
|
|
||||||
...x,
|
|
||||||
percent: Number(((x.qty / total) * 100).toFixed(2)),
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
|
|
||||||
function makeProfit(
|
|
||||||
names: string[],
|
|
||||||
base: number,
|
|
||||||
sign: 1 | -1,
|
|
||||||
): ProfitRow[] {
|
|
||||||
const list = names.map((name, i) => {
|
|
||||||
const profit = sign * Math.floor(base * (0.2 - i * 0.01) + Math.random() * 5e6)
|
|
||||||
return {
|
|
||||||
rank: i + 1,
|
|
||||||
name,
|
|
||||||
profit,
|
|
||||||
netQty: Math.floor((Math.random() - 0.5) * 80000),
|
|
||||||
change: Math.floor((Math.random() - 0.5) * 2000),
|
|
||||||
date: '2026-07-21',
|
|
||||||
percent: 0,
|
|
||||||
}
|
|
||||||
})
|
|
||||||
const total = list.reduce((s, x) => s + Math.abs(x.profit), 0)
|
|
||||||
return list.map((x) => ({
|
|
||||||
...x,
|
|
||||||
percent: total > 0 ? Number(((Math.abs(x.profit) / total) * 100).toFixed(2)) : 0,
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
|
|
||||||
const longNames = [
|
|
||||||
'中财期货',
|
|
||||||
'东证期货',
|
|
||||||
'恒力期货',
|
|
||||||
'物产中大期货',
|
|
||||||
'中信期货',
|
|
||||||
'国泰君安期货',
|
|
||||||
'海通期货',
|
|
||||||
'永安期货',
|
|
||||||
'银河期货',
|
|
||||||
'华泰期货',
|
|
||||||
'南华期货',
|
|
||||||
'光大期货',
|
|
||||||
'方正中期',
|
|
||||||
'申银万国',
|
|
||||||
'中粮期货',
|
|
||||||
'浙商期货',
|
|
||||||
'广发期货',
|
|
||||||
'兴证期货',
|
|
||||||
'瑞达期货',
|
|
||||||
'其他',
|
|
||||||
]
|
|
||||||
|
|
||||||
const shortNames = [
|
|
||||||
'国泰君安期货',
|
|
||||||
'中信期货',
|
|
||||||
'永安期货',
|
|
||||||
'海通期货',
|
|
||||||
'华泰期货',
|
|
||||||
'银河期货',
|
|
||||||
'中财期货',
|
|
||||||
'东证期货',
|
|
||||||
'南华期货',
|
|
||||||
'光大期货',
|
|
||||||
'恒力期货',
|
|
||||||
'物产中大期货',
|
|
||||||
'方正中期',
|
|
||||||
'申银万国',
|
|
||||||
'中粮期货',
|
|
||||||
'浙商期货',
|
|
||||||
'广发期货',
|
|
||||||
'兴证期货',
|
|
||||||
'瑞达期货',
|
|
||||||
'其他',
|
|
||||||
]
|
|
||||||
|
|
||||||
const long = withPercent(makeList(longNames, 650000))
|
|
||||||
const short = withPercent(makeList(shortNames, 640000))
|
|
||||||
const volume = withPercent(makeList(longNames, 480000))
|
|
||||||
const netLong = withPercent(makeList(longNames.slice(0, 12), 120000))
|
|
||||||
const netShort = withPercent(makeList(shortNames.slice(0, 12), 110000))
|
|
||||||
const profitGain = makeProfit(longNames.slice(0, 12), 2e8, 1)
|
|
||||||
const profitLoss = makeProfit(shortNames.slice(0, 12), 1.5e8, -1)
|
|
||||||
|
|
||||||
export const positionsMock: PositionsData = {
|
|
||||||
long,
|
|
||||||
short,
|
|
||||||
volume,
|
|
||||||
netLong,
|
|
||||||
netShort,
|
|
||||||
profitGain,
|
|
||||||
profitLoss,
|
|
||||||
topTwentySum: [
|
|
||||||
{ tradeDate: '2026-07-15', longSum: 1073446, shortSum: 1502020 },
|
|
||||||
{ tradeDate: '2026-07-14', longSum: 1094199, shortSum: 1519906 },
|
|
||||||
{ tradeDate: '2026-07-13', longSum: 1095204, shortSum: 1537419 },
|
|
||||||
],
|
|
||||||
updatedAt: '2026-07-15',
|
|
||||||
}
|
|
||||||
@ -1,117 +0,0 @@
|
|||||||
import type { Candle, IntradayPoint, QuoteData } from '../types'
|
|
||||||
|
|
||||||
function buildIntraday(): IntradayPoint[] {
|
|
||||||
const points: IntradayPoint[] = []
|
|
||||||
let price = 948
|
|
||||||
const slots = [
|
|
||||||
{ start: '21:00', count: 30 },
|
|
||||||
{ start: '09:00', count: 40 },
|
|
||||||
{ start: '10:30', count: 20 },
|
|
||||||
{ start: '13:30', count: 35 },
|
|
||||||
]
|
|
||||||
for (const slot of slots) {
|
|
||||||
const [h, m] = slot.start.split(':').map(Number)
|
|
||||||
for (let i = 0; i < slot.count; i++) {
|
|
||||||
const mm = m + i
|
|
||||||
const hh = h + Math.floor(mm / 60)
|
|
||||||
const min = mm % 60
|
|
||||||
const t = `${String(hh).padStart(2, '0')}:${String(min).padStart(2, '0')}`
|
|
||||||
price += (Math.random() - 0.55) * 1.2
|
|
||||||
points.push({
|
|
||||||
time: t,
|
|
||||||
price: Number(price.toFixed(2)),
|
|
||||||
avg: Number((price + 0.4).toFixed(2)),
|
|
||||||
volume: Math.floor(Math.random() * 800 + 50),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return points
|
|
||||||
}
|
|
||||||
|
|
||||||
function buildCandles(count = 40): Candle[] {
|
|
||||||
const candles: Candle[] = []
|
|
||||||
let close = 950
|
|
||||||
for (let i = 0; i < count; i++) {
|
|
||||||
const open = close
|
|
||||||
const change = (Math.random() - 0.5) * 12
|
|
||||||
close = Number((open + change).toFixed(2))
|
|
||||||
const high = Number((Math.max(open, close) + Math.random() * 4).toFixed(2))
|
|
||||||
const low = Number((Math.min(open, close) - Math.random() * 4).toFixed(2))
|
|
||||||
candles.push({
|
|
||||||
date: `05-${String((i % 28) + 1).padStart(2, '0')}`,
|
|
||||||
open,
|
|
||||||
close,
|
|
||||||
low,
|
|
||||||
high,
|
|
||||||
volume: Math.floor(Math.random() * 20000 + 3000),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
return candles
|
|
||||||
}
|
|
||||||
|
|
||||||
export const quoteMock: QuoteData = {
|
|
||||||
name: '玻璃2609',
|
|
||||||
code: 'FG609',
|
|
||||||
exchange: '郑商所',
|
|
||||||
status: '休市',
|
|
||||||
last: 936.0,
|
|
||||||
change: -13.0,
|
|
||||||
changePercent: -1.37,
|
|
||||||
open: 948.0,
|
|
||||||
high: 949.0,
|
|
||||||
low: 934.0,
|
|
||||||
prevClose: 949.0,
|
|
||||||
settlement: 949.0,
|
|
||||||
prevSettlement: 949.0,
|
|
||||||
avg: 940.0,
|
|
||||||
volume: 825643,
|
|
||||||
amount: 77.72,
|
|
||||||
openInterest: 673892,
|
|
||||||
amplitude: 1.58,
|
|
||||||
outerVol: 412331,
|
|
||||||
innerVol: 413312,
|
|
||||||
updatedAt: '11:30:00',
|
|
||||||
// 买档量 1503 / 卖档量 1365 → 约 52% / 48%
|
|
||||||
buyRatio: 52,
|
|
||||||
sellRatio: 48,
|
|
||||||
intraday: buildIntraday(),
|
|
||||||
candles: {
|
|
||||||
day: buildCandles(60),
|
|
||||||
week: buildCandles(40),
|
|
||||||
month: buildCandles(24),
|
|
||||||
},
|
|
||||||
orderBook: {
|
|
||||||
asks: [
|
|
||||||
{ level: 5, price: 938.0, volume: 312 },
|
|
||||||
{ level: 4, price: 937.0, volume: 198 },
|
|
||||||
{ level: 3, price: 936.0, volume: 456 },
|
|
||||||
{ level: 2, price: 935.0, volume: 221 },
|
|
||||||
{ level: 1, price: 934.0, volume: 178 },
|
|
||||||
],
|
|
||||||
bids: [
|
|
||||||
{ level: 1, price: 933.0, volume: 265 },
|
|
||||||
{ level: 2, price: 932.0, volume: 340 },
|
|
||||||
{ level: 3, price: 931.0, volume: 189 },
|
|
||||||
{ level: 4, price: 930.0, volume: 412 },
|
|
||||||
{ level: 5, price: 929.0, volume: 297 },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
trades: [
|
|
||||||
{ time: '11:30', price: 936.0, volume: 1, side: 'B' },
|
|
||||||
{ time: '11:30', price: 936.0, volume: 23, side: 'B' },
|
|
||||||
{ time: '11:29', price: 935.0, volume: 2, side: 'S' },
|
|
||||||
{ time: '11:29', price: 935.0, volume: 8, side: 'B' },
|
|
||||||
{ time: '11:28', price: 936.0, volume: 15, side: 'S' },
|
|
||||||
{ time: '11:28', price: 936.0, volume: 4, side: 'B' },
|
|
||||||
{ time: '11:27', price: 937.0, volume: 11, side: 'S' },
|
|
||||||
{ time: '11:27', price: 936.0, volume: 6, side: 'B' },
|
|
||||||
{ time: '11:26', price: 935.0, volume: 19, side: 'S' },
|
|
||||||
{ time: '11:26', price: 934.0, volume: 3, side: 'B' },
|
|
||||||
{ time: '11:25', price: 935.0, volume: 27, side: 'S' },
|
|
||||||
{ time: '11:25', price: 936.0, volume: 9, side: 'B' },
|
|
||||||
{ time: '11:24', price: 936.0, volume: 5, side: 'B' },
|
|
||||||
{ time: '11:24', price: 935.0, volume: 7, side: 'S' },
|
|
||||||
{ time: '11:23', price: 935.0, volume: 45, side: 'S' },
|
|
||||||
{ time: '11:23', price: 934.0, volume: 38, side: 'B' },
|
|
||||||
],
|
|
||||||
}
|
|
||||||
@ -1,9 +1,6 @@
|
|||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
import { computed, ref, toRaw } from 'vue'
|
import { computed, ref, toRaw } from 'vue'
|
||||||
import type { Candle, NewsItem, PositionsData, QuoteData } from '../types'
|
import type { Candle, NewsItem, PositionsData, QuoteData } from '../types'
|
||||||
import { quoteMock } from '../mocks/quote'
|
|
||||||
import { newsMock } from '../mocks/news'
|
|
||||||
import { positionsMock } from '../mocks/positions'
|
|
||||||
import { contractConfig } from '../config/contract'
|
import { contractConfig } from '../config/contract'
|
||||||
import { getStockKline, getStockQuotation } from '../api/baidu/quotation'
|
import { getStockKline, getStockQuotation } from '../api/baidu/quotation'
|
||||||
import { getFuturesNews } from '../api/baidu/news'
|
import { getFuturesNews } from '../api/baidu/news'
|
||||||
@ -45,9 +42,55 @@ function emptyCandles(): QuoteData['candles'] {
|
|||||||
return { day: [], week: [], month: [] }
|
return { day: [], week: [], month: [] }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function emptyQuote(): QuoteData {
|
||||||
|
return {
|
||||||
|
name: contractConfig.name,
|
||||||
|
code: contractConfig.code,
|
||||||
|
exchange: contractConfig.exchange,
|
||||||
|
status: '',
|
||||||
|
last: 0,
|
||||||
|
change: 0,
|
||||||
|
changePercent: 0,
|
||||||
|
open: 0,
|
||||||
|
high: 0,
|
||||||
|
low: 0,
|
||||||
|
prevClose: 0,
|
||||||
|
settlement: 0,
|
||||||
|
prevSettlement: 0,
|
||||||
|
avg: 0,
|
||||||
|
volume: 0,
|
||||||
|
amount: 0,
|
||||||
|
openInterest: 0,
|
||||||
|
amplitude: 0,
|
||||||
|
outerVol: 0,
|
||||||
|
innerVol: 0,
|
||||||
|
updatedAt: '',
|
||||||
|
buyRatio: 50,
|
||||||
|
sellRatio: 50,
|
||||||
|
intraday: [],
|
||||||
|
candles: emptyCandles(),
|
||||||
|
orderBook: { asks: [], bids: [] },
|
||||||
|
trades: [],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function emptyPositions(): PositionsData {
|
||||||
|
return {
|
||||||
|
long: [],
|
||||||
|
short: [],
|
||||||
|
volume: [],
|
||||||
|
netLong: [],
|
||||||
|
netShort: [],
|
||||||
|
profitGain: [],
|
||||||
|
profitLoss: [],
|
||||||
|
topTwentySum: [],
|
||||||
|
updatedAt: '',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export const useQuotaStore = defineStore('quota', () => {
|
export const useQuotaStore = defineStore('quota', () => {
|
||||||
// ─── 行情 ───────────────────────────────────────────────
|
// ─── 行情 ───────────────────────────────────────────────
|
||||||
const quote = ref<QuoteData>(structuredClone(quoteMock))
|
const quote = ref<QuoteData>(emptyQuote())
|
||||||
const quoteLoading = ref(false)
|
const quoteLoading = ref(false)
|
||||||
const klineLoading = ref(false)
|
const klineLoading = ref(false)
|
||||||
const quoteError = ref<unknown>(null)
|
const quoteError = ref<unknown>(null)
|
||||||
@ -58,12 +101,12 @@ export const useQuotaStore = defineStore('quota', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
// ─── 新闻 ───────────────────────────────────────────────
|
// ─── 新闻 ───────────────────────────────────────────────
|
||||||
const news = ref<NewsItem[]>(structuredClone(newsMock))
|
const news = ref<NewsItem[]>([])
|
||||||
const newsLoading = ref(false)
|
const newsLoading = ref(false)
|
||||||
const newsError = ref<unknown>(null)
|
const newsError = ref<unknown>(null)
|
||||||
|
|
||||||
// ─── 机构持仓 ───────────────────────────────────────────
|
// ─── 机构持仓 ───────────────────────────────────────────
|
||||||
const positions = ref<PositionsData>(structuredClone(positionsMock))
|
const positions = ref<PositionsData>(emptyPositions())
|
||||||
const positionsLoading = ref(false)
|
const positionsLoading = ref(false)
|
||||||
const positionsError = ref<unknown>(null)
|
const positionsError = ref<unknown>(null)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user