Merge remote-tracking branch 'origin/glms/feature/1.4.2' into glms/feature/1.4.2
This commit is contained in:
@@ -12,11 +12,39 @@ const inputFormatTradeAmount = Object.freeze({ precision: otcformat.trading.noti
|
||||
const inputFormatSwapRate = Object.freeze({ precision: otcformat.trading.premiumRateP.precision, negative: true, append: '%' });
|
||||
const inputFormatTradePrice = Object.freeze({ precision: otcformat.trading.tradePrice.precision, negative: true, append: '' });
|
||||
const inputFormatTradeSinglePrice = Object.freeze({ precision: otcformat.trading.tradeSinglePrice.precision, negative: true, append: '', percent: false });
|
||||
const inputFormatPosiFeePercent = Object.freeze({ precision: 4, negative: true, append: '%' });
|
||||
const inputFormatPosiFeeUnit = Object.freeze({ precision: 2, negative: true, append: '' });
|
||||
const inputFormatMarginRate = Object.freeze({ precision: otcformat.trading.marginRateP.precision, append: '%' });
|
||||
const inputFormatSwapDeliveryPrice = Object.freeze({ precision: 9, negative: true, append: '', percent: false });
|
||||
const inputFormatSwapBondDeliveryPrice = Object.freeze({ precision: 9, negative: true, append: '', percent: true });
|
||||
const inputFormatSwapBondNetPriceAndYtm = Object.freeze({ precision: 9, negative: true, append: '', percent: true });
|
||||
const swapBondStoragePricePrecision = inputFormatSwapBondDeliveryPrice.precision + 2;
|
||||
const consPosiFeeType = Object.freeze({ Percent: 0, Unit: 1 });
|
||||
const swapPosiFeeCalc = Object.freeze({
|
||||
normalizeFeeType(feeType) {
|
||||
return Number(feeType) === consPosiFeeType.Unit ? consPosiFeeType.Unit : consPosiFeeType.Percent;
|
||||
},
|
||||
calcPending(feeType, feeUnit, stockEqvNotional, quantity) {
|
||||
const normalizedFeeType = this.normalizeFeeType(feeType);
|
||||
const normalizedFeeUnit = Number(feeUnit) || 0;
|
||||
const normalizedNotional = Number(stockEqvNotional) || 0;
|
||||
const normalizedQuantity = Number(quantity) || 0;
|
||||
const tradingFeePending = normalizedFeeType === consPosiFeeType.Percent
|
||||
? normalizedFeeUnit / 100 * normalizedNotional
|
||||
: normalizedFeeUnit * normalizedQuantity;
|
||||
return otcformat.trading.tradeSinglePrice(tradingFeePending);
|
||||
},
|
||||
calcFeeUnit(feeType, tradingFeePending, stockEqvNotional, quantity) {
|
||||
const normalizedFeeType = this.normalizeFeeType(feeType);
|
||||
const normalizedTradingFeePending = Number(tradingFeePending) || 0;
|
||||
const normalizedNotional = Number(stockEqvNotional) || 0;
|
||||
const normalizedQuantity = Number(quantity) || 0;
|
||||
if (normalizedFeeType === consPosiFeeType.Percent) {
|
||||
return normalizedNotional === 0 ? 0 : _.round(normalizedTradingFeePending / normalizedNotional * 100, inputFormatPosiFeePercent.precision);
|
||||
}
|
||||
return normalizedQuantity === 0 ? 0 : _.round(normalizedTradingFeePending / normalizedQuantity, inputFormatPosiFeeUnit.precision);
|
||||
}
|
||||
});
|
||||
|
||||
const consUnderlyingFlagBase = (function () {
|
||||
let unSelFlag = tradeHelper.UnderlyingSelectFlag;
|
||||
@@ -153,6 +181,7 @@ const vue = new Vue({
|
||||
currencys: page.currencys,
|
||||
getNotionalSingleFee: 0,
|
||||
isSingleFee: page.Trade.trade_extend.ExtendObj.OpenFeeType == 0,
|
||||
posiFeeModePercent: true,
|
||||
observation: {//互换观察日
|
||||
ObservationInterval: "",
|
||||
IntervalList: [],
|
||||
@@ -236,6 +265,41 @@ const vue = new Vue({
|
||||
const isBond = tradeHelper.IsBond(item && item.UnderlyingInstrumentType);
|
||||
return `${index}-${field}-${isBond ? 'bond' : 'other'}`;
|
||||
},
|
||||
getCurrentPosiFeeType() {
|
||||
return this.posiFeeModePercent ? consPosiFeeType.Percent : consPosiFeeType.Unit;
|
||||
},
|
||||
normalizePosiFeeType(feeType) {
|
||||
return swapPosiFeeCalc.normalizeFeeType(feeType);
|
||||
},
|
||||
syncPosiFeeModeByItem(item) {
|
||||
this.posiFeeModePercent = this.normalizePosiFeeType(item && item.PosiFeeType) !== consPosiFeeType.Unit;
|
||||
},
|
||||
syncPayItemFeeType(item) {
|
||||
item.PosiFeeType = this.getCurrentPosiFeeType();
|
||||
},
|
||||
refreshTradingFeePendingByUnit(item) {
|
||||
this.syncPayItemFeeType(item);
|
||||
item.PosiTradingFeePending = swapPosiFeeCalc.calcPending(
|
||||
item.PosiFeeType,
|
||||
item.PosiTradingFeeUnit,
|
||||
this.trade.StockEqvNotional,
|
||||
item.PosiQuantity
|
||||
);
|
||||
},
|
||||
refreshTradingFeeUnitByPending(item) {
|
||||
this.syncPayItemFeeType(item);
|
||||
item.PosiTradingFeeUnit = swapPosiFeeCalc.calcFeeUnit(
|
||||
item.PosiFeeType,
|
||||
item.PosiTradingFeePending,
|
||||
this.trade.StockEqvNotional,
|
||||
item.PosiQuantity
|
||||
);
|
||||
},
|
||||
refreshPayTradingFeesByUnit() {
|
||||
this.paySwapList.forEach(item => {
|
||||
this.refreshTradingFeePendingByUnit(item);
|
||||
});
|
||||
},
|
||||
changeStructureType() {
|
||||
this.trade.StockEqvNotional = 0;
|
||||
let direction = this.trade.trade_extend.ExtendObj.Direction;
|
||||
@@ -385,6 +449,7 @@ const vue = new Vue({
|
||||
//变更名义本金(仅格式化,不反算数量)
|
||||
changeStockEqvNotional() {
|
||||
this.trade.StockEqvNotional = otcformat.trading.StockEqvNotional(this.trade.StockEqvNotional);
|
||||
this.refreshPayTradingFeesByUnit();
|
||||
//计算数量
|
||||
// if (this.paySwapList.length > 0) {
|
||||
// var item = this.paySwapList[0];
|
||||
@@ -474,6 +539,7 @@ const vue = new Vue({
|
||||
var stockEqvNotional = SwapCalc.calcStockEqvNotional(deliveryPrice, national);//名义本金=期初价格*数量*乘数
|
||||
this.trade.StockEqvNotional = otcformat.trading.stockEqvNotional(stockEqvNotional);
|
||||
payItem.PosiNotionalValue = this.trade.StockEqvNotional;
|
||||
this.refreshPayTradingFeesByUnit();
|
||||
}
|
||||
},
|
||||
//变更到期日
|
||||
@@ -509,26 +575,27 @@ const vue = new Vue({
|
||||
},
|
||||
//变更单位交易费用
|
||||
changeTradingFeeUnit(item) {
|
||||
//计算交易费用
|
||||
//if (this.trade.trade_extend.ExtendObj.OpenFeeType == 0) {//按手数收费
|
||||
// item.PosiTradingFee = item.ContractSize == 0 ? 0 : otcformat.trading.tradeSinglePrice(item.PosiQuantity * item.PosiTradingFeeUnit / item.ContractSize);
|
||||
//} else {
|
||||
// item.PosiTradingFee = otcformat.trading.tradeSinglePrice(item.PosiQuantity * item.PosiTradingFeeUnit);
|
||||
//}
|
||||
|
||||
this.refreshTradingFeePendingByUnit(item);
|
||||
},
|
||||
//变更交易费用
|
||||
changeTradingFee(item) {
|
||||
//计算单位交易费用
|
||||
//if (item.PosiQuantity == 0) {
|
||||
// item.PosiTradingFeeUnit = 0;
|
||||
// return
|
||||
//}
|
||||
//if (this.trade.trade_extend.ExtendObj.OpenFeeType == 0) {//按手数收费
|
||||
// item.PosiTradingFeeUnit = item.ContractSize == 0 ? 0 : otcformat.trading.tradeSinglePrice(item.PosiTradingFee * item.ContractSize / item.PosiQuantity);
|
||||
//} else {
|
||||
// item.PosiTradingFeeUnit = otcformat.trading.tradeSinglePrice(item.PosiTradingFee / item.PosiQuantity);
|
||||
//}
|
||||
this.refreshTradingFeeUnitByPending(item);
|
||||
},
|
||||
showPayAbsPrice() {
|
||||
this.posiFeeModePercent = false;
|
||||
this.paySwapList.forEach(item => {
|
||||
item.PosiFeeType = consPosiFeeType.Unit;
|
||||
item.PosiTradingFeeUnit = 0;
|
||||
item.PosiTradingFeePending = 0;
|
||||
});
|
||||
},
|
||||
showPayPercentPrice() {
|
||||
this.posiFeeModePercent = true;
|
||||
this.paySwapList.forEach(item => {
|
||||
item.PosiFeeType = consPosiFeeType.Percent;
|
||||
item.PosiTradingFeeUnit = 0;
|
||||
item.PosiTradingFeePending = 0;
|
||||
});
|
||||
},
|
||||
savetrade() {
|
||||
if (!this.checkSubmitData()) {
|
||||
@@ -618,6 +685,7 @@ const vue = new Vue({
|
||||
x.PosiGrossPrice = thisObj.roundStorageDeliveryPrice(x, x.PosiGrossPrice);
|
||||
x.PosiNetNoFeePrice = thisObj.roundStorageBondNetPriceAndYtm(x.PosiNetNoFeePrice);
|
||||
x.InitYtm = x.InitYtm == null ? null : thisObj.roundStorageBondNetPriceAndYtm(x.InitYtm);
|
||||
x.PosiFeeType = thisObj.normalizePosiFeeType(x.PosiFeeType);
|
||||
thisObj.trade.swap_positions.push(x);
|
||||
});
|
||||
} else {
|
||||
@@ -1439,6 +1507,7 @@ const vue = new Vue({
|
||||
thisObj.paySwapList = thisObj.trade.swap_positions.filter(x => { if (x.UnderlyingCode != null && x.UnderlyingCode.length != 0 && x.IsInitial) return x; });
|
||||
thisObj.paySwapList.forEach((val, num, arr) => {
|
||||
arr[num].index = num;
|
||||
arr[num].PosiFeeType = thisObj.normalizePosiFeeType(arr[num].PosiFeeType);
|
||||
this.StockEqvNotional = val.ContractSize * val.PosiQuantity * val.PosiGrossPrice;
|
||||
// D2 修复:重开(审批重开/刷新)已保存的债券成交单时,三字段互算的手动标志随页面重置而丢失;
|
||||
// 若不锁,用户一旦编辑任一价格字段就会以它为源重新反算、覆盖当初保存的其他两格。
|
||||
@@ -1450,6 +1519,9 @@ const vue = new Vue({
|
||||
thisObj.$set(arr[num], 'bondManual', { CP: true, DP: true, YD: true });
|
||||
}
|
||||
});
|
||||
if (thisObj.paySwapList.length > 0) {
|
||||
thisObj.syncPosiFeeModeByItem(thisObj.paySwapList[0]);
|
||||
}
|
||||
}
|
||||
|
||||
if (thisObj.paySwapList.length == 0) {
|
||||
@@ -1576,6 +1648,7 @@ const vue = new Vue({
|
||||
PosiTradingFee: 0,//交易费用
|
||||
PosiTradingFeePending: 0,//交易费用后付
|
||||
PosiTradingFeeUnit: 0,//单位交易费用
|
||||
PosiFeeType: thisObj.getCurrentPosiFeeType(),//单位交易费用模式
|
||||
InterestDirection: 0,//利息收支方式
|
||||
InterestRateDefault: 0,//计息利率
|
||||
InterestMode: 0,//计息基本类型
|
||||
|
||||
@@ -8,6 +8,22 @@ const inputFormatEqvNotional = Object.freeze({ precision: otcformat.trading.Stoc
|
||||
const inputFormatMarginRate = Object.freeze({ precision: otcformat.trading.marginRateP.precision, append: '%' });
|
||||
const inputFormatMarginRateNoPercent = Object.freeze({ precision: otcformat.trading.umpriceP.precision, append: '', percent: true });
|
||||
const inputFormatSwapDeliveryPrice = Object.freeze({ precision: 9, append: '', negative: true });
|
||||
const consPosiFeeType = Object.freeze({ Percent: 0, Unit: 1 });
|
||||
const swapPosiFeeCalc = {
|
||||
normalizeFeeType(feeType) {
|
||||
return Number(feeType) === consPosiFeeType.Unit ? consPosiFeeType.Unit : consPosiFeeType.Percent;
|
||||
},
|
||||
calcTradingFee(feeType, feeUnit, closeNotionalValue, closeQty) {
|
||||
const normalizedFeeType = this.normalizeFeeType(feeType);
|
||||
const normalizedFeeUnit = Number(feeUnit) || 0;
|
||||
const normalizedCloseNotionalValue = Number(closeNotionalValue) || 0;
|
||||
const normalizedCloseQty = Number(closeQty) || 0;
|
||||
const tradingFee = normalizedFeeType === consPosiFeeType.Unit
|
||||
? normalizedFeeUnit * normalizedCloseQty
|
||||
: normalizedFeeUnit / 100 * normalizedCloseNotionalValue;
|
||||
return otcformat.trading.StockEqvNotional(_.round(tradingFee, 2));
|
||||
}
|
||||
};
|
||||
let ValueDate = model.ValueDate;
|
||||
const vue = new Vue({
|
||||
el: '#vueDiv',
|
||||
@@ -140,6 +156,7 @@ const vue = new Vue({
|
||||
this.deal.CloseQty = this.calcCloseQtyByPercent(this.deal.ClosePercent);
|
||||
}
|
||||
this.calcTradingFeePending();
|
||||
this.refreshTradingFeeByUnit();
|
||||
this.getInterestList();
|
||||
this.calcFloatClosePnl();
|
||||
},
|
||||
@@ -153,6 +170,13 @@ const vue = new Vue({
|
||||
calcTradingFeePending() {
|
||||
this.floatPosition.TradingFeePending = this.floatPosition.BeforeCloseFee * parseFloat(this.deal.ClosePercent);
|
||||
},
|
||||
refreshTradingFeeByUnit() {
|
||||
this.floatPosition.TradingFee = swapPosiFeeCalc.calcTradingFee(
|
||||
this.floatPosition.PosiFeeType,
|
||||
this.floatPosition.PosiTradingFeeUnit,
|
||||
this.deal.CloseNotionalValue,
|
||||
this.deal.CloseQty);
|
||||
},
|
||||
changeCloseQty() {//修改平仓数量
|
||||
if (parseFloat(this.deal.CloseQty) > parseFloat(this.deal.PositionQty)) {
|
||||
main.message("平仓数量不能超过持仓数量");
|
||||
@@ -169,6 +193,7 @@ const vue = new Vue({
|
||||
// 占期初口径:平仓名义本金 = 平仓比例 × 期初名义本金(NotionalValue)
|
||||
this.deal.CloseNotionalValue = otcformat.trading.StockEqvNotional(parseFloat(this.deal.ClosePercent) * parseFloat(this.deal.NotionalValue));
|
||||
this.calcTradingFeePending();
|
||||
this.refreshTradingFeeByUnit();
|
||||
this.getInterestList();
|
||||
this.calcFloatClosePnl();
|
||||
},
|
||||
@@ -187,6 +212,7 @@ const vue = new Vue({
|
||||
this.deal.CloseMethod = 2;
|
||||
}
|
||||
this.calcTradingFeePending();
|
||||
this.refreshTradingFeeByUnit();
|
||||
this.getInterestList();
|
||||
this.calcFloatClosePnl();
|
||||
},
|
||||
@@ -205,6 +231,7 @@ const vue = new Vue({
|
||||
this.deal.CloseMethod = 2;
|
||||
}
|
||||
this.calcTradingFeePending();
|
||||
this.refreshTradingFeeByUnit();
|
||||
this.getInterestList();
|
||||
this.calcFloatClosePnl();
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user