li.shaoyi 2 ay önce
ebeveyn
işleme
457a5ff9be

+ 5 - 4
src/packages/mobile/views/pricing/trade/prepayment/Index.vue

@@ -180,15 +180,16 @@ const takeProfitRatio = shallowRef(0) // 止盈比例
 const stopLossRatio = shallowRef(0) // 止损比例
 const sliderStep = 0.01 // 滑块步长
 
-// 计算盈亏
+// 计算盈亏 
 const calcProfitLoss = (ratio: number, profitLoss: 1 | -1) => usedMargin.value.deposit * (ratio / 100) * profitLoss
 
 // 计算价差
 const calcSpread = (value: number, profitLoss: 1 | -1) => {
-    const { agreeunit = 0 } = quote.value ?? {}
+    const { agreeunit = 0, decimalplace = 0 } = quote.value ?? {}
     const spread = value / (props.orderQty * agreeunit)
-    const roundedSpread = profitLoss === 1 ? Math.ceil(spread * 100) : Math.floor(spread * 100)
-    return roundedSpread / 100 * (props.orderType === 2 ? 1 : -1)
+    const multiplier = Math.pow(10, decimalplace) // 小数位n次方
+    const roundedSpread = profitLoss === 1 ? Math.ceil(spread * multiplier) : Math.floor(spread * multiplier) // 取整
+    return roundedSpread / multiplier * (props.orderType === 2 ? 1 : -1)
 }
 
 // 盈亏比限制