|
@@ -3,13 +3,15 @@ import { EnumRouterName } from "@/common/constants/enumRouterName";
|
|
|
import { queryResultLoadingAndInfo } from "@/common/methods/request/resultInfo";
|
|
import { queryResultLoadingAndInfo } from "@/common/methods/request/resultInfo";
|
|
|
import { getAccountTypeList, getCanUseMoney } from "@/services/bus/account";
|
|
import { getAccountTypeList, getCanUseMoney } from "@/services/bus/account";
|
|
|
import { getGoodsAgreeunitByGoodsCode, getQuoteDayInfoByCodeFindPrice } from "@/services/bus/goods";
|
|
import { getGoodsAgreeunitByGoodsCode, getQuoteDayInfoByCodeFindPrice } from "@/services/bus/goods";
|
|
|
-import { getRules } from '@/services/bus/rules';
|
|
|
|
|
|
|
+import { getRulesByMarketid } from '@/services/bus/rules';
|
|
|
import { AccountListItem } from "@/services/dataCenter/interafce/account";
|
|
import { AccountListItem } from "@/services/dataCenter/interafce/account";
|
|
|
import { queryHoldLB, queryWrPosition } from '@/services/go/wrtrade';
|
|
import { queryHoldLB, queryWrPosition } from '@/services/go/wrtrade';
|
|
|
import { QueryWrPositionReq, WrHoldLB, WrOrderQuote, WrOrderQuoteDetail, WrPosition } from "@/services/go/wrtrade/interface";
|
|
import { QueryWrPositionReq, WrHoldLB, WrOrderQuote, WrOrderQuoteDetail, WrPosition } from "@/services/go/wrtrade/interface";
|
|
|
import { reactive, Ref, ref, UnwrapRef } from "vue";
|
|
import { reactive, Ref, ref, UnwrapRef } from "vue";
|
|
|
import { handleIs } from "../../setup";
|
|
import { handleIs } from "../../setup";
|
|
|
import { ListingForm, Wrhold } from "./interface";
|
|
import { ListingForm, Wrhold } from "./interface";
|
|
|
|
|
+import APP from '@/services'
|
|
|
|
|
+import { TjmdMarketSectionConfig } from '@/services/go/Tjmd/interface'
|
|
|
|
|
|
|
|
export function handleForm(data: WrOrderQuoteDetail) {
|
|
export function handleForm(data: WrOrderQuoteDetail) {
|
|
|
const formRef = ref();
|
|
const formRef = ref();
|
|
@@ -72,17 +74,55 @@ export function handleNumAndMoney(enumName: EnumRouterName, buyOrSell: BuyOrSell
|
|
|
// 获取选中的资金账号
|
|
// 获取选中的资金账号
|
|
|
const getSelectedAccount = () => accountList.find((e) => e.accountid === formState.accountid);
|
|
const getSelectedAccount = () => accountList.find((e) => e.accountid === formState.accountid);
|
|
|
// 交易规则
|
|
// 交易规则
|
|
|
- const rules = getRules()
|
|
|
|
|
- // 是否有规则
|
|
|
|
|
- const hasRule = () => rules.length > 0;
|
|
|
|
|
- const { buymarginvalue, buymarginalgorithm } = rules.length ? rules[0] : { buymarginvalue: 0, buymarginalgorithm: 1 }
|
|
|
|
|
|
|
+ const rules = getRulesByMarketid(selectedRow.marketid ?? 0)
|
|
|
|
|
+
|
|
|
//保证金模式 1: 比率 2: 固定
|
|
//保证金模式 1: 比率 2: 固定
|
|
|
- const marginMethod = () => buymarginalgorithm === 1
|
|
|
|
|
|
|
+ const marginMethod = () => {
|
|
|
|
|
+ if (rules) {
|
|
|
|
|
+ switch (selectedRow.buyorsell) {
|
|
|
|
|
+ case BuyOrSell.buy: {
|
|
|
|
|
+ return rules.buymarginalgorithm === 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ case BuyOrSell.sell: {
|
|
|
|
|
+ return rules.sellmarginalgorithm === 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 获取保证金比例
|
|
|
|
|
+ const getMarginValue = () => {
|
|
|
|
|
+ if (rules) {
|
|
|
|
|
+ switch (selectedRow.buyorsell) {
|
|
|
|
|
+ case BuyOrSell.sell: {
|
|
|
|
|
+ return rules.buymarginvalue;
|
|
|
|
|
+ }
|
|
|
|
|
+ case BuyOrSell.buy: {
|
|
|
|
|
+ const market = APP.get('markets').find((e: TjmdMarketSectionConfig) => e.marketid === selectedRow.marketid)
|
|
|
|
|
+ if (market) {
|
|
|
|
|
+ switch (market.auctionwrtype) {
|
|
|
|
|
+ // 无仓单
|
|
|
|
|
+ case 1: {
|
|
|
|
|
+ return rules.sellmarginvalue2;
|
|
|
|
|
+ }
|
|
|
|
|
+ // 有仓单
|
|
|
|
|
+ default: {
|
|
|
|
|
+ return rules.sellmarginvalue;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return 0;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
const { fixedprice, orderqty, pricemove } = selectedRow;
|
|
const { fixedprice, orderqty, pricemove } = selectedRow;
|
|
|
// 获取摘牌最大可摘量
|
|
// 获取摘牌最大可摘量
|
|
|
function getMaxNum() {
|
|
function getMaxNum() {
|
|
|
let result = 0;
|
|
let result = 0;
|
|
|
- if (hasRule()) {
|
|
|
|
|
|
|
+ if (rules) {
|
|
|
let marginMoney = 0;
|
|
let marginMoney = 0;
|
|
|
// 可用资金
|
|
// 可用资金
|
|
|
const canUseMoney = Number(getCanUseMoney(getSelectedAccount() as AccountListItem))
|
|
const canUseMoney = Number(getCanUseMoney(getSelectedAccount() as AccountListItem))
|
|
@@ -94,11 +134,11 @@ export function handleNumAndMoney(enumName: EnumRouterName, buyOrSell: BuyOrSell
|
|
|
// 估算总价
|
|
// 估算总价
|
|
|
const predictTotal = pricemove + (goodsPrice as number);
|
|
const predictTotal = pricemove + (goodsPrice as number);
|
|
|
// 买方履约保证金比例*估算总价
|
|
// 买方履约保证金比例*估算总价
|
|
|
- marginMoney = marginMethod() ? (buymarginvalue * predictTotal) : (buymarginvalue + predictTotal)
|
|
|
|
|
|
|
+ marginMoney = marginMethod() ? (rules.buymarginvalue * predictTotal) : (rules.buymarginvalue + predictTotal)
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
// 买方履约保证金比例*挂牌价格
|
|
// 买方履约保证金比例*挂牌价格
|
|
|
- marginMoney = marginMethod() ? (buymarginvalue * fixedprice) : (buymarginvalue + fixedprice)
|
|
|
|
|
|
|
+ marginMoney = marginMethod() ? (rules.buymarginvalue * fixedprice) : (rules.buymarginvalue + fixedprice)
|
|
|
}
|
|
}
|
|
|
if (marginMoney > 0) {
|
|
if (marginMoney > 0) {
|
|
|
// 摘买 最大数量
|
|
// 摘买 最大数量
|
|
@@ -149,12 +189,7 @@ export function handleNumAndMoney(enumName: EnumRouterName, buyOrSell: BuyOrSell
|
|
|
// fixed bull 履约保证金=买方履约保证金比例*摘牌金额
|
|
// fixed bull 履约保证金=买方履约保证金比例*摘牌金额
|
|
|
// floor sell 履约保证金=卖方履约保证金比例*估算总额,履约保证金为0则括号内容不显示
|
|
// floor sell 履约保证金=卖方履约保证金比例*估算总额,履约保证金为0则括号内容不显示
|
|
|
// floor buy 履约保证金=买方履约保证金比例*估算总额
|
|
// floor buy 履约保证金=买方履约保证金比例*估算总额
|
|
|
- let result = 0
|
|
|
|
|
- if (hasRule()) {
|
|
|
|
|
- const { buymarginvalue, sellmarginvalue } = rules[0]
|
|
|
|
|
- const margin = isBuy() ? sellmarginvalue : buymarginvalue
|
|
|
|
|
- result = marginMethod() ? margin * getMoney() : margin + getMoney()
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ const result = marginMethod() ? getMarginValue() * getMoney() : getMarginValue() + getMoney()
|
|
|
return Number(result.toFixed(2))
|
|
return Number(result.toFixed(2))
|
|
|
}
|
|
}
|
|
|
return { getMaxNum, getMoney, getMargin }
|
|
return { getMaxNum, getMoney, getMargin }
|