@using YLErp.Enums; @using System.Globalization; @model TradeViewModel @{ ViewBag.Title = "交易信息|查看"; Layout = "~/Views/Shared/_InfoLayout.cshtml"; var trade = Model.Trade; var salesNames = String.Join(",", Model.SalesCommission.Select(n => n.SalesmanName).ToArray()); trade.TradeUnit = PS.Config.IsUseDisplayNotional ? (trade.QuoteUnit == "500千克" ? "半吨" : "吨") : trade.TradeUnit; var pageObj = new { Trade = trade, ClosePrice = Model.ClosePrice ?? 0, ConfirmInfo = "确认删除此交易?如果属于结构化交易则删除整个交易", IsGenerateAmendDoc = PS.Config.TradeElement.IsGenerateAmendDoc, NeedSendChangeEmail = PS.Config.TradeElement.IsAmendableAfterConfirm && PS.Config.TradeElement.IsGenerateAmendDoc, buttonStr = YLErp.PS.Config.Company == CompanyEnum.天风 ? "交易录入" : "交易特批", }; bool hasPosition = false;//是否有持仓 bool singleTrade = trade.StructureType != ClientMarginTypeEnum.多空组合.ToString(); hasPosition = trade.swap_positions.Any(x => !x.IsInitial); 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 = 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; bool hideFloatingIncomeDirection = PS.Config.ErpElement.SwapFloatingIncomeReceiveOnlyMode; string FloatingPositionTypeText(int posiDirection, int positionType) { if (hideFloatingIncomeDirection) { return posiDirection == positionType ? "多头" : "空头"; } return positionType == (int)PositionTypeFlag.Long ? "多头" : "空头"; } string SwapPriceData(decimal? value) => value?.ToString(CultureInfo.InvariantCulture) ?? string.Empty; string SwapCommonData(object value) => value == null ? string.Empty : Convert.ToString(value, CultureInfo.InvariantCulture); } @section CSS{ } @section JS{ } @Html.Partial("~/Views/SwapTrade2/header.cshtml", Model)
@**@ @*@if (AppHelper.UseFutureVersion("销售提成", "V2")) { }*@ @{ trade.MetaDic.TryGetValue(YLErp.DBModels.Consts.ConsTradeMetaKey.ClearingAgency, out var clearingAgency); trade.MetaDic.TryGetValue(YLErp.DBModels.Consts.ConsTradeMetaKey.TradingPlace, out var tradingPlace); trade.MetaDic.TryGetValue(YLErp.DBModels.Consts.ConsTradeMetaKey.MainProtocolCode, out var mainProtocolCode); trade.MetaDic.TryGetValue(YLErp.DBModels.Consts.ConsTradeMetaKey.SupProtocolCode, out var supProtocolCode); }
产品结构 @trade.StructureType
簿记账户 @trade.AssetBookName
交易对手方 @trade.ClientName
交易员 @trade.TraderName
成交日期 @trade.TradeDate.OtcFormatDate()
开始日期 @trade.StartDate.OtcFormatDate()
到期日期 @trade.ExerciseDate.OtcFormatDate()
名义本金
初始预付金 @if (trade.trade_Initial_Margin != null) { var direction = trade.trade_Initial_Margin.Direction; var directionStr = direction == 2 ? "支付" : "收取"; var btnClass = "swapget"; if (direction == 2) { btnClass = "swappay"; } if (trade.trade_Initial_Margin.MarginType == 0) { @trade.trade_Initial_Margin.MarginValue.OtcFormatPercent() } else { @trade.trade_Initial_Margin.MarginValue.OtcFormatMoney(true) } }
交易编号 @trade.TradeNumber
@(PS.Config.ErpElement.SaleMode == YLErp.Configuration.Enums.SaleMode.SaleMen ?"销售员":"客户经理") @salesNames
销售提成 @(Model.SalesCommission.FirstOrDefault()?.CommissionString())
流水簿记模式 @((FlowBookModeEnum)trade.trade_extend?.ExtendObj?.FlowBookMode)
交易场所 @tradingPlace
清算机构 @clearingAgency
主协议编号 @mainProtocolCode
补充协议编号 @supProtocolCode
交易对手方角色 @trade.OpponentRole
@* *@
年化天数 @trade.trade_extend.ExtendObj.AnnualDays
计息方式 @(TradeViewModel.GetSwapRateCalcModeDesc(trade.trade_extend.ExtendObj.InterestCalcMode))
是否开仓时收取开仓费 @(trade.trade_extend.ExtendObj.NeedOpenFee ? "是" : "否")
收费基本单位 @(trade.trade_extend.ExtendObj.OpenFeeType == 0 ? "按手数收费" : "按份数收费")
结算规则 @(trade.trade_extend.ExtendObj.SettlementRules == 0 ? "T+0" : "T+1")
派息金额支付日 @(trade.trade_extend.ExtendObj.DividendPayDate == 0 ? "到期结算日" : "派息日+" + (trade.trade_extend.ExtendObj.DividendPayDate - 1))
保证金模板 @trade.MarginTemplateName
@if (trade.swap_positions != null) { foreach (var item in trade.swap_positions.Where(x => (x.InterestMode == 5 || x.InterestMode == 6) && x.IsInitial)) { var bgclass = item.InterestDirection == (int)SwapDirectionEnum.收取 ? "swapget" : "swappay"; } }
收支方向 资金类别 发生日期 金额 币种 预付金返息率 利率是否年化 结算规则
@((SwapDirectionEnum)item.InterestDirection) @((InterestModeEnum)item.InterestMode) @item.HappenDate.OtcFormatDate() @item.Currency @(item.IsAnnualized ? "是" : "否")
@if (trade.swap_positions != null) { foreach (var item in trade.swap_positions.Where(x => ConsTrade.InterestModels.Contains(x.InterestMode) && x.IsInitial)) { decimal? interestPrice = null; if (item.InterestMode == (int)InterestModeEnum.合约名义本金规模) { interestPrice = Convert.ToDecimal(trade.OriginalStockEqvNotional.Value); } else if (item.InterestMode == (int)InterestModeEnum.标的期初全价) { interestPrice = Convert.ToDecimal(trade.OriginalStockEqvNotional.Value); } else if (item.InterestMode == (int)InterestModeEnum.固定值) { interestPrice = item.InterestPrincipalFix; } @* else if (item.InterestMode == (int)InterestModeEnum.多头存续名义本金) { interestPrice = positions.Where(w => w.PositionType == (int)PositionTypeFlag.Long).Sum(s => s.PosiNotionalValue); } else if (item.InterestMode == (int)InterestModeEnum.空头存续名义本金) { interestPrice = positions.Where(w => w.PositionType == (int)PositionTypeFlag.Short).Sum(s => s.PosiNotionalValue); }*@ var bgclass = item.InterestDirection == (int)SwapDirectionEnum.收取 ? "swapget" : "swappay"; var sign = item.InterestRateDefault < 0 ? "" : "+"; } }
收支方向 计息基本类型 计息基数 利率 利率是否年化 计息方式 重置频率(天) 利率准则 类别 结算规则
@((SwapDirectionEnum)item.InterestDirection) @((InterestModeEnum)item.InterestMode) @(string.IsNullOrEmpty(item.FloatRateUnderlyingCode) ? "无" : item.FloatRateUnderlyingCode) @sign @(item.IsAnnualized ? "是" : "否") @((InterestTypeEnum)item.InterestType) @item.interest_rest_days @((item.interest_rule != null) ? (SwapInterestRule)item.interest_rule : "") @(string.IsNullOrEmpty(item.category_tag) ? "互换利率" : item.category_tag)
@if (singleTrade || !hideFloatingIncomeDirection) {
} @if (trade.swap_positions != null) { var paySwapPositions = trade.swap_positions.Where(x => !string.IsNullOrEmpty(x.UnderlyingCode) && x.IsInitial&&x.PosiStartDate==trade.StartDate).ToList(); if (paySwapPositions.Count > 0) {
@if (!hideFloatingIncomeDirection) { } @if (isBond) { } @foreach (var item in paySwapPositions) { var bgclass = item.PosiDirection == (int)SwapDirectionEnum.收取 ? "swapget" : "swappay"; var multiplier = ConsGlobal.InstrumentType.IsBond(item.UnderlyingInstrumentType) ? 100 : 1; @if (!hideFloatingIncomeDirection) { } @if (isBond) { } }
收支方向多空方向 标的代码 @spotPriceTitle@netSportPriceTitle @initYtmTitle数量 基础费率 交易费用后付
@((SwapDirectionEnum)item.PosiDirection)@FloatingPositionTypeText(item.PosiDirection, item.PositionType) @item.UnderlyingCode @if (item.PosiFeeType == 0) { @(item.PosiTradingFeeUnit.ToString("0.0000") + "%") } else { @item.PosiTradingFeeUnit.ToString("0.000000") }
} else if (!hideFloatingIncomeDirection) {
@{ var posiDirection = trade.trade_extend.ExtendObj.Direction; var bgclass = posiDirection == (int)SwapDirectionEnum.收取 ? "swapget" : "swappay"; }
收支方向
@((SwapDirectionEnum)posiDirection)
} }
@foreach (var item in trade.swap_positions.Where(x => (x.InterestMode == 5 || x.InterestMode == 6) && !x.IsInitial)) { var bgclass = item.InterestDirection == (int)SwapDirectionEnum.收取 ? "swapget" : "swappay"; }
收支方向 资金类别 发生日期 金额 币种 预付金返息率 利率是否年化 结算规则
@((SwapDirectionEnum)item.InterestDirection) @((InterestModeEnum)item.InterestMode) @item.HappenDate.OtcFormatDate() @item.Currency @(item.IsAnnualized ? "是" : "否")
@{ foreach (var item in trade.swap_positions.Where(x => ConsTrade.InterestModels.Contains(x.InterestMode) && !x.IsInitial)) { decimal? interestPrice = null; if (item.InterestMode == (int)InterestModeEnum.合约名义本金规模) { interestPrice = Convert.ToDecimal(trade.StockEqvNotional); } else if (item.InterestMode == (int)InterestModeEnum.标的期初全价) { interestPrice = Convert.ToDecimal(trade.StockEqvNotional); } else if (item.InterestMode == (int)InterestModeEnum.固定值) { interestPrice = item.InterestPrincipalFix; } //else if (item.InterestMode == (int)InterestModeEnum.多头存续名义本金) //{ // interestPrice = realPositions.Where(w => w.PositionType == (int)PositionTypeFlag.Long).Sum(s => s.PosiNotionalValue); //} //else if (item.InterestMode == (int)InterestModeEnum.空头存续名义本金) //{ // interestPrice = realPositions.Where(w => w.PositionType == (int)PositionTypeFlag.Short).Sum(s => s.PosiNotionalValue); //} var bgclass = item.InterestDirection == (int)SwapDirectionEnum.收取 ? "swapget" : "swappay"; var sign = item.InterestRateDefault < 0 ? "" : "+"; } }
收支方向 计息基本类型 计息基数 利率 利率是否年化 计息方式 重置频率(天) 利率准则 类别 结算规则
@((SwapDirectionEnum)item.InterestDirection) @((InterestModeEnum)item.InterestMode) @(string.IsNullOrEmpty(item.FloatRateUnderlyingCode) ? "无" : item.FloatRateUnderlyingCode) @sign @(item.IsAnnualized ? "是" : "否") @(item.InterestType == 0 ? "单利" : "复利") @item.interest_rest_days @((item.interest_rule != null) ? (SwapInterestRule)item.interest_rule : "") @(string.IsNullOrEmpty(item.category_tag) ? "互换利率" : item.category_tag)
@if (singleTrade || realPositions.Any(x => !string.IsNullOrEmpty(x.UnderlyingCode)) || !hideFloatingIncomeDirection) {
} @if (trade.swap_positions != null) { var paySwapPositions = trade.swap_positions.Where(x => !string.IsNullOrEmpty(x.UnderlyingCode) && !x.IsInitial).ToList(); if (paySwapPositions.Count > 0) {
@if (!hideFloatingIncomeDirection) { } @if (isBond) { } @foreach (var item in paySwapPositions) { var bgclass = item.PosiDirection == 1 ? "swapget" : "swappay"; var multiplier = ConsGlobal.InstrumentType.IsBond(item.UnderlyingInstrumentType) ? 100 : 1; @if (!hideFloatingIncomeDirection) { } @if (isBond) { } }
收支方向多空方向 标的代码 @spotPriceTitle@netSportPriceTitle数量 持仓名义本金 交易费用后付 起始日期 到期日期
@((SwapDirectionEnum)item.PosiDirection) @FloatingPositionTypeText(item.PosiDirection, item.PositionType) @item.UnderlyingCode @item.PosiStartDate.OtcFormatDate() @item.PosiMatuirityDate.OtcFormatDate()
} else if (!hideFloatingIncomeDirection) {
@{ var posiDirection = trade.trade_extend.ExtendObj.Direction; var bgclass = posiDirection == (int)SwapDirectionEnum.收取 ? "swapget" : "swappay"; }
收支方向
@((SwapDirectionEnum)posiDirection)
} }
@if (singleTrade && closeSwapDeals.Count > 0) { var index = 1;
@foreach (var deal in closeSwapDeals) { var tc = deal.unwindData; if (tc.FlowEvents.Count == 0) { continue; } var closeFloat = tc.FlowEvents.First(x => !string.IsNullOrEmpty(x.UnderlyingCode)); var DealInterests = tc.FlowEvents.Where(x => string.IsNullOrEmpty(x.UnderlyingCode)).ToList(); var fbgclass = closeFloat.PayDirection == (int)SwapDirectionEnum.收取 ? "swapget" : "swappay"; var multiplier = ConsGlobal.InstrumentType.IsBond(closeFloat.UnderlyingInstrumentType) ? 100 : 1; var unwindDate = tc.UnwindDate.HasValue ? tc.UnwindDate.Value : tc.ValueDate; @if (tc.CloseType == 1) { } else { }
提前终止序号 @(index++)
平仓数量 平仓比例 @(tc.ClosePercent.OtcFormatPercent(4)) 平仓名义本金
起始日期 @(tc.StartDate.OtcFormatDate()) 事件日期 @(tc.ValueDate.OtcFormatDate())
平仓日期 @(unwindDate.OtcFormatDate()) 支付日期 @(tc.PayDate.OtcFormatDate())
实现盈亏 平仓总额
@foreach (var item in DealInterests.Where(x => x.InterestMode == 5 || x.InterestMode == 6)) { var bgclass = item.InterestDirection == (int)SwapDirectionEnum.收取 ? "swapget" : "swappay"; }
收支方向 资金类别 应返还本金 利息金额 预付金平仓盈亏
@((SwapDirectionEnum)item.InterestDirection) @(item.InterestModeStr)
@**@ @foreach (var item in DealInterests.Where(x => ConsTrade.InterestModels.Contains(x.InterestMode))) { var bgclass = item.InterestDirection == (int)SwapDirectionEnum.收取 ? "swapget" : "swappay"; @**@ }
收支方向计息基准 计息开始日 计息结束日 利率(年化)其他费用 利息金额 利息端平仓盈亏
@((SwapDirectionEnum)item.InterestDirection)@(item.Principal.OtcFormatMoney(true)) @(item.InterestStartDate.OtcFormatDate()) @(item.InterestEndDate.OtcFormatDate()) @(item.Rate.OtcFormatPercent())
@if (!hideFloatingIncomeDirection) { } @if (isBond) { } else { } @if (!hideFloatingIncomeDirection) { } @if (isBond) { } else { }
收支方向多空方向 标的代码期初标的交割全价% 期末标的交割全价%期初标的价格 期末标的价格数量 交易费用 交易费用(待结算) 分红收益 浮动端平仓盈亏
@((SwapDirectionEnum)closeFloat.PayDirection)@FloatingPositionTypeText(closeFloat.PayDirection, closeFloat.PositionType) @closeFloat.UnderlyingCode
}
} @if (!singleTrade && closeSwapDeals.Count > 0) { var index = 1;
@foreach (var eod in trade.eod_swaps) {
提前终止序号 @(index++)
起始日期 @(eod.CloseStartDate.OtcFormatDate()) 平仓日期 @(eod.ValueDate.OtcFormatDate())
平仓总额 实现盈亏
}
} @if (swap_deals.Count > 0) { var index = 1;
@foreach (var deal in swap_deals) { var tc = deal.unwindData; var closeFloat = tc.FlowEvents.FirstOrDefault(x => !string.IsNullOrEmpty(x.UnderlyingCode)); var DealInterests = tc.FlowEvents.Where(x => string.IsNullOrEmpty(x.UnderlyingCode)).ToList(); var swapInterests = DealInterests.Where(x => ConsTrade.InterestModels.Contains(x.InterestMode)).ToList(); var marginInterests = DealInterests.Where(x => x.InterestMode == 5 || x.InterestMode == 6).ToList();
互换序号 @(index++) 互换名义本金
起始日期 @(tc.StartDate.OtcFormatDate()) 互换日期 @(tc.ValueDate.OtcFormatDate())
支付日期 @(tc.PayDate?.OtcFormatDate() ?? tc.ValueDate.OtcFormatDate())
平仓总额 实现盈亏
@if (marginInterests.Count > 0) {
@foreach (var item in marginInterests) { var bgclass = item.InterestDirection == (int)SwapDirectionEnum.收取 ? "swapget" : "swappay"; }
收支方向 其他费用 利息金额 预付金平仓盈亏
@((SwapDirectionEnum)item.InterestDirection)
} @if (swapInterests.Count > 0) {
@foreach (var item in swapInterests) { var bgclass = item.InterestDirection == (int)SwapDirectionEnum.收取 ? "swapget" : "swappay"; }
收支方向 其他费用 利息金额 利息端平仓盈亏
@((SwapDirectionEnum)item.InterestDirection)
} @if (singleTrade && closeFloat != null) { var fbgclass = closeFloat.PayDirection == (int)SwapDirectionEnum.收取 ? "swapget" : "swappay"; var multiplier = ConsGlobal.InstrumentType.IsBond(closeFloat.UnderlyingInstrumentType) ? 100 : 1;
@if (!hideFloatingIncomeDirection) { } @if (isBond) { } else { } @if (!hideFloatingIncomeDirection) { } @if (isBond) { } else { }
收支方向多空方向 标的代码@spotPriceTitle @netSportPriceTitle标的价格@endSpotPriceTitle 数量 交易费用 分红收益 浮动端平仓盈亏
@((SwapDirectionEnum)closeFloat.PayDirection)@FloatingPositionTypeText(closeFloat.PayDirection, closeFloat.PositionType) @closeFloat.UnderlyingCode
}
}
} @if (trade.ClientCashInCashOutList.Count > 0) {
@foreach (var item in trade.ClientCashInCashOutList) { }
资金编号 方向类型 金额 资金状态 操作人 创建人 发生时间 操作时间 备注
@item.Number @item.TradeDirectionType @(item.Money == 0 ? 0 : item.Money * -1) @item.State @item.OptName @item.CreatorName @item.HappenDate?.ToString("yyyy-MM-dd") @item.OptDate?.ToString("yyyy-MM-dd HH:mm:ss") @(item.Comments)
}
@if (!string.IsNullOrWhiteSpace(Context.Request.Query["abstract"])) { @await Html.PartialAsync("/Views/trade/_part/TradeAbstractInfo.cshtml", Model.Trade) }