|
|
@@ -184,10 +184,11 @@ const sliderStep = 0.01 // 滑块步长
|
|
|
const calcProfitLoss = (ratio: number, profitLoss: 1 | -1) => usedMargin.value.deposit * (ratio / 100) * profitLoss
|
|
|
|
|
|
// 计算价差
|
|
|
-const calcSpread = (value: number) => {
|
|
|
+const calcSpread = (value: number, profitLoss: 1 | -1) => {
|
|
|
const { agreeunit = 0 } = quote.value ?? {}
|
|
|
- const absValue = Math.abs(value / (props.orderQty * agreeunit))
|
|
|
- return (Math.ceil(absValue * 100) / 100) * (props.orderType === 2 ? 1 : -1)
|
|
|
+ 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)
|
|
|
}
|
|
|
|
|
|
// 盈亏比限制
|
|
|
@@ -223,9 +224,9 @@ const sliderDecrease = (actionName = 'tp') => {
|
|
|
// 止盈止损
|
|
|
const tpsl = computed(() => {
|
|
|
const takeProfit = calcProfitLoss(takeProfitRatio.value, 1) // 盈利
|
|
|
- const takeProfitSpread = calcSpread(takeProfit) // 止盈价差
|
|
|
+ const takeProfitSpread = calcSpread(takeProfit, 1) // 止盈价差
|
|
|
const stopLoss = calcProfitLoss(stopLossRatio.value, -1) // 亏损
|
|
|
- const stopLossSpread = calcSpread(stopLoss) // 止损价差
|
|
|
+ const stopLossSpread = calcSpread(stopLoss, -1) // 止损价差
|
|
|
|
|
|
return {
|
|
|
takeProfit,
|