|
@@ -1,5 +1,5 @@
|
|
|
import { reactive, computed, toRefs } from 'vue'
|
|
import { reactive, computed, toRefs } from 'vue'
|
|
|
-import { handlePriceColor } from '@/filters'
|
|
|
|
|
|
|
+import { handlePriceColor, round } from '@/filters'
|
|
|
import { BuyOrSell } from '@/constants/order'
|
|
import { BuyOrSell } from '@/constants/order'
|
|
|
import { queryTradePosition } from '@/services/api/order'
|
|
import { queryTradePosition } from '@/services/api/order'
|
|
|
import { useFuturesStore } from './futures'
|
|
import { useFuturesStore } from './futures'
|
|
@@ -48,16 +48,18 @@ export const usePositionStore = defineStore(() => {
|
|
|
|
|
|
|
|
// 计算市值 = 现价 * 数量 * 合约单位
|
|
// 计算市值 = 现价 * 数量 * 合约单位
|
|
|
const marketValue = price ? price * item.curpositionqty * item.agreeunit : 0
|
|
const marketValue = price ? price * item.curpositionqty * item.agreeunit : 0
|
|
|
|
|
+ const roundedMarketValue = round(marketValue, quote.value?.decimalplace)
|
|
|
// 计算浮动盈亏
|
|
// 计算浮动盈亏
|
|
|
- const closepl = price ? (marketValue - item.curholderamount) * (item.buyorsell === BuyOrSell.Buy ? 1 : -1) : 0
|
|
|
|
|
|
|
+ const closepl = price ? (roundedMarketValue - item.curholderamount) * (item.buyorsell === BuyOrSell.Buy ? 1 : -1) : 0
|
|
|
|
|
+ const roundedClosepl = round(closepl, quote.value?.decimalplace)
|
|
|
|
|
|
|
|
result.push({
|
|
result.push({
|
|
|
...item,
|
|
...item,
|
|
|
lastprice: price,
|
|
lastprice: price,
|
|
|
lastColor: handlePriceColor(price, presettle),
|
|
lastColor: handlePriceColor(price, presettle),
|
|
|
- closepl,
|
|
|
|
|
- closeplColor: handlePriceColor(closepl, 0),
|
|
|
|
|
- marketValue,
|
|
|
|
|
|
|
+ closepl: roundedClosepl,
|
|
|
|
|
+ closeplColor: handlePriceColor(roundedClosepl, 0),
|
|
|
|
|
+ marketValue: roundedMarketValue,
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|