|
|
@@ -135,6 +135,7 @@ export const useSBYJOrderStore = defineStore(() => {
|
|
|
state.orderList.forEach((e) => {
|
|
|
e.tHDetailEx.depositRate = calcDepositRate(e)
|
|
|
e.tHDetailEx.floatPL = calcFloatpl(e)
|
|
|
+ e.tHDetailEx.riskRate = calRiskRate(e)
|
|
|
})
|
|
|
// 任务 #5753
|
|
|
return state.orderList.filter((e) => e.tHDetailEx.holderQty > 0)
|
|
|
@@ -165,6 +166,23 @@ export const useSBYJOrderStore = defineStore(() => {
|
|
|
return depositRate
|
|
|
}
|
|
|
|
|
|
+ // 计算风险率
|
|
|
+ const calRiskRate = (e: Model.SBYJMyOrderRsp) => {
|
|
|
+ // 已付定金+补充定金
|
|
|
+ const useMargin = e.tHDetailEx.payedDeposit+e.tHDetailEx.restockDeposit
|
|
|
+
|
|
|
+ const quote = futuresStore.getGoodsQuote(e.tHDetailEx.goodsID)
|
|
|
+ const { ask = 0, bid = 0, agreeunit = 0 } = quote.value ?? {}
|
|
|
+ const price = e.tHDetailEx.buyOrSell === BuyOrSell.Buy ? bid : ask // 根据方向取买卖价
|
|
|
+
|
|
|
+ // 计算浮动盈亏 (价格 * 手数 * 合约乘数 - 持仓金额) * 方向标识
|
|
|
+ const float = price ? price * e.tHDetailEx.holderQty * agreeunit - e.tHDetailEx.holderAmount : 0
|
|
|
+ const floatpl = float * (e.tHDetailEx.buyOrSell === BuyOrSell.Buy ? 1 : -1)
|
|
|
+ // 计算风险率 占用/占用+浮动盈亏
|
|
|
+ const riskRate = useMargin/(useMargin+floatpl)
|
|
|
+ return riskRate
|
|
|
+ }
|
|
|
+
|
|
|
// 获取订单列表
|
|
|
const getSBYJMyOrders = async () => {
|
|
|
if (!state.loading) {
|