交易数据显示规则
This commit is contained in:
parent
24a72bfd3f
commit
9ed84cf083
@ -8,7 +8,7 @@ import type {
|
|||||||
} from './types'
|
} from './types'
|
||||||
import {
|
import {
|
||||||
extractVariety,
|
extractVariety,
|
||||||
getPreviousTradingDate,
|
getPositionQueryDate,
|
||||||
getRecentMonthRange,
|
getRecentMonthRange,
|
||||||
} from '../../utils/tradingDate'
|
} from '../../utils/tradingDate'
|
||||||
|
|
||||||
@ -19,7 +19,7 @@ export interface GetDealPositionParams {
|
|||||||
variety?: string
|
variety?: string
|
||||||
/**
|
/**
|
||||||
* 查询日期 YYYY-MM-DD。
|
* 查询日期 YYYY-MM-DD。
|
||||||
* 缺省为上一交易日(接口一般只能查到上一交易日)。
|
* 缺省:交易日 16:00 后为当天,否则上一交易日。
|
||||||
*/
|
*/
|
||||||
date?: string
|
date?: string
|
||||||
}
|
}
|
||||||
@ -33,7 +33,7 @@ export async function getDealPosition(
|
|||||||
): Promise<JqkaDealPositionData> {
|
): Promise<JqkaDealPositionData> {
|
||||||
const contract = params.contract
|
const contract = params.contract
|
||||||
const variety = params.variety ?? extractVariety(contract)
|
const variety = params.variety ?? extractVariety(contract)
|
||||||
const date = params.date ?? getPreviousTradingDate()
|
const date = params.date ?? getPositionQueryDate()
|
||||||
|
|
||||||
const { data } = await jqkaHttp.get<JqkaDealPositionResponse>(
|
const { data } = await jqkaHttp.get<JqkaDealPositionResponse>(
|
||||||
'/futgwapi/api/market/v1/position/getDealPosition/',
|
'/futgwapi/api/market/v1/position/getDealPosition/',
|
||||||
|
|||||||
@ -38,14 +38,14 @@ const columns = computed((): StatCell[][] => {
|
|||||||
{ label: '成交额', value: `${q.amount}亿` },
|
{ label: '成交额', value: `${q.amount}亿` },
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
{ label: '持仓量', value: q.openInterest.toLocaleString() },
|
{ label: '持仓量', value: `${(q.openInterest / 10000).toFixed(2)}万` },
|
||||||
{ label: '振幅', value: `${q.amplitude}%` },
|
{ label: '振幅', value: `${q.amplitude}%` },
|
||||||
{ label: '外盘', value: q.outerVol.toLocaleString(), className: 'price-up' },
|
{ label: '外盘', value: `${(q.outerVol / 10000).toFixed(2)}万`, className: 'price-up' },
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
{ label: '昨收', value: q.prevClose.toFixed(2) },
|
{ label: '昨收', value: q.prevClose.toFixed(2) },
|
||||||
{ label: '成交量', value: q.volume.toLocaleString() },
|
{ label: '成交量', value: q.volume.toLocaleString() },
|
||||||
{ label: '内盘', value: q.innerVol.toLocaleString(), className: 'price-down' },
|
{ label: '内盘', value: `${(q.innerVol / 10000).toFixed(2)}万`, className: 'price-down' },
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
{ label: '最低', value: q.low.toFixed(2), className: 'price-down' },
|
{ label: '最低', value: q.low.toFixed(2), className: 'price-down' },
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import { useQuotaStore } from '../stores/quota'
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 机构持仓 composable:状态统一落在 quota store。
|
* 机构持仓 composable:状态统一落在 quota store。
|
||||||
* 打开页面时按上一交易日拉取同花顺会员持仓。
|
* 打开页面时按交易日规则拉取同花顺会员持仓(16:00 后查当天,否则上一交易日)。
|
||||||
*/
|
*/
|
||||||
export function usePositions() {
|
export function usePositions() {
|
||||||
const store = useQuotaStore()
|
const store = useQuotaStore()
|
||||||
|
|||||||
@ -15,6 +15,7 @@ import { getDealPosition, getPositionProfitRank } from '../api/jqka/position'
|
|||||||
import { mapJqkaDealPosition, mapJqkaPositionProfit } from '../api/jqka/mapPosition'
|
import { mapJqkaDealPosition, mapJqkaPositionProfit } from '../api/jqka/mapPosition'
|
||||||
import {
|
import {
|
||||||
extractVariety,
|
extractVariety,
|
||||||
|
getPositionQueryDate,
|
||||||
getPreviousTradingDate,
|
getPreviousTradingDate,
|
||||||
} from '../utils/tradingDate'
|
} from '../utils/tradingDate'
|
||||||
|
|
||||||
@ -129,7 +130,8 @@ export const useQuotaStore = defineStore('quota', () => {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 拉取会员持仓 + 机构盈利。
|
* 拉取会员持仓 + 机构盈利。
|
||||||
* 持仓日期默认上一交易日;若遇节假日空数据则再往前最多试 5 个交易日。
|
* 持仓日期:交易日 16:00 后查当天,否则查上一交易日;
|
||||||
|
* 若遇节假日空数据则再往前最多试 5 个交易日。
|
||||||
* 盈利默认最近一个月、按当前品种查询。
|
* 盈利默认最近一个月、按当前品种查询。
|
||||||
*/
|
*/
|
||||||
async function fetchPositions() {
|
async function fetchPositions() {
|
||||||
@ -138,7 +140,7 @@ export const useQuotaStore = defineStore('quota', () => {
|
|||||||
try {
|
try {
|
||||||
const contract = contractConfig.code
|
const contract = contractConfig.code
|
||||||
const variety = contractConfig.variety || extractVariety(contract)
|
const variety = contractConfig.variety || extractVariety(contract)
|
||||||
let date = getPreviousTradingDate()
|
let date = getPositionQueryDate()
|
||||||
let mapped: PositionsData | null = null
|
let mapped: PositionsData | null = null
|
||||||
|
|
||||||
for (let i = 0; i < 5; i++) {
|
for (let i = 0; i < 5; i++) {
|
||||||
|
|||||||
@ -13,9 +13,13 @@ function isWeekend(d: Date): boolean {
|
|||||||
return day === 0 || day === 6
|
return day === 0 || day === 6
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 是否交易日(跳过周末;不含法定节假日日历) */
|
||||||
|
export function isTradingDay(d: Date = new Date()): boolean {
|
||||||
|
return !isWeekend(d)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 上一个交易日(跳过周末;不含法定节假日日历)。
|
* 上一个交易日(跳过周末;不含法定节假日日历)。
|
||||||
* 持仓接口一般只能查到上一交易日数据,故默认用此日期。
|
|
||||||
*/
|
*/
|
||||||
export function getPreviousTradingDate(from: Date = new Date()): string {
|
export function getPreviousTradingDate(from: Date = new Date()): string {
|
||||||
const d = new Date(from.getFullYear(), from.getMonth(), from.getDate())
|
const d = new Date(from.getFullYear(), from.getMonth(), from.getDate())
|
||||||
@ -26,6 +30,19 @@ export function getPreviousTradingDate(from: Date = new Date()): string {
|
|||||||
return formatDateYmd(d)
|
return formatDateYmd(d)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 机构持仓默认查询日期:
|
||||||
|
* - 当天为交易日且已到下午 16:00(含)→ 查当天
|
||||||
|
* - 否则(交易日 16:00 前,或非交易日)→ 查上一交易日
|
||||||
|
*/
|
||||||
|
export function getPositionQueryDate(from: Date = new Date()): string {
|
||||||
|
const now = new Date(from)
|
||||||
|
if (isTradingDay(now) && now.getHours() >= 16) {
|
||||||
|
return formatDateYmd(now)
|
||||||
|
}
|
||||||
|
return getPreviousTradingDate(now)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 从合约代码提取品种,如 FG609 → FG、au2512 → au
|
* 从合约代码提取品种,如 FG609 → FG、au2512 → au
|
||||||
*/
|
*/
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user