var queryurl = '/swaptrade2/EodPositionRiskQuery'; var cloumnTargetName = "eodSwapPositionList"; $(function () { var PostData = {}; $("#DateValueDate").datepicker({ changeMonth: true, changeYear: true, showButtonPanel: true, showOtherMonths: true, selectOtherMonths: true, maxDate: page.valueDate_eod }); $("#DateValueDate").val(page.valueDate_eod); var colModelGrid = colModelGridEodPosition(); if (page.tabIndex == 2) { queryurl = '/swaptrade2/EodSwapRiskQuery'; $("#myTab li:first").removeClass("active"); $("#myTab li:eq(1)").addClass("active"); cloumnTargetName = "eodSwapList"; colModelGrid = colModelGridEodSwap(); } PostData.ValueDate = $("#DateValueDate").val(); var grid = jQuery('#listGrid').jqGrid({ url: queryurl, datatype: 'json', height: 'auto', width: '96%', multiselect: false, autowidth: false, shrinkToFit: false, jsonReader: { repeatitems: false }, mtype: 'POST', postData: PostData, afterInsertRow: AfterInsertRow, onSelectRow: rowclick, colModel: colModelGrid, pager: jQuery('#pagerGrid'), pagerpos: 'left', rowNum: 25, rowList: [25, 50, 100, 200, 10000], footerrow: false, loadComplete: gridComplete, onPaging: onJqgridPaging, grouping: true }); function keyEnter(event) { try { var e = event ? event : (window.event ? window.event : null); if (e.keyCode == 13) { SearchClick(true); } } catch (e) { } } document.onkeydown = keyEnter; let underlyingCtrl = new tradeHelper.UnderlyingSelectCtrl('#UnderlyingId') .setFlag(tradeHelper.UnderlyingSelectFlag.OtcTrade); $(window).resize(function () { //如有频繁改变大小的需求,要增加延迟运行的逻辑; $("#listGrid").setGridWidth($("#main-wrapper").width() - 30); var newHeight = $(window).height() - 350; $("#listGrid").setGridHeight(newHeight); }); }); const GroupingFormat = main.numberFormat(2, { grouping: true }); const ThreeDecimalGroupingFormat = main.numberFormat(3, { grouping: false }); var i = 0; //日终持仓table function colModelGridEodPosition() { var colModelGrid = [{ name: 'eodPosition.id', label: 'id', index: 'eodPosition.id', sortIndex: i++, width: 70, align: 'center', hidden: true, optionHide: true }, { name: 'eodPosition.EncryptId', label: 'EncryptId', index: 'eodPosition.EncryptId', sortIndex: i++, width: 70, align: 'center', hidden: true, optionHide: true }, { name: 'eodPosition.UnderlyingInstrumentType', label: 'UnderlyingInstrumentType', index: 'eodPosition.UnderlyingInstrumentType', sortIndex: i++, width: 70, align: 'center', hidden: true, optionHide: true }, { name: 'eodPosition.ValueDate', label: '交易日', index: 'eodPosition.ValueDate', width: 100, align: 'center', sortIndex: i++, formatter: 'date', sortable: true }, { name: 'ClientName', label: '交易对手方', index: 'ClientName', width: 150, sortIndex: i++, align: 'center', sortable: true }, { name: 'SwapTradeNo', label: '互换交易编码', index: 'SwapTradeNo', width: 150, align: 'center', sortIndex: i++, sortable: true }, { name: 'eodPosition.PositionIdPadding', label: '持仓编码', index: 'eodPosition.id', width: 150, align: 'center', sortIndex: i++, sortable: true }, { name: 'eodPosition.PosiDirection', label: '[浮动]收支方向', index: 'eodPosition.PosiDirection', width: 90, align: 'center', formatter: DrictionFormat }, { name: 'eodPosition.PositionType', label: '标的多空(B/S)', index: 'eodPosition.PositionType', width: 90, align: 'center', formatter: PositionTypeFormat }, { name: 'eodPosition.UnderlyingCode', label: '标的代码', index: 'eodPosition.UnderlyingCode', width: 150, align: 'center' }, { name: 'eodPosition.ContractSize', label: '合约乘数', index: 'eodPosition.ContractSize', width: 90, align: 'center', }, { name: 'eodPosition.PosiNetPrice', label: '期初价格', index: 'eodPosition.PosiNetPrice', width: 90, align: 'center', formatter: PriceFormat }, { name: 'eodPosition.PosiGrossPrice', label: '期初价格-不含费', index: 'eodPosition.PosiGrossPrice', width: 90, align: 'center', formatter: PriceFormat, }, { name: 'eodPosition.PosiQuantity', label: '名义数量', index: 'eodPosition.PosiQuantity', width: 100, align: 'center', formatter: otcformat.trading.notional, }, { name: 'eodPosition.PosiNotionalValue', label: '名义本金', index: 'eodPosition.PosiNotionalValue', width: 100, align: 'center', formatter: StockEqvNotionalFormat }, { name: 'eodPosition.PosiFeePending', label: '交易费用佣金', index: 'eodPosition.PosiFeePending', width: 90, align: 'center', formatter: StockEqvNotionalFormat }, { name: 'eodPosition.PosiStartDate', label: '起始日', index: 'eodPosition.PosiStartDate', width: 100, align: 'center', formatter: 'date', }, { name: 'eodPosition.PosiMatuirityDate', label: '到期日', index: 'eodPosition.PosiMatuirityDate', width: 100, align: 'center', formatter: 'date', }, { name: 'eodPosition.UnderlyingPrice', label: '盯市价格', index: 'eodPosition.UnderlyingPrice', width: 100, align: 'center', formatter: PriceFormat, }, { name: 'eodPosition.UnderlyingMarketValue', label: '标的市值', index: 'eodPosition.UnderlyingMarketValue', width: 100, align: 'center', formatter: StockEqvNotionalFormat, }, { name: 'eodPosition.TdPosiDividend', label: '当日浮动端分红', index: 'eodPosition.TdPosiDividend', width: 100, align: 'center', formatter: StockEqvNotionalFormat, }, { name: 'eodPosition.PosiMtmPnL', label: '浮动端待实现收益·盯市', index: 'eodPosition.PosiMtmPnL', width: 100, align: 'center', formatter: StockEqvNotionalFormat, }, { name: 'eodPosition.PosiDividendSum', label: '浮动端待实现收益·分红', index: 'eodPosition.PosiDividendSum', width: 100, align: 'center', formatter: StockEqvNotionalFormat, }, { name: 'eodPosition.PosiFeePending', label: '浮动端待实现收益·后付费用', index: 'eodPosition.PosiFeePending', width: 100, align: 'center', formatter: StockEqvNotionalFormat, }, { name: 'eodPosition.PosiProfitSum', label: '浮动端待实现收益', index: 'eodPosition.PosiProfitSum', width: 100, align: 'center', formatter: StockEqvNotionalFormat, }, { name: 'eodPosition.InterestDirection', label: '[利息]收支方向', index: 'eodPosition.InterestDirection', width: 100, align: 'center', formatter: DrictionFormat, }, { name: 'eodPosition.InterestMode', label: '计息基准类型', index: 'eodPosition.InterestMode', width: 100, align: 'center', formatter: InterestModeFormat, }, { name: 'eodPosition.InterestPrincipalFix', label: '计息基准固定值', index: 'eodPosition.InterestPrincipalFix', width: 100, align: 'center', formatter: StockEqvNotionalFormat, }, { name: 'eodPosition.InterestRateDefault', label: '互换利率(年化)', index: 'eodPosition.InterestRateDefault', width: 100, align: 'center', formatter: PercentFormat, }, { name: 'eodPosition.TdInterestPrincipal', label: '当日适用计息金额', index: 'eodPosition.TdInterestPrincipal', width: 100, align: 'center', formatter: StockEqvNotionalFormat, }, { name: 'eodPosition.TdInterestRate', label: '当日适用利率(年化)', index: 'eodPosition.TdInterestRate', width: 100, align: 'center', formatter: PercentFormat, }, { name: 'eodPosition.TdInterestIncome', label: '当日利率端新计利息', index: 'eodPosition.TdInterestIncome', width: 100, align: 'center', formatter: StockEqvNotionalFormat, }, { name: 'eodPosition.TdInterestFee', label: '当日利率端新增费用', index: 'eodPosition.TdInterestFee', width: 100, align: 'center', formatter: StockEqvNotionalFormat, }, { name: 'eodPosition.InterestIncomeSum', label: '利率端待实现收益-利息', index: 'eodPosition.InterestIncomeSum', width: 100, align: 'center', formatter: StockEqvNotionalFormat, }, { name: 'eodPosition.InterestFeeSum', label: '利率端待实现收益-其他费用', index: 'eodPosition.InterestFeeSum', width: 100, align: 'center', formatter: StockEqvNotionalFormat, }, { name: 'eodPosition.InterestProfitSum', label: '利率端待实现收益', index: 'eodPosition.InterestProfitSum', width: 100, align: 'center', formatter: StockEqvNotionalFormat, }, { name: 'eodPosition.SwapPositionValue', label: '互换持仓价值', index: 'eodPosition.SwapPositionValue', width: 100, align: 'center', formatter: StockEqvNotionalFormat, }, { name: 'eodPosition.TdCloseQty', label: '当日平仓数量', index: 'eodPosition.TdCloseQty', width: 100, align: 'center', formatter: otcformat.trading.notional, }, { name: 'eodPosition.TdChangedQty', label: '当日公司行为数量', index: 'eodPosition.TdChangedQty', width: 100, align: 'center', formatter: otcformat.trading.notional, }, { name: 'eodPosition.TdCloseMtmPnl', label: '当日浮动端平仓盈亏·盯市', index: 'eodPosition.TdCloseMtmPnl', width: 100, align: 'center', formatter: StockEqvNotionalFormat, }, { name: 'eodPosition.TdCloseDividend', label: '当日浮动端平仓盈亏·分红', index: 'eodPosition.TdCloseDividend', width: 100, align: 'center', formatter: StockEqvNotionalFormat, }, { name: 'eodPosition.TdCloseFee', label: '当日浮动端平仓盈亏·费用', index: 'eodPosition.TdCloseFee', width: 100, align: 'center', formatter: StockEqvNotionalFormat, }, { name: 'eodPosition.TdCloseInterest', label: '当日利率端平仓盈亏·利息', index: 'eodPosition.TdCloseInterest', width: 100, align: 'center', formatter: StockEqvNotionalFormat, }, { name: 'eodPosition.TdCloseInterestFee', label: '当日利率端平仓盈亏·其他费用', index: 'eodPosition.TdCloseInterestFee', width: 100, align: 'center', formatter: StockEqvNotionalFormat, }, { name: 'eodPosition.RealizedMtmPnL', label: '浮动端累计已实现盈亏·盯市', index: 'eodPosition.RealizedMtmPnL', width: 100, align: 'center', formatter: StockEqvNotionalFormat, }, { name: 'eodPosition.RealizedDividend', label: '浮动端累计已实现盈亏·分红', index: 'eodPosition.RealizedDividend', width: 100, align: 'center', formatter: StockEqvNotionalFormat, }, { name: 'eodPosition.RealizedFee', label: '浮动端累计已实现盈亏·费用', index: 'eodPosition.RealizedFee', width: 100, align: 'center', formatter: StockEqvNotionalFormat, }, { name: 'eodPosition.RealizedInterest', label: '利率端累计已实现盈亏·利息', index: 'eodPosition.RealizedInterest', width: 100, align: 'center', formatter: StockEqvNotionalFormat, }, { name: 'eodPosition.RealizedInterestFee', label: '利率端累计已实现盈亏·其他费用', index: 'eodPosition.RealizedInterestFee', width: 100, align: 'center', formatter: StockEqvNotionalFormat, }, { name: 'eodPosition.RealizedPnl', label: '已实现盈亏', index: 'eodPosition.RealizedPnl', width: 100, align: 'center', formatter: StockEqvNotionalFormat, }, { name: 'eodPosition.TdCurrency', label: '当日适用汇率', index: 'eodPosition.TdCurrency', width: 100, align: 'center', formatter: otcformat.trading.notional, }, { name: 'eodPosition.PosiStatus', label: '持仓状态', index: 'eodPosition.PosiStatus', width: 100, align: 'center', formatter: PosiStatusFormat, }, { name: 'SwapTradeTypeStr', label: '互换类型', index: 'SwapTradeTypeStr', width: 100, align: 'center', sortable: false } ]; return colModelGrid; } //框架合约table function colModelGridEodSwap() { var colModelGrid = [{ name: 'position.id', label: 'id', index: 'position.id', sortIndex: i++, width: 70, align: 'center', hidden: true, optionHide: true }, { name: 'position.EncryptId', label: 'EncryptId', index: 'position.EncryptId', sortIndex: i++, width: 70, align: 'center', hidden: true, optionHide: true }, { name: 'position.ValueDate', label: '交易日', index: 'position.ValueDate', width: 150, align: 'center', sortIndex: i++, formatter: 'date', sortable: true }, { name: 'AssetBookName', label: '簿记账户', index: 'AssetBookName', width: 150, align: 'center', }, { name: 'ClientName', label: '交易对手方', index: 'ClientName', width: 150, sortIndex: i++, align: 'center', sortable: true }, { name: 'SwapTradeNo', label: '互换交易编码', index: 'SwapTradeNo', width: 150, align: 'center', sortIndex: i++, sortable: true }, { name: 'StructureType', label: '产品类型', index: 'StructureType', width: 90, align: 'center', }, { name: 'position.NotionalValue', label: '合约名义本金', index: 'position.NotionalValue', width: 150, align: 'center', formatter: StockEqvNotionalFormat }, { name: 'position.NotionalValueLong', label: '合约多头名义本金', index: 'position.NotionalValueLong', width: 150, align: 'center', formatter: StockEqvNotionalFormat }, { name: 'position.NotionalValueShort', label: '合约空头名义本金', index: 'position.NotionalValueShort', width: 150, align: 'center', formatter: StockEqvNotionalFormat }, { name: 'position.MarketValueLong', label: '合约多头标的市值', index: 'position.MarketValueLong', width: 150, align: 'center', formatter: StockEqvNotionalFormat }, { name: 'position.MarketValueShort', label: '合约空头标的市值', index: 'position.MarketValueShort', width: 150, align: 'center', formatter: StockEqvNotionalFormat }, { name: 'position.FloatingPnL', label: '合约浮动端待实现收益', index: 'position.FloatingPnL', width: 150, align: 'center', formatter: StockEqvNotionalFormat, }, { name: 'position.InterestPnL', label: '合约利率端待实现收益', index: 'position.InterestPnL', width: 150, align: 'center', formatter: otcformat.trading.notional, }, { name: 'position.PostionValue', label: '合约持仓价值', index: 'position.PostionValue', width: 150, align: 'center', formatter: StockEqvNotionalFormat }, { name: 'position.TdRealizedPnL', label: '合约当日实现收益', index: 'position.TdRealizedPnL', width: 150, align: 'center', formatter: StockEqvNotionalFormat }, { name: 'position.RealizedPnL', label: '合约已实现收益', index: 'position.RealizedPnL', width: 150, align: 'center', formatter: StockEqvNotionalFormat, }, { name: 'position.InitMarginGain', label: '收取对手方初始预付金', index: 'position.InitMarginGain', width: 150, align: 'center', formatter: StockEqvNotionalFormat, }, { name: 'position.PostionMarginGain', label: '收取对手方维持预付金', index: 'position.PostionMarginGain', width: 150, align: 'center', formatter: StockEqvNotionalFormat, }, { name: 'position.InitMarginLoss', label: '支付初始预付金', index: 'position.InitMarginLoss', width: 150, align: 'center', formatter: StockEqvNotionalFormat, }, { name: 'position.PostionMarginLoss', label: '支付维持预付金', index: 'position.PostionMarginLoss', width: 150, align: 'center', formatter: StockEqvNotionalFormat, }, { name: 'SwapTradeTypeStr', label: '互换类型', index: 'SwapTradeTypeStr', width: 100, align: 'center', sortable: false } ]; return colModelGrid; } function gridComplete() { var jgrid = $(this); main.setcolumnChooser(jgrid, page.configcolumn_data); $(window).resize(); } function rowdblclick(rowid) { var rowData = $(this).getRowData(rowid); if (rowData.id > 0) { starttradeView(rowData.EncryptTradeId); } } function starttradeView(id) { var srcurl = "/swaptrade2/tradeView/?enid=" + id + "&isFromPositionReport=false&isOnlyCloseButton=true"; main.open("查看交易", srcurl); } //---------------------------Formatter--------------------------------- function PriceFormat(cellValue, options, rowObject) { return otcformat.trading.umprice(cellValue); } function RealizedPnlFormat(cellValue, options, rowObject) { return otcformat.trading.tradePrice(cellValue); } function StockEqvNotionalFormat(cellValue, options, rowObject) { return otcformat.trading.StockEqvNotional(cellValue); } function PosiStatusFormat(cellValue, options, rowObject) { return cellValue == 1 ? "已平" : "正常"; } function PositionTypeFormat(cellValue, options, rowObject) { if (cellValue == 1) { return "B"; } if (cellValue == 2) { return "S"; } return ""; } function DrictionFormat(cellValue, options, rowObject) { if (cellValue == 1) { return "收取"; } if (cellValue == 2) { return "支付"; } return ""; } function InterestModeFormat(cellValue, options, rowObject) { switch (cellValue) { case 1: return "固定值"; case 2: return "框架合约名义本金规模"; case 3: return "持仓名义本金"; case 4: return "持仓市值"; case 5: return "初始预付金"; case 6: return "追加预付金"; default: return ""; } } function PercentFormat(cellValue, options, rowObject) { if (cellValue) { var num = new Number(cellValue) * 100; return num.toFixed(2) + "%"; } else { return "0.00%"; } } function SwapTimeAndRateFormat(cellValue, options, rowObject) { if (cellValue != null && cellValue.indexOf(";") > 0) { var spCellValue = cellValue.split(";")[1]; if (spCellValue != null && spCellValue.indexOf(",") > 0) { return PercentFormat(spCellValue.split(",")[0]); } else { return PercentFormat(spCellValue); } } return PercentFormat(cellValue); } //--------------------------------------------------------------------------------- function rowclick(id) { } function exportTrade() { var jgrid = jQuery('#listGrid'); var postData = GetPostData(); var ids = jgrid.jqGrid('getGridParam', 'selarrrow'); if (ids.length > 0) { postData.TradeIds = ids; } downLoadFile("/swaptrade/DownloadEodPositionRisks?" + $.param(postData, true)); } function downLoadFile(downloadUrlStr) { window.open(downloadUrlStr); } function GetPostData() { var postData = {}; postData.ValueDate = $("#DateValueDate").val(); postData.TradeNumber = $("#TradeNumber").val(); postData.BookIds = $("#BookId").val(); postData.AssetIdGroupList = $("#GroupId").val(); postData.UnderlyingIds = $("#UnderlyingId").val(); postData.ClientIds = $("#ClientId").val(); return postData; } function SearchClick(isSearchclick) { var listGrid = $('#listGrid'); listGrid.appendPostData(GetPostData()); if (typeof (isSearchclick) != "undefined" && isSearchclick) { //点击搜索时默认第一页 listGrid.jqGrid('setGridParam', { page: 1 }); } listGrid.trigger('reloadGrid'); } function showcolumnChooser() { var jgrid = jQuery('#listGrid'); main.showcolumnChooser(jgrid, cloumnTargetName, page.configcolumn_data); }