|
|
@@ -70,14 +70,14 @@ export function handleNumAndMoney(enumName: EnumRouterName, buyOrSell: BuyOrSell
|
|
|
const rules = getRules()
|
|
|
// 是否有规则
|
|
|
const hasRule = () => rules.length > 0;
|
|
|
+ const { buymarginvalue, buymarginalgorithm } = rules[0]
|
|
|
//保证金模式 1: 比率 2: 固定
|
|
|
- const marginMethod = (buymarginalgorithm: number) => buymarginalgorithm === 1
|
|
|
+ const marginMethod = () => buymarginalgorithm === 1
|
|
|
const { fixedprice, orderqty, pricemove } = selectedRow;
|
|
|
// 获取摘牌最大可摘量
|
|
|
function getMaxNum() {
|
|
|
let result = 0;
|
|
|
if (hasRule()) {
|
|
|
- const { buymarginvalue, buymarginalgorithm } = rules[0]
|
|
|
// 可用资金
|
|
|
const canUseMoney = Number(getCanUseMoney(getSelectedAccount() as AccountListItem))
|
|
|
if (!isBuy()) {
|
|
|
@@ -88,13 +88,13 @@ export function handleNumAndMoney(enumName: EnumRouterName, buyOrSell: BuyOrSell
|
|
|
// 估算总价
|
|
|
const predictTotal = pricemove + (goodsPrice.value as number);
|
|
|
// 买方履约保证金比例*估算总价
|
|
|
- const marginMoney = marginMethod(buymarginalgorithm) ? (buymarginvalue * predictTotal) : (buymarginvalue + predictTotal)
|
|
|
+ const marginMoney = marginMethod() ? (buymarginvalue * predictTotal) : (buymarginvalue + predictTotal)
|
|
|
// 浮动价 摘买 最大数量=min{可用资金/(买方履约保证金比例*估算总价),挂牌数量}
|
|
|
result = Math.min(orderqty, canUseMoney / marginMoney)
|
|
|
}
|
|
|
} else {
|
|
|
// 买方履约保证金比例*挂牌价格
|
|
|
- const marginMoney = marginMethod(buymarginalgorithm) ? (buymarginvalue * fixedprice) : (buymarginvalue + fixedprice)
|
|
|
+ const marginMoney = marginMethod() ? (buymarginvalue * fixedprice) : (buymarginvalue + fixedprice)
|
|
|
// 一口价 摘买 最大数量=min{挂牌数量,可用资金/(买方履约保证金比例*挂牌价格)
|
|
|
result = Math.min(orderqty, canUseMoney / marginMoney)
|
|
|
}
|
|
|
@@ -145,11 +145,8 @@ export function handleNumAndMoney(enumName: EnumRouterName, buyOrSell: BuyOrSell
|
|
|
let result = 0
|
|
|
if (hasRule()) {
|
|
|
const { buymarginvalue, sellmarginvalue } = rules[0]
|
|
|
- if (isBuy()) {
|
|
|
- result = sellmarginvalue * getMoney()
|
|
|
- } else {
|
|
|
- result = buymarginvalue * getMoney()
|
|
|
- }
|
|
|
+ const margin = isBuy() ? sellmarginvalue : buymarginvalue
|
|
|
+ result = marginMethod() ? margin * getMoney() : margin + getMoney()
|
|
|
}
|
|
|
return Number(result.toFixed(2))
|
|
|
}
|