From 9e5081907031aabf5a9e24afb74c4483ef298edb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E6=96=B9=E6=B5=B7?= Date: Tue, 2 Jun 2026 16:10:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=99=AE=E9=80=9A=E6=94=B6=E7=9B=8A=E4=BA=92?= =?UTF-8?q?=E6=8D=A2=E7=9A=84=E6=A8=A1=E6=9D=BF=E6=81=A2=E5=A4=8D=20#EQD-5?= =?UTF-8?q?914=20=E5=9B=BD=E8=81=94=E6=B0=91=E7=94=9F-=E5=80=BA=E5=88=B8ET?= =?UTF-8?q?F=E4=B8=BA=E6=A0=87=E7=9A=84=E7=9A=84TRS=E4=B8=9A=E5=8A=A1?= =?UTF-8?q?=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../underlying_managerController.cs | 1 + YLErpWeb/Views/SwapTrade2/SwapIncome.cshtml | 14 +-- YLErpWeb/Views/SwapTrade2/SwapUnwind.cshtml | 10 +- YLErpWeb/Views/SwapTrade2/TradeEdit.cshtml | 25 +++-- YLErpWeb/Views/SwapTrade2/TradeView.cshtml | 102 +++++++++++++----- .../Scripts/app/swaptrade/incomeSwapTrade.js | 28 +++-- .../Scripts/app/swaptrade/swapTradeEdit.js | 39 ++++--- .../Scripts/app/swaptrade/unwindSwapTrade.js | 21 ++-- YLErpWeb/wwwroot/Scripts/app/tradeHelper.js | 24 ++--- 9 files changed, 171 insertions(+), 93 deletions(-) diff --git a/YLErpWeb/Controllers/underlying_managerController.cs b/YLErpWeb/Controllers/underlying_managerController.cs index 3c3585bc..509b3aaa 100644 --- a/YLErpWeb/Controllers/underlying_managerController.cs +++ b/YLErpWeb/Controllers/underlying_managerController.cs @@ -307,6 +307,7 @@ namespace YLErp.Web.Controllers if (EodPriceQueryService.TryGetEodPrice(valuedate.Value, code, out var eodPrice)) { price = eodPrice.GetPrice((SettlementTypeEnum)settlementType); + return JsonSuccessData(price); } } diff --git a/YLErpWeb/Views/SwapTrade2/SwapIncome.cshtml b/YLErpWeb/Views/SwapTrade2/SwapIncome.cshtml index 14e12e6b..e3d4e19b 100644 --- a/YLErpWeb/Views/SwapTrade2/SwapIncome.cshtml +++ b/YLErpWeb/Views/SwapTrade2/SwapIncome.cshtml @@ -1,4 +1,4 @@ -@model UnwindData +@model UnwindData @{ ViewBag.Title = "交易 | 收益结算"; Layout = "~/Views/Shared/_InfoLayout.cshtml"; @@ -127,10 +127,12 @@ 收支方向 多空方向 标的代码 - 期初标的交割全价% - 期初标的交割净价% - 标的价格% - 持仓数量 + 期初标的交割全价% + 期初标的交割净价% + 期初标的价格 + 期末标的交割全价% + 期末标的价格 + 数量 交易费用(平仓) 分红收益 浮动端平仓盈亏 @@ -144,7 +146,7 @@ {{floatPosition.UnderlyingCode}} {{priceFormat(floatPosition.PosiGrossPrice)}} - {{priceFormat(floatPosition.TradingAmountNetAvg)}} + {{priceFormat(floatPosition.TradingAmountNetAvg)}} diff --git a/YLErpWeb/Views/SwapTrade2/SwapUnwind.cshtml b/YLErpWeb/Views/SwapTrade2/SwapUnwind.cshtml index 612995b4..1bb5484d 100644 --- a/YLErpWeb/Views/SwapTrade2/SwapUnwind.cshtml +++ b/YLErpWeb/Views/SwapTrade2/SwapUnwind.cshtml @@ -1,4 +1,4 @@ -@model UnwindData +@model UnwindData @{ ViewBag.Title = "交易 | 交易平仓"; Layout = "~/Views/Shared/_InfoLayout.cshtml"; @@ -179,9 +179,11 @@ 收支方向 多空方向 标的代码 - 期初标的交割全价% - 期末标的交割全价% - 持仓数量 + 期初标的交割全价% + 期初标的价格 + 期末标的交割全价% + 期末标的价格 + 数量 交易费用(平仓) 交易费用(待结算) 分红收益 diff --git a/YLErpWeb/Views/SwapTrade2/TradeEdit.cshtml b/YLErpWeb/Views/SwapTrade2/TradeEdit.cshtml index 4133bbc4..8aa40471 100644 --- a/YLErpWeb/Views/SwapTrade2/TradeEdit.cshtml +++ b/YLErpWeb/Views/SwapTrade2/TradeEdit.cshtml @@ -394,9 +394,10 @@ 收支方向 多空方向 标的代码 - 期初标的交割全价% - 期初标的交割净价% - 期初标的成交收益率% + 期初标的交割全价% + 期初标的交割净价% + 期初标的成交收益率% + 期初标的价格 数量 交易费用后付 @@ -414,19 +415,23 @@ - + + - - + + - - + + - - + + + + + {{item.underlying!=null?item.underlying.QuoteUnitString:''}} diff --git a/YLErpWeb/Views/SwapTrade2/TradeView.cshtml b/YLErpWeb/Views/SwapTrade2/TradeView.cshtml index 093dd18f..a72f09ca 100644 --- a/YLErpWeb/Views/SwapTrade2/TradeView.cshtml +++ b/YLErpWeb/Views/SwapTrade2/TradeView.cshtml @@ -22,9 +22,10 @@ var swap_deals = trade.swap_Events.Where(x => x.EventType == (int)SwapEventTypeEnum.互换 || x.EventType == (int)SwapEventTypeEnum.自动互换).ToList();//单标的/多空组合互换 互换记录 var closeSwapDeals = trade.swap_Events.Where(x => x.EventType == (int)SwapEventTypeEnum.平仓).ToList();//单标的互换 平仓记录 bool isBond = trade.StructureType == "普通债券类收益互换"; - string spotPriceTitle = "期初标的交割全价%"; - string netSportPriceTitle = "期初标的交割净价%"; - string initYtmTitle = "期初标的成交收益率%"; + string spotPriceTitle = isBond ? "期初标的交割全价%" : "期初标的价格"; + string netSportPriceTitle = isBond ? "期初标的交割净价%" : string.Empty; + string initYtmTitle = isBond ? "期初标的成交收益率%" : string.Empty; + string endSpotPriceTitle = isBond ? "期末标的交割全价%" : "期末标的价格"; var positions = trade.swap_positions.Where(x=>x.PosiDirection>0&&x.IsInitial).ToList(); var realPositions = trade.swap_positions.Where(x => x.PosiDirection > 0 && !x.IsInitial).ToList(); var sr = trade.trade_extend.ExtendObj.SettlementRules; @@ -364,8 +365,11 @@ 多空方向 标的代码 @spotPriceTitle - @netSportPriceTitle - @initYtmTitle + @if (isBond) + { + @netSportPriceTitle + @initYtmTitle + } 数量 交易费用后付 @@ -380,12 +384,15 @@ @((item.PosiGrossPrice * multiplier).OtcFormat(OtcFormatFlag.umprice)) - - @(((item.PosiNetNoFeePrice ?? 0) * multiplier).OtcFormat(OtcFormatFlag.umprice)) - - - @((item.InitYtm * multiplier).OtcFormat(OtcFormatFlag.umprice)) - + @if (isBond) + { + + @(((item.PosiNetNoFeePrice ?? 0) * multiplier).OtcFormat(OtcFormatFlag.umprice)) + + + @((item.InitYtm * multiplier).OtcFormat(OtcFormatFlag.umprice)) + + } @item.PosiQuantity.OtcFormat(OtcFormatFlag.StockEqvNotional) @@ -557,8 +564,11 @@ 多空方向 标的代码 @spotPriceTitle - @netSportPriceTitle - 持仓数量 + @if (isBond) + { + @netSportPriceTitle + } + 数量 持仓名义本金 交易费用后付 起始日期 @@ -579,9 +589,12 @@ @((item.PosiGrossPrice * multiplier).OtcFormat(OtcFormatFlag.umprice)) - - @(((item.PosiNetNoFeePrice ?? 0) * multiplier).OtcFormat(OtcFormatFlag.umprice)) - + @if (isBond) + { + + @(((item.PosiNetNoFeePrice ?? 0) * multiplier).OtcFormat(OtcFormatFlag.umprice)) + + } @item.PosiQuantity.OtcFormat(OtcFormatFlag.StockEqvNotional) @@ -757,9 +770,17 @@ 收支方向 多空方向 标的代码 - 期初标的交割全价% - 期末标的交割全价% - 平仓数量 + @if (isBond) + { + 期初标的交割全价% + 期末标的交割全价% + } + else + { + 期初标的价格 + 期末标的价格 + } + 数量 交易费用 交易费用(待结算) 分红收益 @@ -769,8 +790,16 @@ @((SwapDirectionEnum)closeFloat.PayDirection) @(closeFloat.PositionType == (int)PositionTypeFlag.Long ? "多头" : "空头") @closeFloat.UnderlyingCode - @((closeFloat.PosiGrossPrice * multiplier).OtcFormat(OtcFormatFlag.umprice)) - @((closeFloat.TradingAmountAvg * multiplier).OtcFormat(OtcFormatFlag.umprice)) + @if (isBond) + { + @((closeFloat.PosiGrossPrice * multiplier).OtcFormat(OtcFormatFlag.umprice)) + @((closeFloat.TradingAmountAvg * multiplier).OtcFormat(OtcFormatFlag.umprice)) + } + else + { + @(closeFloat.PosiGrossPrice.OtcFormat(OtcFormatFlag.umprice)) + @(closeFloat.TradingAmountAvg.OtcFormat(OtcFormatFlag.umprice)) + } @(closeFloat.Quantity.OtcFormat(OtcFormatFlag.StockEqvNotional)) @(closeFloat.TradingFee.OtcFormat(OtcFormatFlag.StockEqvNotional)) @(closeFloat.TradingFeePending.OtcFormat(OtcFormatFlag.StockEqvNotional)) @@ -928,10 +957,18 @@ 收支方向 多空方向 标的代码 - @spotPriceTitle - @netSportPriceTitle - 标的价格% - 持仓数量 + @if (isBond) + { + @spotPriceTitle + @netSportPriceTitle + + } + else + { + 标的价格 + } + @endSpotPriceTitle + 数量 交易费用 分红收益 浮动端平仓盈亏 @@ -940,9 +977,16 @@ @((SwapDirectionEnum)closeFloat.PayDirection) @(closeFloat.PositionType == (int)PositionTypeFlag.Long ? "多头" : "空头") @closeFloat.UnderlyingCode - @((closeFloat.PosiGrossPrice * multiplier).OtcFormat(OtcFormatFlag.umpriceP)) - @(((closeFloat.TradingAmountNetAvg ?? 0) * multiplier).OtcFormat(OtcFormatFlag.umpriceP)) - @((closeFloat.TradingAmountAvg * multiplier).OtcFormat(OtcFormatFlag.umpriceP)) + @if (isBond) + { + @((closeFloat.PosiGrossPrice * multiplier).OtcFormat(OtcFormatFlag.umprice)) + @(((closeFloat.TradingAmountNetAvg ?? 0) * multiplier).OtcFormat(OtcFormatFlag.umprice)) + } + else + { + @((closeFloat.TradingAmountAvg * multiplier).OtcFormat(OtcFormatFlag.umprice)) + } + @((closeFloat.TradingAmountAvg * multiplier).OtcFormat(OtcFormatFlag.umprice)) @((closeFloat.PositionQty??0).OtcFormat(OtcFormatFlag.StockEqvNotional)) @(closeFloat.TradingFee.OtcFormat(OtcFormatFlag.StockEqvNotional)) @(closeFloat.DividendIn.OtcFormat(OtcFormatFlag.StockEqvNotional)) @@ -1047,4 +1091,4 @@ @if (!string.IsNullOrWhiteSpace(Context.Request.Query["abstract"])) { @await Html.PartialAsync("/Views/trade/_part/TradeAbstractInfo.cshtml", Model.Trade) -} \ No newline at end of file +} diff --git a/YLErpWeb/wwwroot/Scripts/app/swaptrade/incomeSwapTrade.js b/YLErpWeb/wwwroot/Scripts/app/swaptrade/incomeSwapTrade.js index 9846f8f8..69d6a9b2 100644 --- a/YLErpWeb/wwwroot/Scripts/app/swaptrade/incomeSwapTrade.js +++ b/YLErpWeb/wwwroot/Scripts/app/swaptrade/incomeSwapTrade.js @@ -1,4 +1,4 @@ -//otcformat禁止千分位分组 +//otcformat禁止千分位分组 window.otcformat.options.disableGrouping = true; const inputFormatSwapRate = Object.freeze({ precision: otcformat.trading.premiumRateP.precision, append: '%' }); @@ -27,13 +27,14 @@ const vue = new Vue({ } }, created() { + this.multiplier = this.deal.StructureType == '普通债券类收益互换' ? 100 : 1; this.initDeal(); this.setValueDate(); - if (this.deal.StructureType != '普通收益互换') { - this.multiplier = 100; - } }, methods: { + getPriceScale() { + return this.multiplier == 100 ? 0.01 : 1; + }, initDeal() { var positions = model.FlowEvents.filter((item) => { return item.UnderlyingCode; @@ -46,6 +47,9 @@ const vue = new Vue({ this.marginList = model.FlowEvents.filter((item) => { return item.InterestMode == 5 || item.InterestMode == 6; }); + if (this.floatPosition.TradingAmountAvg) { + this.floatPosition.TradingAmountAvg = this.floatPosition.TradingAmountAvg * this.multiplier; + } }, IsBond(instType) { return tradeHelper.IsBond(instType); @@ -104,8 +108,8 @@ const vue = new Vue({ main.post("/underlying_manager/GetUnderlyingPriceByCode", { code: thisObj.floatPosition.UnderlyingCode, ValueDate: thisObj.deal.ValueDate }) .done(function (res) { - res.obj = res.obj * 100; - thisObj.floatPosition.TradingAmountAvg = otcformat.trading.umprice(res.obj); + res.obj = res.obj * thisObj.multiplier; + thisObj.floatPosition.TradingAmountAvg = otcformat.trading.tradeSinglePrice(res.obj); thisObj.calcFloatClosePnl(); }); }, @@ -124,7 +128,8 @@ const vue = new Vue({ let TradingFee = thisObj.floatPosition.TradingFee == "" ? 0 : parseFloat(thisObj.floatPosition.TradingFee); let TradingFeePending = thisObj.floatPosition.TradingFeePending == "" ? 0 : parseFloat(thisObj.floatPosition.TradingFeePending); let DividendIn = thisObj.floatPosition.DividendIn == "" ? 0 : parseFloat(thisObj.floatPosition.DividendIn ?? 0); - thisObj.floatPosition.MarkClosePnl = thisObj.deal.CloseNotionalValue * (thisObj.floatPosition.TradingAmountAvg*0.01 - thisObj.initPosiNetPrice) * floatRatio; + let scale = thisObj.getPriceScale(); + thisObj.floatPosition.MarkClosePnl = thisObj.deal.CloseNotionalValue * (thisObj.floatPosition.TradingAmountAvg * scale - thisObj.initPosiNetPrice) * floatRatio; thisObj.floatPosition.MarkClosePnl = thisObj.floatPosition.MarkClosePnl + TradingFee + TradingFeePending + DividendIn; thisObj.floatPosition.MarkClosePnl = otcformat.trading.StockEqvNotional(thisObj.floatPosition.MarkClosePnl); thisObj.calcCloseAmount(); @@ -143,12 +148,13 @@ const vue = new Vue({ thisObj.deal.SwapRealizedPnL = pnl; thisObj.deal.SwapMarginRebatePnl = 0; thisObj.deal.SwapMarginAmount = 0; - thisObj.floatPosition.TradingAmount = parseFloat(thisObj.floatPosition.TradingAmountAvg) * parseFloat(thisObj.deal.CloseNotionalValue) * 0.01; + let scale = thisObj.getPriceScale(); + thisObj.floatPosition.TradingAmount = parseFloat(thisObj.floatPosition.TradingAmountAvg) * parseFloat(thisObj.deal.CloseNotionalValue) * scale; thisObj.floatPosition.CloseFee = TradingFee; if (thisObj.deal.CloseQty > 0) { - thisObj.floatPosition.TradingAmountFeeAvg = parseFloat(thisObj.floatPosition.TradingAmountAvg) * 0.01 + (TradingFee / thisObj.deal.CloseQty) * floatRatio; + thisObj.floatPosition.TradingAmountFeeAvg = parseFloat(thisObj.floatPosition.TradingAmountAvg) * scale + (TradingFee / thisObj.deal.CloseQty) * floatRatio; } else { - thisObj.floatPosition.TradingAmountFeeAvg = parseFloat(thisObj.floatPosition.TradingAmountAvg) * 0.01; + thisObj.floatPosition.TradingAmountFeeAvg = parseFloat(thisObj.floatPosition.TradingAmountAvg) * scale; } this.interestList.forEach(x => { //let interestRatio = x.InterestDirection == 1 ? 1 : -1; @@ -195,7 +201,7 @@ const vue = new Vue({ thisObj.floatPosition.EventDate = thisObj.deal.ValueDate; let floatPosition = _.cloneDeep(thisObj.floatPosition); floatPosition.Quantity = 0; - floatPosition.TradingAmountAvg = floatPosition.TradingAmountAvg * 0.01; + floatPosition.TradingAmountAvg = floatPosition.TradingAmountAvg * thisObj.getPriceScale(); reqObj.FlowEvents.push(floatPosition); var postData = { unwindData: reqObj }; var msg = "确认提交收益结算?"; diff --git a/YLErpWeb/wwwroot/Scripts/app/swaptrade/swapTradeEdit.js b/YLErpWeb/wwwroot/Scripts/app/swaptrade/swapTradeEdit.js index e71b9f5a..091ad022 100644 --- a/YLErpWeb/wwwroot/Scripts/app/swaptrade/swapTradeEdit.js +++ b/YLErpWeb/wwwroot/Scripts/app/swaptrade/swapTradeEdit.js @@ -11,14 +11,22 @@ const inputFormatEqvNotional = Object.freeze({ precision: otcformat.trading.Stoc const inputFormatTradeAmount = Object.freeze({ precision: otcformat.trading.notional.precision, append: '' }); 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: '' }); +const inputFormatTradeSinglePrice = Object.freeze({ precision: otcformat.trading.tradeSinglePrice.precision, negative: true, append: '', percent: false }); const inputFormatMarginRate = Object.freeze({ precision: otcformat.trading.marginRateP.precision, append: '%' }); const inputFormatMarginRateNoPercent = Object.freeze({ precision: otcformat.trading.umpriceP.precision, append: '', percent:true }); -const consUnderlyingFlag = (function () { +const consUnderlyingFlagBase = (function () { let unSelFlag = tradeHelper.UnderlyingSelectFlag; return unSelFlag.UseForTrading | unSelFlag.IncludeMatured | unSelFlag.UsePinYinFilter | unSelFlag.IncludeBasket | unSelFlag.IncludeSynthetic | unSelFlag.CheckLaunch; }()); +const consUnderlyingFlagNonBond = (function () { + let unSelFlag = tradeHelper.UnderlyingSelectFlag; + return consUnderlyingFlagBase | unSelFlag.Stock | unSelFlag.StockIndex | unSelFlag.StockIF | unSelFlag.CommodityFutures | unSelFlag.CommoditySpot; +}()); +const consUnderlyingFlagBond = (function () { + let unSelFlag = tradeHelper.UnderlyingSelectFlag; + return consUnderlyingFlagBase | unSelFlag.CreditBonds | unSelFlag.Bonds | unSelFlag.TBonds | unSelFlag.OtherBonds; +}()); const inputFormatDouble2 = Object.freeze({ precision: 2, append: '' }); var autoMarginTemplateName; @@ -42,16 +50,14 @@ const consNumberFormat = Object.freeze(new function () { return this; }()); -//标的选择组件 -const vueUnderlying = function () { +const createVueUnderlying = function (selectFlag) { return { props: ['value', 'index'], data() { return { autoUnderlying: null }; }, mounted() { - var selFlag = tradeHelper.UnderlyingSelectFlag; - this.autoUnderlying = tradeHelper.UnderlyingAutoComplete(this.$el, { SelectFlag: selFlag.UsePinYinFilter | selFlag.UseForTrading | selFlag.IncludeSynthetic | selFlag.IncludeMatured | selFlag.IncludeBasket | selFlag.CheckLaunch, BlackLimit: 2, }); + this.autoUnderlying = tradeHelper.UnderlyingAutoComplete(this.$el, { SelectFlag: selectFlag, BlackLimit: 2, }); this.autoUnderlying.onSelect(this.onchange); this.value && this.autoUnderlying.selectByCode(this.value); }, @@ -67,6 +73,12 @@ const vueUnderlying = function () { template: '' }; }; +const vueUnderlyingNonBond = function () { + return createVueUnderlying(consUnderlyingFlagNonBond); +}; +const vueUnderlyingBond = function () { + return createVueUnderlying(consUnderlyingFlagBond); +}; //标的选择组件 银行间回购定盘&其他利率 const vueUnderlyingRate = function () { @@ -177,11 +189,6 @@ const vue = new Vue({ this.initSwapRateList(); }, methods: { - getPosiPriceFormat(item) { - return tradeHelper.IsBond(item && item.UnderlyingInstrumentType) - ? inputFormatMarginRateNoPercent - : inputFormatTradeSinglePrice; - }, getPosiPriceFormatKey(item, field) { const index = item && item.index != null ? item.index : ''; const isBond = tradeHelper.IsBond(item && item.UnderlyingInstrumentType); @@ -189,6 +196,13 @@ const vue = new Vue({ }, changeStructureType() { this.trade.StockEqvNotional = 0; + let direction = this.trade.trade_extend.ExtendObj.Direction; + if (direction !== 1 && direction !== 2) { + direction = 2; + this.trade.trade_extend.ExtendObj.Direction = direction; + } + this.paySwapList = []; + this.addSwapFloat(direction); //this.trade.trade_extend.ExtendObj.FlowBookMode = 0; }, //变更初始预付金收取方向 @@ -1432,7 +1446,8 @@ const vue = new Vue({ components: { 'vue-datepicker': FastVue.vueDatePicker(), 'vue-number-input': FastVue.vueNumberInput(), - 'vue-underlying': vueUnderlying(), + 'vue-underlying-nonbond': vueUnderlyingNonBond(), + 'vue-underlying-bond': vueUnderlyingBond(), 'vue-underlying-rate': vueUnderlyingRate() }, destroyed() { diff --git a/YLErpWeb/wwwroot/Scripts/app/swaptrade/unwindSwapTrade.js b/YLErpWeb/wwwroot/Scripts/app/swaptrade/unwindSwapTrade.js index eb16694c..db1af06d 100644 --- a/YLErpWeb/wwwroot/Scripts/app/swaptrade/unwindSwapTrade.js +++ b/YLErpWeb/wwwroot/Scripts/app/swaptrade/unwindSwapTrade.js @@ -1,4 +1,4 @@ -//otcformat禁止千分位分组 +//otcformat禁止千分位分组 window.otcformat.options.disableGrouping = true; const inputFormatSwapRate = Object.freeze({ precision: otcformat.trading.premiumRateP.precision, append: '%' }); @@ -30,13 +30,14 @@ const vue = new Vue({ } }, created() { - if (this.deal.StructureType != '普通收益互换') { - this.multiplier = 100; - } + this.multiplier = this.deal.StructureType == '普通债券类收益互换' ? 100 : 1; this.initDeal(); this.setUnwindDate(); }, methods: { + getPriceScale() { + return this.multiplier == 100 ? 0.01 : 1; + }, initDeal() { var positions = model.FlowEvents.filter((item) => { return item.UnderlyingCode; @@ -187,7 +188,7 @@ const vue = new Vue({ main.post("/underlying_manager/GetUnderlyingPriceByCode", { code: thisObj.floatPosition.UnderlyingCode, valuedate: thisObj.deal.ValueDate }) .done(function (res) { - res.obj = res.obj * 100; + res.obj = res.obj * thisObj.multiplier; thisObj.floatPosition.TradingAmountAvg = otcformat.trading.tradeSinglePrice(res.obj); thisObj.calcFloatClosePnl(); }); @@ -198,7 +199,8 @@ const vue = new Vue({ let longRatio = thisObj.floatPosition.PositionType == 1 ? 1 : -1; let TradingFee = thisObj.floatPosition.TradingFee == "" ? 0 : parseFloat(thisObj.floatPosition.TradingFee); let TradingFeePending = thisObj.floatPosition.TradingFeePending == "" ? 0 : parseFloat(thisObj.floatPosition.TradingFeePending); - thisObj.floatPosition.MarkClosePnl = Math.round(thisObj.deal.CloseQty * (thisObj.floatPosition.TradingAmountAvg*0.01 - thisObj.initPosiNetPrice) * floatRatio * longRatio * 10000) / 10000; + let scale = thisObj.getPriceScale(); + thisObj.floatPosition.MarkClosePnl = Math.round(thisObj.deal.CloseQty * (thisObj.floatPosition.TradingAmountAvg * scale - thisObj.initPosiNetPrice) * floatRatio * longRatio * 10000) / 10000; thisObj.floatPosition.MarkClosePnl = Number(thisObj.floatPosition.MarkClosePnl.toFixed(2)); thisObj.floatPosition.MarkClosePnl = thisObj.floatPosition.MarkClosePnl + (TradingFee + TradingFeePending) * floatRatio * -1 + parseFloat(thisObj.floatPosition.DividendIn); thisObj.floatPosition.MarkClosePnl = otcformat.trading.StockEqvNotional(thisObj.floatPosition.MarkClosePnl); @@ -228,12 +230,13 @@ const vue = new Vue({ thisObj.deal.SwapRealizedPnL = pnl; thisObj.deal.SwapMarginRebatePnl = 0; thisObj.deal.SwapMarginAmount = 0; - thisObj.floatPosition.TradingAmount = parseFloat(thisObj.floatPosition.TradingAmountAvg) * parseFloat(thisObj.deal.CloseQty) * 0.01; + let scale = thisObj.getPriceScale(); + thisObj.floatPosition.TradingAmount = parseFloat(thisObj.floatPosition.TradingAmountAvg) * parseFloat(thisObj.deal.CloseQty) * scale; thisObj.floatPosition.CloseFee = TradingFee; if (thisObj.deal.CloseQty == 0) { thisObj.floatPosition.TradingAmountFeeAvg = 0; } else { - thisObj.floatPosition.TradingAmountFeeAvg = parseFloat(thisObj.floatPosition.TradingAmountAvg) * 0.01 + (TradingFee / thisObj.deal.CloseQty) * ratio; + thisObj.floatPosition.TradingAmountFeeAvg = parseFloat(thisObj.floatPosition.TradingAmountAvg) * scale + (TradingFee / thisObj.deal.CloseQty) * ratio; } this.interestList.forEach(x => { /*let interestRatio = x.InterestDirection == 1 ? 1 : -1;*/ @@ -322,7 +325,7 @@ const vue = new Vue({ thisObj.floatPosition.EventDate = thisObj.deal.ValueDate; let floatPosition = _.cloneDeep(thisObj.floatPosition); floatPosition.Quantity = reqObj.CloseQty; - floatPosition.TradingAmountAvg = floatPosition.TradingAmountAvg * 0.01; + floatPosition.TradingAmountAvg = floatPosition.TradingAmountAvg * thisObj.getPriceScale(); reqObj.FlowEvents.push(floatPosition); var postData = { unwindData: reqObj }; var msg = "确认提交平仓?"; diff --git a/YLErpWeb/wwwroot/Scripts/app/tradeHelper.js b/YLErpWeb/wwwroot/Scripts/app/tradeHelper.js index 564d5697..f920ddc2 100644 --- a/YLErpWeb/wwwroot/Scripts/app/tradeHelper.js +++ b/YLErpWeb/wwwroot/Scripts/app/tradeHelper.js @@ -1,4 +1,4 @@ -//tradeHelper +//tradeHelper (function () { function tradeHelper() { } @@ -362,22 +362,22 @@ function __getPostData() { let options = this.options; let sf = options.SelectFlag; - let InstrumentTypes = options.InstrumentTypes; - (sf & SelectFlag.Stock) > 0 && (InstrumentTypes.push('Stock')); - (sf & SelectFlag.StockIndex) > 0 && (InstrumentTypes.push('StockIndex')); - (sf & SelectFlag.CommodityFutures) > 0 && (InstrumentTypes.push('CommodityFutures')); - (sf & SelectFlag.CommoditySpot) > 0 && (InstrumentTypes.push('CommoditySpot')); - (sf & SelectFlag.CreditBonds) > 0 && (InstrumentTypes.push('CreditBonds')); - (sf & SelectFlag.Bonds) > 0 && (InstrumentTypes.push('Bonds')); - (sf & SelectFlag.TBonds) > 0 && (InstrumentTypes.push('TBonds')); - (sf & SelectFlag.OtherBonds) > 0 && (InstrumentTypes.push('OtherBonds')); + let instrumentTypes = Array.isArray(options.InstrumentTypes) ? options.InstrumentTypes.slice() : []; + (sf & SelectFlag.Stock) > 0 && (instrumentTypes.push('Stock')); + (sf & SelectFlag.StockIndex) > 0 && (instrumentTypes.push('StockIndex')); + (sf & SelectFlag.CommodityFutures) > 0 && (instrumentTypes.push('CommodityFutures')); + (sf & SelectFlag.CommoditySpot) > 0 && (instrumentTypes.push('CommoditySpot')); + (sf & SelectFlag.CreditBonds) > 0 && (instrumentTypes.push('CreditBonds')); + (sf & SelectFlag.Bonds) > 0 && (instrumentTypes.push('Bonds')); + (sf & SelectFlag.TBonds) > 0 && (instrumentTypes.push('TBonds')); + (sf & SelectFlag.OtherBonds) > 0 && (instrumentTypes.push('OtherBonds')); return { FilterCode: '{{{q}}}', ClientId: options.ClientId, VarietyId: options.VarietyId, BlackLimit: options.BlackLimit, MaxShowLength: options.MaxShowLength, - InstrumentTypes: InstrumentTypes, + InstrumentTypes: instrumentTypes, UsePinYinFilter: (sf & (SelectFlag.UsePinYinFilter | SelectFlag.Stock | SelectFlag.StockIndex)) > 0, IncludeMatured: (sf & SelectFlag.IncludeMatured) > 0, OnlySynthetic: (sf & SelectFlag.OnlySynthetic) > 0, @@ -728,4 +728,4 @@ }(window.tradeHelper)); -Object.freeze(window.tradeHelper); \ No newline at end of file +Object.freeze(window.tradeHelper);