优化收益互换方向判断逻辑,移除冗余方法

This commit is contained in:
锦麟 王
2026-04-13 14:55:57 +08:00
parent 44c3c87304
commit 789c882448
@@ -54,8 +54,11 @@ namespace YLErp.Plugins.GuoLian.DocumentGenerator
var trade = Context.Trade;
var underlying = Context.GetTradeUnderlying();
// 判断看多/看空方向
bool isLong = IsLongPosition(trade);
// 判断看多/看空方向(通过持仓方向判断:PositionType: 1=多头/看多,2=空头/看空)
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;
// 判断标的类型(债券ETF vs 现券)
bool isEtf = IsBondEtf(underlying?.UnderlyingCode ?? string.Empty);
@@ -74,15 +77,6 @@ namespace YLErp.Plugins.GuoLian.DocumentGenerator
return Path.Combine(GlobalConfig.PluginFolder, "App_Docs\\contract_template", templateName);
}
/// <summary>
/// 判断是否为多头/看多方向
/// </summary>
private bool IsLongPosition(OtcTradeBase trade)
{
// 通过BuySell判断:买入=看多,卖出=看空
return trade.BuySell == "买入";
}
/// <summary>
/// 判断是否为债券ETF
/// - .SH后缀且511开头 -> 债券ETF