89 lines
1.9 KiB
TypeScript
89 lines
1.9 KiB
TypeScript
import type { PositionRow, PositionsData } 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)),
|
|
}))
|
|
}
|
|
|
|
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))
|
|
|
|
export const positionsMock: PositionsData = {
|
|
long,
|
|
short,
|
|
volume,
|
|
netLong,
|
|
netShort,
|
|
topTwentySum: [
|
|
{ tradeDate: '2026-07-15', longSum: 1073446, shortSum: 1502020 },
|
|
{ tradeDate: '2026-07-14', longSum: 1094199, shortSum: 1519906 },
|
|
],
|
|
updatedAt: '2026-07-15',
|
|
}
|