|
@@ -1,10 +1,13 @@
|
|
|
import { isOemByEnum, OemType } from '@/common/config/projectName';
|
|
import { isOemByEnum, OemType } from '@/common/config/projectName';
|
|
|
|
|
+import { queryResultLoadingAndInfo } from '@/common/methods/request/resultInfo';
|
|
|
import { hasSystemParam } from '@/hooks/system';
|
|
import { hasSystemParam } from '@/hooks/system';
|
|
|
import { useHolderprice, useProfitloss } from '@/services/bus/holdPosition';
|
|
import { useHolderprice, useProfitloss } from '@/services/bus/holdPosition';
|
|
|
import { getMarketTradePropertyByGoodsId } from '@/services/bus/market';
|
|
import { getMarketTradePropertyByGoodsId } from '@/services/bus/market';
|
|
|
|
|
+import { AccountListItem } from '@/services/dataCenter/interafce/account';
|
|
|
|
|
+import { queryTradePosition } from '@/services/go/ermcp/order';
|
|
|
import { QueryTradePositionRsp } from '@/services/go/ermcp/order/interface';
|
|
import { QueryTradePositionRsp } from '@/services/go/ermcp/order/interface';
|
|
|
import { Taaccount } from '@/services/go/TaAccount/interface';
|
|
import { Taaccount } from '@/services/go/TaAccount/interface';
|
|
|
-import { Ref } from 'vue';
|
|
|
|
|
|
|
+import { ref, Ref } from 'vue';
|
|
|
|
|
|
|
|
export const tableColumns = () => {
|
|
export const tableColumns = () => {
|
|
|
let result = [
|
|
let result = [
|
|
@@ -130,15 +133,24 @@ export const tableColumns = () => {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
-export const useHazardRates = (positions: Ref<QueryTradePositionRsp[]>) => {
|
|
|
|
|
|
|
+export const useHazardRates = () => {
|
|
|
|
|
+ // 持仓汇总
|
|
|
|
|
+ const holdsList = ref<QueryTradePositionRsp[]>([]);
|
|
|
|
|
+ function getHoldsList(loading: Ref<boolean>) {
|
|
|
|
|
+ // 获取头寸
|
|
|
|
|
+ queryResultLoadingAndInfo(queryTradePosition, loading).then(res => {
|
|
|
|
|
+ holdsList.value = res;
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// 获取报价小数位
|
|
// 获取报价小数位
|
|
|
function getDecimalplace() {
|
|
function getDecimalplace() {
|
|
|
- return positions.value.length > 0 ? positions.value[0].decimalplace : 2
|
|
|
|
|
|
|
+ return holdsList.value.length > 0 ? holdsList.value[0].decimalplace : 2
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 获取当前资金账号对应的头寸
|
|
// 获取当前资金账号对应的头寸
|
|
|
function getTaaccountPosition(accountid: number) {
|
|
function getTaaccountPosition(accountid: number) {
|
|
|
- return positions.value.filter(e => e.accountid === accountid)
|
|
|
|
|
|
|
+ return holdsList.value.filter(e => e.accountid === accountid)
|
|
|
}
|
|
}
|
|
|
// 汇总资金账号 的 浮动盈亏
|
|
// 汇总资金账号 的 浮动盈亏
|
|
|
function handleProfitloss({ accountid }: Taaccount, isDecimalPace = true) {
|
|
function handleProfitloss({ accountid }: Taaccount, isDecimalPace = true) {
|
|
@@ -208,12 +220,12 @@ export const useHazardRates = (positions: Ref<QueryTradePositionRsp[]>) => {
|
|
|
result = result ? result * 100 : 0
|
|
result = result ? result * 100 : 0
|
|
|
return result.toFixed(decimalplace) + '%'
|
|
return result.toFixed(decimalplace) + '%'
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- function canUseMoney(taaccount: Taaccount) {
|
|
|
|
|
|
|
+ // 可用资金
|
|
|
|
|
+ function canUseMoney(taaccount: Taaccount | AccountListItem) {
|
|
|
const { currentbalance, usedmargin, freezemargin, freezecharge, otherfreezemargin, outamountfreeze } = taaccount
|
|
const { currentbalance, usedmargin, freezemargin, freezecharge, otherfreezemargin, outamountfreeze } = taaccount
|
|
|
|
|
|
|
|
// 浮动盈亏
|
|
// 浮动盈亏
|
|
|
- const profitloss = handleProfitloss(taaccount, false) as number
|
|
|
|
|
|
|
+ const profitloss = handleProfitloss(taaccount as Taaccount, false) as number
|
|
|
// 占用+冻结+其它冻结+手续费冻结+出金冻结
|
|
// 占用+冻结+其它冻结+手续费冻结+出金冻结
|
|
|
const freeze = usedmargin + freezemargin + freezecharge + otherfreezemargin + outamountfreeze
|
|
const freeze = usedmargin + freezemargin + freezecharge + otherfreezemargin + outamountfreeze
|
|
|
let result = 0
|
|
let result = 0
|
|
@@ -235,6 +247,6 @@ export const useHazardRates = (positions: Ref<QueryTradePositionRsp[]>) => {
|
|
|
return result.toFixed(decimalplace)
|
|
return result.toFixed(decimalplace)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- return { handleProfitloss, hazardRates, netWorth, canUseMoney }
|
|
|
|
|
|
|
+ return { handleProfitloss, hazardRates, netWorth, canUseMoney, getHoldsList }
|
|
|
}
|
|
}
|
|
|
|
|
|