Handy_Cao 1 月之前
父节点
当前提交
c9399edfe2
共有 1 个文件被更改,包括 11 次插入21 次删除
  1. 11 21
      src/packages/digital/views/contract/goods/detail/index.vue

+ 11 - 21
src/packages/digital/views/contract/goods/detail/index.vue

@@ -52,7 +52,7 @@
                         <app-stepper v-model="formData.OrderQty" :min="0" />
                     </template>
                 </Field>
-                <Cell title="开仓价值" :value="formatDecimal(openAmount) + enumName" />
+                <Cell title="开仓价值" :value="formatDecimal(calculations.openAmount) + enumName" />
             </CellGroup>
             <CellGroup inset>
                 <Cell title="可用余额" :value="formatDecimal(calculations.maxBalance)" />
@@ -282,12 +282,10 @@ const tpsl = computed(() => {
 // 保证金设置(比率) 时:可开数量 = 可用余额 / (价格 * 合约乘数 * 比率值)
 const calculations = computed(() => {
 
-    const feeValue = futuresStore.getFeeValue(quote.value, 101)
+    const { bid = 0, ask = 0, agreeunit = 0, currencyid = 0, goodscurrencyid = 0, marketmarginalgorithm, marketmarginvalue = 0 } = quote.value ?? {}
+    const { OrderPrice = 0, OrderQty = 0, BuyOrSell } = formData
 
-    const { last = 0, agreeunit = 0, currencyid = 0, goodscurrencyid = 0 } = quote.value ?? {}
-    const { OrderPrice = 0, OrderQty = 0 } = formData
-
-    const price = formData.PriceMode === PriceMode.Market ? last : OrderPrice
+    const price = formData.PriceMode === PriceMode.Market ? (BuyOrSell === 0 ? ask : bid) : OrderPrice
     const amount = OrderQty * agreeunit
 
     // 预估金额
@@ -296,22 +294,27 @@ const calculations = computed(() => {
     const accountStore = useAccountStore()
     const account = computed(() => accountStore.filterAccountsByCurrencyId(currencyid, goodscurrencyid)).value[0] ?? {}
 
+    const openAmount = price*OrderQty*agreeunit
+
     // 可用余额
     const maxBalance =  account.avaiableBalance
     // 预估手续费 1 比率 2 固定 预估手续费(小数位根据币种小数位格式化):
     // 手续费设置(固定) 时:预估手续费 = 数量 * 合约乘数 * 固定值
     // 手续费设置(比率) 时:预估手续费 = 价格 * 数量 * 合约乘数 * 比率值
-    const buyEstimatedFee = (feeValue.FeeAlgorithm === 1 ? OrderPrice : 1)*OrderQty*agreeunit*feeValue.feeValue
+    const buyEstimatedFee = (marketmarginalgorithm === 2 ? price : 1)*OrderQty*agreeunit*marketmarginvalue
     // 可开数量 1 比率 2 固定
     // 可开数量(整数,向下取整):
     // 保证金设置(固定) 时:可开数量 = 可用余额 / (合约乘数 * 固定值)
     // 保证金设置(比率) 时:可开数量 = 可用余额 / (价格 * 合约乘数 * 比率值)
-    const maxBuyQty =  feeValue.FeeAlgorithm === 1 ? maxBalance/(agreeunit*feeValue.feeValue) : maxBalance/(OrderPrice*agreeunit*feeValue.feeValue)
+    console.log(marketmarginalgorithm, marketmarginvalue)
+
+    const maxBuyQty = marketmarginalgorithm === 2 ? maxBalance/(agreeunit*marketmarginvalue) : maxBalance/(price*agreeunit*marketmarginvalue)
     return {
         estimatedAmount,
         maxBalance,
         maxBuyQty,
         buyEstimatedFee,
+        openAmount
     }
 })
 
@@ -324,19 +327,6 @@ const routerToChart = () => {
     })
 }
 
-// 开仓价值
-const openAmount = computed(() => {
-    const { agreeunit = 0.0 } = goods.value ?? {}
-    const orderQty = formData.OrderQty ?? 0.0
-    if (formData.PriceMode === PriceMode.Market) {
-        const price = (formData.BuyOrSell === BuyOrSell.Buy ? quote.value?.ask : quote.value?.bid) ?? 0.0
-        return price * orderQty * agreeunit
-    } else {
-        const price = formData.OrderPrice ?? 0.0
-        return price * orderQty * agreeunit
-    }
-})
-
 const buyOrSell = (item: BuyOrSell) => {
     const { bid = 0, ask = 0 } = quote.value ?? {}
     formData.BuyOrSell = item