收益互换模板选择逻辑优化结合 swap_position 的 PosiDirection(收支方向)与 PositionType(多空方向)共同判断客户看多/看空方向
This commit is contained in:
@@ -22,7 +22,8 @@ namespace YLErp.Plugins.GuoLian.DocumentGenerator
|
||||
/// <summary>
|
||||
/// 获取模板文件路径
|
||||
/// 收益互换模板选择逻辑:
|
||||
/// 1. 客户看多/看空:通过持仓方向判断(PositionType: 1=多头/看多,2=空头/看空)
|
||||
/// 1. 客户看多/看空:根据 swap_position 的 PosiDirection(收支方向)和 PositionType(多空方向)
|
||||
/// 组合出我方方向,再取反得到客户方向。
|
||||
/// 2. 标的类型:
|
||||
/// - 债券ETF:.SH后缀且511开头,或.SZ后缀且59开头
|
||||
/// - 现券:其他
|
||||
@@ -54,22 +55,31 @@ namespace YLErp.Plugins.GuoLian.DocumentGenerator
|
||||
var trade = Context.Trade;
|
||||
var underlying = Context.GetTradeUnderlying();
|
||||
|
||||
// 判断看多/看空方向(通过持仓方向判断:PositionType: 1=多头/看多,2=空头/看空)
|
||||
// 判断客户看多/看空方向:
|
||||
// 先根据 PosiDirection(收支方向)和 PositionType(多空方向)组合出我方方向,再取反得到客户方向。
|
||||
var swapPosition = Context.GetSwapPositions(trade.id, true)
|
||||
.Where(x => x.PositionType == (int)PositionTypeFlag.Long || x.PositionType == (int)PositionTypeFlag.Short)
|
||||
.FirstOrDefault();
|
||||
bool isLong = swapPosition?.PositionType == (int)PositionTypeFlag.Long;
|
||||
|
||||
bool isCustomerLong = false;
|
||||
if (swapPosition != null)
|
||||
{
|
||||
bool isOurLong = swapPosition.PosiDirection == (int)SwapDirectionEnum.支付
|
||||
? swapPosition.PositionType == (int)PositionTypeFlag.Short // 支付端:我方方向与 PositionType 相反
|
||||
: swapPosition.PositionType == (int)PositionTypeFlag.Long; // 收取端:我方方向与 PositionType 相同
|
||||
isCustomerLong = !isOurLong;
|
||||
}
|
||||
|
||||
// 判断标的类型(债券ETF vs 现券)
|
||||
bool isEtf = IsBondEtf(underlying?.UnderlyingCode ?? string.Empty);
|
||||
|
||||
// 选择对应模板(使用客户提供的原始文件名)
|
||||
string templateName;
|
||||
if (isLong && !isEtf)
|
||||
if (isCustomerLong && !isEtf)
|
||||
templateName = "国联民生-收益互换交易确认书-境内模板-【客户看多】-【现券】-清洁版.docx";
|
||||
else if (isLong && isEtf)
|
||||
else if (isCustomerLong && isEtf)
|
||||
templateName = "国联民生-收益互换交易确认书-境内模板-【客户看多】-【债券ETF】-清洁版.docx";
|
||||
else if (!isLong && !isEtf)
|
||||
else if (!isCustomerLong && !isEtf)
|
||||
templateName = "国联民生-收益互换交易确认书-境内模板-【客户看空】-【现券】-清洁版.docx";
|
||||
else
|
||||
templateName = "国联民生-收益互换交易确认书-境内模板-【客户看空】-【债券ETF】-清洁版.docx";
|
||||
|
||||
Reference in New Issue
Block a user