- 为价格字段添加9位小数精度的导出格式化器 - 实现自定义导出函数exportEodPositionRows以支持完整数据导出 - 在jqGrid列配置中添加exportFormatter和exportNumberFormat属性 - 更新utils.js中的导出逻辑以支持自定义格式化器和数字格式 - 在数据库上下文中添加ClientBalanceDaily实体的货币精度转换配置 - 修复导出时价格精度丢失问题,确保财务数据准确性
950 lines
30 KiB
JavaScript
950 lines
30 KiB
JavaScript
var queryurl = '/swaptrade2/EodPositionRiskQuery';
|
|
var cloumnTargetName = "eodSwapPositionList";
|
|
var eodSwapExportColumnNames = [];
|
|
$(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();
|
|
eodSwapExportColumnNames = colModelGrid.filter(function (col) {
|
|
return !col.optionHide;
|
|
}).map(function (col) {
|
|
return col.name;
|
|
});
|
|
}
|
|
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: page.tabIndex == 2,
|
|
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,
|
|
exportFormatter: ExportPriceNineDecimalFormat,
|
|
exportNumberFormat: '0.000000000'
|
|
}, {
|
|
name: 'eodPosition.PosiGrossPrice',
|
|
label: '期初价格-不含费',
|
|
index: 'eodPosition.PosiGrossPrice',
|
|
width: 90,
|
|
align: 'center',
|
|
formatter: PriceFormat,
|
|
exportFormatter: ExportPriceNineDecimalFormat,
|
|
exportNumberFormat: '0.000000000'
|
|
}, {
|
|
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() {
|
|
//按需求《估值模块V1》2.2 分组定义排列列顺序,确保组内列连续(setGroupHeaders 要求)
|
|
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: 'SwapTradeTypeStr',
|
|
label: '互换类型',
|
|
index: 'SwapTradeTypeStr',
|
|
width: 100,
|
|
align: 'center',
|
|
sortable: false
|
|
}, {
|
|
name: 'UnderlyingType',
|
|
label: '标的类型',
|
|
index: 'UnderlyingType',
|
|
width: 100,
|
|
align: 'center',
|
|
sortable: false
|
|
},
|
|
//=== 名义本金 ===
|
|
{
|
|
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: 'FloatingUnrealizedPnl',
|
|
label: '合约浮动端待实现收益',
|
|
index: 'FloatingUnrealizedPnl',
|
|
width: 150,
|
|
align: 'center',
|
|
formatter: StockEqvNotionalFormat,
|
|
}, {
|
|
name: 'PeriodAmount',
|
|
label: '期间付息/分红',
|
|
index: 'PeriodAmount',
|
|
width: 150,
|
|
align: 'center',
|
|
formatter: StockEqvNotionalFormat,
|
|
cellattr: function () {
|
|
return ' title="合约期间内的期间付息金额(无关乎派息支付日)"';
|
|
},
|
|
},
|
|
//=== 利息端 ===
|
|
{
|
|
name: 'position.InterestPnL',
|
|
label: '合约利息端待实现收益',
|
|
index: 'position.InterestPnL',
|
|
width: 150,
|
|
align: 'center',
|
|
formatter: otcformat.trading.notional,
|
|
},
|
|
//=== 保证金 ===
|
|
{
|
|
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: 'MarginInterestGain',
|
|
label: '收取对手方保证金利息',
|
|
index: 'MarginInterestGain',
|
|
width: 170,
|
|
align: 'center',
|
|
formatter: StockEqvNotionalFormat,
|
|
}, {
|
|
name: 'MarginInterestLoss',
|
|
label: '支付对手方保证金利息',
|
|
index: 'MarginInterestLoss',
|
|
width: 170,
|
|
align: 'center',
|
|
formatter: StockEqvNotionalFormat,
|
|
},
|
|
//=== 估值与实现收益 ===
|
|
{
|
|
name: 'position.dv01',
|
|
label: 'DV',
|
|
index: 'position.dv01',
|
|
width: 120,
|
|
align: 'center',
|
|
formatter: function (cellvalue, options, rowObject) {
|
|
if (Number.isNaN(cellvalue)) return "0";
|
|
var abs = Math.abs(Number(cellvalue));
|
|
if (abs < 0.0001) return "0";
|
|
return cellvalue.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 4 });
|
|
},
|
|
}, {
|
|
name: 'InterestPaymentMethod',
|
|
label: '付息方式',
|
|
index: 'InterestPaymentMethod',
|
|
width: 120,
|
|
align: 'center',
|
|
}, {
|
|
name: 'MaturityNettingValuation',
|
|
label: '合约估值(到期轧差口径)',
|
|
index: 'MaturityNettingValuation',
|
|
width: 190,
|
|
align: 'center',
|
|
formatter: NullableStockEqvNotionalFormat,
|
|
}, {
|
|
name: 'PeriodPaymentValuation',
|
|
label: '合约估值(期间支付派息口径)',
|
|
index: 'PeriodPaymentValuation',
|
|
width: 210,
|
|
align: 'center',
|
|
formatter: NullableStockEqvNotionalFormat,
|
|
}, {
|
|
name: 'position.RealizedPnL',
|
|
label: '合约已实现收益',
|
|
index: 'position.RealizedPnL',
|
|
width: 150,
|
|
align: 'center',
|
|
formatter: StockEqvNotionalFormat,
|
|
}
|
|
|
|
];
|
|
return colModelGrid;
|
|
}
|
|
|
|
//框架合约分组配置(对应需求《估值模块V1》2.2 字段定义)
|
|
//columns 使用 colModel.name;组内列在 colModel 中必须连续
|
|
var eodSwapGroupConfig = [
|
|
{ title: '基本信息', columns: ['position.ValueDate', 'AssetBookName', 'ClientName', 'SwapTradeNo', 'StructureType', 'SwapTradeTypeStr', 'UnderlyingType'] },
|
|
{ title: '名义本金', columns: ['position.NotionalValue', 'position.NotionalValueLong', 'position.NotionalValueShort'] },
|
|
{ title: '标的市值', columns: ['position.MarketValueLong', 'position.MarketValueShort'] },
|
|
{ title: '浮动端', columns: ['FloatingUnrealizedPnl', 'PeriodAmount'] },
|
|
{ title: '利息端', columns: ['position.InterestPnL'] },
|
|
{ title: '保证金', columns: ['position.InitMarginGain', 'position.PostionMarginGain', 'position.InitMarginLoss', 'position.PostionMarginLoss', 'MarginInterestGain', 'MarginInterestLoss'] },
|
|
{ title: '估值与实现收益', columns: ['position.dv01', 'InterestPaymentMethod', 'MaturityNettingValuation', 'PeriodPaymentValuation', 'position.RealizedPnL'] }
|
|
];
|
|
|
|
|
|
function gridComplete() {
|
|
var jgrid = $(this);
|
|
if (arguments[0].Sum) {
|
|
jgrid.footerData("set", { 'position.dv01': arguments[0].Sum["DV"] });
|
|
}
|
|
//框架合约Tab:列设置应用完成后补充期间付息提示。
|
|
if (page.tabIndex == 2) {
|
|
var defer = main.setcolumnChooser(jgrid, cloumnTargetName);
|
|
$.when(defer).done(function () {
|
|
jgrid.jqGrid('setLabel', 'PeriodAmount', null, null, {
|
|
title: '合约期间内的期间付息金额(无关乎派息支付日)'
|
|
});
|
|
});
|
|
} else {
|
|
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);
|
|
}
|
|
|
|
function exportVisibleColumns() {
|
|
var jgrid = jQuery('#listGrid');
|
|
var dateStr = $("#DateValueDate").val() || '';
|
|
var tabName = page.tabIndex == 2 ? '框架合约' : '日终持仓';
|
|
var fileName = '日终持仓风险_互换_' + tabName + (dateStr ? '_' + dateStr : '');
|
|
if (page.tabIndex != 2) {
|
|
exportEodPositionRows(jgrid, fileName);
|
|
return;
|
|
}
|
|
|
|
layer.open({
|
|
type: 1,
|
|
title: '选择导出方式',
|
|
shadeClose: false,
|
|
shade: 0.4,
|
|
area: ['300px', '200px'],
|
|
content: '<div style="padding:20px">' +
|
|
'<p><input class="btn btn-primary js-export-eod-swap-standard" type="button" value="导出标准格式"></p>' +
|
|
'<p><input class="btn btn-primary js-export-eod-swap-visible" type="button" value="导出界面上全部数据"></p>' +
|
|
'</div>',
|
|
success: function (layero, index) {
|
|
layero.find('.js-export-eod-swap-standard').on('click', function () {
|
|
exportEodSwapRows(jgrid, fileName, eodSwapGroupConfig, eodSwapExportColumnNames);
|
|
layer.close(index);
|
|
});
|
|
layero.find('.js-export-eod-swap-visible').on('click', function () {
|
|
exportEodSwapRows(jgrid, fileName, null, getVisibleEodSwapBusinessColumnNames(jgrid));
|
|
layer.close(index);
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
function exportEodPositionRows(jgrid, fileName) {
|
|
var exportPostData = $.extend({}, GetPostData(), {
|
|
page: jgrid.jqGrid('getGridParam', 'page'),
|
|
rows: jgrid.jqGrid('getGridParam', 'rowNum'),
|
|
sidx: jgrid.jqGrid('getGridParam', 'sortname'),
|
|
sord: jgrid.jqGrid('getGridParam', 'sortorder')
|
|
});
|
|
$.ajax({
|
|
url: queryurl,
|
|
type: 'POST',
|
|
dataType: 'json',
|
|
traditional: true,
|
|
data: exportPostData
|
|
}).done(function (result) {
|
|
main.exportVisibleColumnsToExcel(jgrid, fileName, null, result && result.rows ? result.rows : []);
|
|
}).fail(function () {
|
|
main.message && main.message('导出失败,无法获取日终持仓数据');
|
|
});
|
|
}
|
|
|
|
function getVisibleEodSwapBusinessColumnNames(jgrid) {
|
|
var colModel = jgrid.jqGrid('getGridParam', 'colModel') || [];
|
|
return colModel.filter(function (col) {
|
|
return col.hidden !== true && !col.optionHide && col.name !== 'cb' && col.name !== 'rn';
|
|
}).map(function (col) {
|
|
return col.name;
|
|
});
|
|
}
|
|
|
|
function exportEodSwapRows(jgrid, fileName, groupConfig, exportColumnNames) {
|
|
var exportPostData = $.extend({}, GetPostData(), {
|
|
page: 1,
|
|
rows: 0,
|
|
sidx: jgrid.jqGrid('getGridParam', 'sortname'),
|
|
sord: jgrid.jqGrid('getGridParam', 'sortorder')
|
|
});
|
|
$.ajax({
|
|
url: queryurl,
|
|
type: 'POST',
|
|
dataType: 'json',
|
|
traditional: true,
|
|
data: exportPostData
|
|
}).done(function (result) {
|
|
main.exportVisibleColumnsToExcel(jgrid, fileName, groupConfig, result && result.rows ? result.rows : [], exportColumnNames);
|
|
}).fail(function () {
|
|
main.message && main.message('导出失败,无法获取筛选后的全部数据');
|
|
});
|
|
}
|
|
//---------------------------Formatter---------------------------------
|
|
function PriceFormat(cellValue, options, rowObject) {
|
|
return otcformat.trading.umprice(cellValue);
|
|
}
|
|
|
|
function ExportPriceNineDecimalFormat(cellValue) {
|
|
if (cellValue === null || cellValue === undefined || cellValue === '') {
|
|
return '';
|
|
}
|
|
var price = Number(cellValue);
|
|
return isFinite(price) ? price.toFixed(9) : cellValue;
|
|
}
|
|
|
|
function RealizedPnlFormat(cellValue, options, rowObject) {
|
|
return otcformat.trading.tradePrice(cellValue);
|
|
}
|
|
|
|
function StockEqvNotionalFormat(cellValue, options, rowObject) {
|
|
return otcformat.trading.StockEqvNotional(cellValue);
|
|
}
|
|
function NullableStockEqvNotionalFormat(cellValue, options, rowObject) {
|
|
if (cellValue === null || cellValue === undefined || cellValue === '') {
|
|
return '';
|
|
}
|
|
return StockEqvNotionalFormat(cellValue, options, rowObject);
|
|
}
|
|
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);
|
|
}
|