|
@@ -59,60 +59,6 @@
|
|
|
<Cell title="可开数量" :value="handleNoneValue(formatDecimal(calculations.maxBuyQty, 0))" />
|
|
<Cell title="可开数量" :value="handleNoneValue(formatDecimal(calculations.maxBuyQty, 0))" />
|
|
|
<Cell title="预估手续费" :value="formatDecimal(calculations.buyEstimatedFee)" />
|
|
<Cell title="预估手续费" :value="formatDecimal(calculations.buyEstimatedFee)" />
|
|
|
</CellGroup>
|
|
</CellGroup>
|
|
|
- <!-- 任务 #7130 -->
|
|
|
|
|
- <div class="order-tpsl" v-if="quote?.tpslflag">
|
|
|
|
|
- <div class="order-tpsl__tp">
|
|
|
|
|
- <div class="left">
|
|
|
|
|
- <Checkbox v-model="formData.TPFlag" :disabled="!!quote.tpslforceflag">{{
|
|
|
|
|
- $t('tss.tpspforceflag') }}
|
|
|
|
|
- </Checkbox>
|
|
|
|
|
- </div>
|
|
|
|
|
- <div class="right">
|
|
|
|
|
- <div class="right-top">
|
|
|
|
|
- <span>{{ $t('tss.stopLossSpread') }}{{ (tpsl.takeProfitSpread > 0 ? '+' : '')
|
|
|
|
|
- + tpsl.takeProfitSpread.toFixed(quote.decimalplace) }}</span>
|
|
|
|
|
- <span class="g-price-up">[{{ takeProfitRatio.toFixed(2) }}%]</span>
|
|
|
|
|
- <span class="g-price-up">+{{ tpsl.takeProfit.toFixed(2) }}</span>
|
|
|
|
|
- </div>
|
|
|
|
|
- <div class="right-bottom">
|
|
|
|
|
- <Button size="small" icon="minus"
|
|
|
|
|
- :disabled="!formData.TPFlag || takeProfitRatio <= profitLossLimits.minProfitRatio" round
|
|
|
|
|
- @click="sliderDecrease()" />
|
|
|
|
|
- <Slider v-model="takeProfitRatio" :bar-height="6" :min="profitLossLimits.minProfitRatio"
|
|
|
|
|
- :max="profitLossLimits.maxProfitRatio" :step="sliderStep"
|
|
|
|
|
- :disabled="!formData.TPFlag" />
|
|
|
|
|
- <Button size="small" icon="plus"
|
|
|
|
|
- :disabled="!formData.TPFlag || takeProfitRatio >= profitLossLimits.maxProfitRatio" round
|
|
|
|
|
- @click="sliderIncrease()" />
|
|
|
|
|
- </div>
|
|
|
|
|
- </div>
|
|
|
|
|
- </div>
|
|
|
|
|
- <div class="order-tpsl__sl">
|
|
|
|
|
- <div class="left">
|
|
|
|
|
- <Checkbox v-model="formData.SLFlag" :disabled="!!quote?.tpslforceflag">{{
|
|
|
|
|
- $t('tss.tpslforceflag') }}
|
|
|
|
|
- </Checkbox>
|
|
|
|
|
- </div>
|
|
|
|
|
- <div class="right">
|
|
|
|
|
- <div class="right-top">
|
|
|
|
|
- <span>{{ $t('tss.stopLossSpread') }}{{ (tpsl.stopLossSpread > 0 ? '+' : '')
|
|
|
|
|
- + tpsl.stopLossSpread.toFixed(quote.decimalplace) }}</span>
|
|
|
|
|
- <span class="g-price-down">[{{ stopLossRatio.toFixed(2) }}%]</span>
|
|
|
|
|
- <span class="g-price-down">{{ tpsl.stopLoss.toFixed(2) }}</span>
|
|
|
|
|
- </div>
|
|
|
|
|
- <div class="right-bottom">
|
|
|
|
|
- <Button size="small" icon="minus"
|
|
|
|
|
- :disabled="!formData.SLFlag || stopLossRatio <= profitLossLimits.minLossRatio" round
|
|
|
|
|
- @click="sliderDecrease('sl')" />
|
|
|
|
|
- <Slider v-model="stopLossRatio" :bar-height="6" :min="profitLossLimits.minLossRatio"
|
|
|
|
|
- :max="profitLossLimits.maxLossRatio" :step="sliderStep" :disabled="!formData.SLFlag" />
|
|
|
|
|
- <Button size="small" icon="plus"
|
|
|
|
|
- :disabled="!formData.SLFlag || stopLossRatio >= profitLossLimits.maxLossRatio" round
|
|
|
|
|
- @click="sliderIncrease('sl')" />
|
|
|
|
|
- </div>
|
|
|
|
|
- </div>
|
|
|
|
|
- </div>
|
|
|
|
|
- </div>
|
|
|
|
|
</Form>
|
|
</Form>
|
|
|
<Row class="g-layout-block g-layout-block--inset">
|
|
<Row class="g-layout-block g-layout-block--inset">
|
|
|
<Col span="24">
|
|
<Col span="24">
|
|
@@ -137,7 +83,7 @@
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
|
<script lang="ts" setup>
|
|
|
import { shallowRef, computed, onMounted, onActivated } from 'vue'
|
|
import { shallowRef, computed, onMounted, onActivated } from 'vue'
|
|
|
-import { Form, FormInstance, Button, CellGroup, Field, Cell, Tab, Tabs, FieldRule, Col, Row, Slider, Checkbox } from 'vant'
|
|
|
|
|
|
|
+import { Form, FormInstance, Button, CellGroup, Field, Cell, Tab, Tabs, FieldRule, Col, Row } from 'vant'
|
|
|
import { EValidType, EOrderOperateType, EBuildType } from '@/constants/client'
|
|
import { EValidType, EOrderOperateType, EBuildType } from '@/constants/client'
|
|
|
import { formatDecimal, handleNoneValue, handleNumberValue, parsePercent } from '@/filters'
|
|
import { formatDecimal, handleNoneValue, handleNumberValue, parsePercent } from '@/filters'
|
|
|
import { useNavigation } from '@mobile/router/navigation'
|
|
import { useNavigation } from '@mobile/router/navigation'
|
|
@@ -161,13 +107,8 @@ const { global: { t } } = i18n
|
|
|
const formRef = shallowRef<FormInstance>()
|
|
const formRef = shallowRef<FormInstance>()
|
|
|
const showModal = shallowRef(true)
|
|
const showModal = shallowRef(true)
|
|
|
|
|
|
|
|
-const accountStore = useAccountStore()
|
|
|
|
|
const userStore = useUserStore()
|
|
const userStore = useUserStore()
|
|
|
-
|
|
|
|
|
const { formData, formSubmit } = useOrder()
|
|
const { formData, formSubmit } = useOrder()
|
|
|
-const takeProfitRatio = shallowRef(0) // 止盈比例
|
|
|
|
|
-const stopLossRatio = shallowRef(0) // 止损比例
|
|
|
|
|
-const sliderStep = 0.01 // 滑块步长
|
|
|
|
|
|
|
|
|
|
const { getSBYJMyOrders } = useSBYJOrderStore()
|
|
const { getSBYJMyOrders } = useSBYJOrderStore()
|
|
|
const goods = computed(() => futuresStore.getGoods(goodsId ?? 0)) ?? {}
|
|
const goods = computed(() => futuresStore.getGoods(goodsId ?? 0)) ?? {}
|
|
@@ -186,99 +127,6 @@ const enumName = computed(() => {
|
|
|
return getGoodsCurrencyItemName(quote.value?.currencyid ?? 0)
|
|
return getGoodsCurrencyItemName(quote.value?.currencyid ?? 0)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
-// 计算市价
|
|
|
|
|
-const marketPrice = computed(() => {
|
|
|
|
|
- const { ask = 0, bid = 0 } = quote.value ?? {}
|
|
|
|
|
- return formData.BuyOrSell === BuyOrSell.Buy ? ask : bid
|
|
|
|
|
-})
|
|
|
|
|
-
|
|
|
|
|
-// 预付款
|
|
|
|
|
-const usedMargin = computed(() => {
|
|
|
|
|
- const { avaiableBalance = 0 } = accountStore.currentAccount
|
|
|
|
|
- const { marketmarginalgorithm = 0, marketmarginvalue = 0, agreeunit = 0 } = quote.value ?? {}
|
|
|
|
|
-
|
|
|
|
|
- // 结果集合
|
|
|
|
|
- const result = {
|
|
|
|
|
- enableQty: 0,
|
|
|
|
|
- deposit: 0
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- const fixed = agreeunit * marketmarginvalue
|
|
|
|
|
- const ratio = fixed * marketPrice.value
|
|
|
|
|
-
|
|
|
|
|
- if (fixed && ratio) {
|
|
|
|
|
- const { OrderQty = 0 } = formData
|
|
|
|
|
- if (marketmarginalgorithm === 1) {
|
|
|
|
|
- const qty = Math.trunc(avaiableBalance / ratio)
|
|
|
|
|
- result.deposit = OrderQty * ratio
|
|
|
|
|
- result.enableQty = qty > 0 ? qty : 0
|
|
|
|
|
- }
|
|
|
|
|
- if (marketmarginalgorithm === 2) {
|
|
|
|
|
- const qty = Math.trunc(avaiableBalance / fixed)
|
|
|
|
|
- result.deposit = OrderQty * fixed
|
|
|
|
|
- result.enableQty = qty > 0 ? qty : 0
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- return result
|
|
|
|
|
-})
|
|
|
|
|
-
|
|
|
|
|
-// 计算盈亏
|
|
|
|
|
-const calcProfitLoss = (ratio: number, profitLoss: 1 | -1) => usedMargin.value.deposit * (ratio / 100) * profitLoss
|
|
|
|
|
-
|
|
|
|
|
-// 计算价差
|
|
|
|
|
-const calcSpread = (value: number, profitLoss: 1 | -1) => {
|
|
|
|
|
- const { agreeunit = 0, decimalplace = 0 } = quote.value ?? {}
|
|
|
|
|
- const { OrderQty = 0 } = formData
|
|
|
|
|
- const spread = value / (OrderQty * agreeunit)
|
|
|
|
|
- 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)
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-// 盈亏比限制
|
|
|
|
|
-const profitLossLimits = computed(() => {
|
|
|
|
|
- const { tpratioup = 0, tpratiodown = 0, slratioup = 0, slratiodown = 0 } = quote.value ?? {}
|
|
|
|
|
- return {
|
|
|
|
|
- maxProfitRatio: tpratioup * 100,
|
|
|
|
|
- minProfitRatio: tpratiodown * 100,
|
|
|
|
|
- maxLossRatio: slratioup * 100,
|
|
|
|
|
- minLossRatio: slratiodown * 100
|
|
|
|
|
- }
|
|
|
|
|
-})
|
|
|
|
|
-
|
|
|
|
|
-// 滑块增加
|
|
|
|
|
-const sliderIncrease = (actionName = 'tp') => {
|
|
|
|
|
- if (actionName === 'tp') {
|
|
|
|
|
- takeProfitRatio.value += sliderStep
|
|
|
|
|
- } else {
|
|
|
|
|
- stopLossRatio.value += sliderStep
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-// 滑块减少
|
|
|
|
|
-const sliderDecrease = (actionName = 'tp') => {
|
|
|
|
|
- if (actionName === 'tp') {
|
|
|
|
|
- takeProfitRatio.value -= sliderStep
|
|
|
|
|
- } else {
|
|
|
|
|
- stopLossRatio.value -= sliderStep
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-// 止盈止损
|
|
|
|
|
-const tpsl = computed(() => {
|
|
|
|
|
- const takeProfit = calcProfitLoss(takeProfitRatio.value, 1) // 盈利
|
|
|
|
|
- const takeProfitSpread = calcSpread(takeProfit, 1) // 止盈价差
|
|
|
|
|
- const stopLoss = calcProfitLoss(stopLossRatio.value, -1) // 亏损
|
|
|
|
|
- const stopLossSpread = calcSpread(stopLoss, -1) // 止损价差
|
|
|
|
|
-
|
|
|
|
|
- return {
|
|
|
|
|
- takeProfit,
|
|
|
|
|
- takeProfitSpread,
|
|
|
|
|
- stopLoss,
|
|
|
|
|
- stopLossSpread
|
|
|
|
|
- }
|
|
|
|
|
-})
|
|
|
|
|
-
|
|
|
|
|
// 可开数量(整数,向下取整):
|
|
// 可开数量(整数,向下取整):
|
|
|
// 保证金设置(固定) 时:可开数量 = 可用余额 / (合约乘数 * 固定值)
|
|
// 保证金设置(固定) 时:可开数量 = 可用余额 / (合约乘数 * 固定值)
|
|
|
// 保证金设置(比率) 时:可开数量 = 可用余额 / (价格 * 合约乘数 * 比率值)
|
|
// 保证金设置(比率) 时:可开数量 = 可用余额 / (价格 * 合约乘数 * 比率值)
|
|
@@ -363,7 +211,7 @@ const onSubmit = () => {
|
|
|
message: '确认要提交吗?',
|
|
message: '确认要提交吗?',
|
|
|
showCancelButton: true,
|
|
showCancelButton: true,
|
|
|
}).then(() => {
|
|
}).then(() => {
|
|
|
- const { marketid = 0, goodsid = 0, tpslflag = 0 } = quote.value ?? {}
|
|
|
|
|
|
|
+ const { marketid = 0, goodsid = 0 } = quote.value ?? {}
|
|
|
/// 获取对应的市场ID
|
|
/// 获取对应的市场ID
|
|
|
formData.MarketID = marketid
|
|
formData.MarketID = marketid
|
|
|
formData.GoodsID = goodsid
|
|
formData.GoodsID = goodsid
|
|
@@ -373,14 +221,6 @@ const onSubmit = () => {
|
|
|
const param112 = userStore.getSystemParamValue('112')
|
|
const param112 = userStore.getSystemParamValue('112')
|
|
|
formData.MarketMaxSub = Number(param112) || 100
|
|
formData.MarketMaxSub = Number(param112) || 100
|
|
|
|
|
|
|
|
- // 止盈止损
|
|
|
|
|
- if (tpslflag) {
|
|
|
|
|
- formData.TPRatio = formData.TPFlag ? takeProfitRatio.value / 100 : 0
|
|
|
|
|
- formData.SLRatio = formData.SLFlag ? stopLossRatio.value / 100 : 0
|
|
|
|
|
- formData.TPFlag = Number(formData.TPFlag)
|
|
|
|
|
- formData.SLFlag = Number(formData.SLFlag)
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
fullloading((hideLoading) => {
|
|
fullloading((hideLoading) => {
|
|
|
formSubmit().then(() => {
|
|
formSubmit().then(() => {
|
|
|
hideLoading('提交成功。', 'success')
|
|
hideLoading('提交成功。', 'success')
|
|
@@ -395,18 +235,9 @@ const onSubmit = () => {
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
|
if (quote.value) {
|
|
if (quote.value) {
|
|
|
- const { tpslflag = 0, tpratiodefault = 0, slratiodefault = 0 } = quote.value ?? {}
|
|
|
|
|
-
|
|
|
|
|
formData.BuyOrSell = BuyOrSell.Buy
|
|
formData.BuyOrSell = BuyOrSell.Buy
|
|
|
formData.PriceMode = PriceMode.Market
|
|
formData.PriceMode = PriceMode.Market
|
|
|
formData.OrderPrice = formData.BuyOrSell === BuyOrSell.Buy ? quote.value.ask : quote.value.bid
|
|
formData.OrderPrice = formData.BuyOrSell === BuyOrSell.Buy ? quote.value.ask : quote.value.bid
|
|
|
-
|
|
|
|
|
- if (tpslflag) {
|
|
|
|
|
- formData.TPFlag = 1
|
|
|
|
|
- formData.SLFlag = 1
|
|
|
|
|
- takeProfitRatio.value = tpratiodefault * 100
|
|
|
|
|
- stopLossRatio.value = slratiodefault * 100
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
onActivated(() => {
|
|
onActivated(() => {
|