收盘自动互换,需要将当前计息基数给回到持仓名义本金或固定值

This commit is contained in:
吴方海
2026-05-14 16:15:38 +08:00
parent fb735d4740
commit 44e8972626
2 changed files with 12 additions and 8 deletions
@@ -825,7 +825,8 @@ namespace YLErp.Modules.SwapModule
positions.Add(position);
List<eod_swap_position> preEodPositions = new List<eod_swap_position>();
preEodPositions.Add(eodPayPosition);
if (position.InterestMode == (int)InterestModeEnum.||position.InterestMode == (int)InterestModeEnum. || position.InterestMode == (int)InterestModeEnum.)
var interestModes = new List<int>() { (int)InterestModeEnum., (int)InterestModeEnum., (int)InterestModeEnum. };
if (interestModes.Contains(position.InterestMode))
{
orginPv = eodPayPosition.InterestPrincipalFix;
}
@@ -853,7 +854,7 @@ namespace YLErp.Modules.SwapModule
newEodPayPosition.FloatRateUnderlyingCode = position.FloatRateUnderlyingCode;
newEodPayPosition.InterestFeePending = 0;
//利息端估值用信息
newEodPayPosition.TdInterestPrincipal = interests.Count > 0 ? interests.First().InterestPrincipal : 0;
eodPayPosition.TdInterestPrincipal = interestModes.Contains(position.InterestMode) ? eodPayPosition.InterestPrincipalFix : posiNotionalValue;
newEodPayPosition.TdInterestRate = interval.Rate;
//当日已实现
//newEodPayPosition.TdInterestFee = 0;
@@ -920,7 +921,8 @@ namespace YLErp.Modules.SwapModule
newEodPayPosition = eodPayPosition.Clone();
newEodPayPosition.id = 0;
}
if (position.InterestMode == (int)InterestModeEnum. || position.InterestMode == (int)InterestModeEnum. || position.InterestMode == (int)InterestModeEnum.)
var interestModes = new List<int>() { (int)InterestModeEnum., (int)InterestModeEnum., (int)InterestModeEnum. };
if (interestModes.Contains(position.InterestMode))
{
orginPv = eodPayPosition.InterestPrincipalFix;
}
@@ -962,8 +964,7 @@ namespace YLErp.Modules.SwapModule
newEodPayPosition.interest_rest_days = position.interest_rest_days;
newEodPayPosition.interest_rule = position.interest_rule;
//利息端估值用信息
newEodPayPosition.TdInterestPrincipal = interests.Count > 0 ? interests.First().InterestPrincipal : 0;
newEodPayPosition.TdInterestPrincipal *= (1 - closePercent);
newEodPayPosition.TdInterestPrincipal = interestModes.Contains(position.InterestMode) ? eodPayPosition.InterestPrincipalFix : posiLongNotional + posiShortNational;
if (interval != null)
{
newEodPayPosition.TdInterestRate = interval.Rate;
@@ -1027,6 +1028,7 @@ namespace YLErp.Modules.SwapModule
Log.Info($"eodPayPosition is {JsonHelper.Serialize(eodPayPosition, false)},newEodPayPosition is {JsonHelper.Serialize(newEodPayPosition, false)}");
List<IntervalModel> intervals = position.SwapIntervalList;
var tradeExtend = td.trade_extend.ExtendObj;
var interestModes = new List<int>() { (int)InterestModeEnum., (int)InterestModeEnum., (int)InterestModeEnum. };
if (eodPayPosition == null)
{
//if (position.PosiStartDate > valueDate)
@@ -1038,11 +1040,12 @@ namespace YLErp.Modules.SwapModule
eodPayPosition.ClientId = td.ClientId;
eodPayPosition.SwapTradeId = td.id;
//eodPayPosition.PositionId = position.id; 为了算利息时找不到给日期重新赋值
eodPayPosition.InterestMode = position.InterestMode;
eodPayPosition.InterestPrincipalFix = position.InterestPrincipalFix;
eodPayPosition.InterestRateDefault = position.InterestRateDefault;
eodPayPosition.InterestSwapInterval = position.InterestSwapInterval;
eodPayPosition.TdInterestPrincipal = position.InterestMode == 1 ? eodPayPosition.InterestPrincipalFix : posiLongNational + posiShortNational;
eodPayPosition.TdInterestPrincipal = interestModes.Contains(position.InterestMode) ? eodPayPosition.InterestPrincipalFix : posiLongNational + posiShortNational;
eodPayPosition.PosiStartDate = td.StartDate.Value;
eodPayPosition.PosiMatuirityDate = td.ExerciseDate.Value;
eodPayPosition.IsAnnualized = position.IsAnnualized;
@@ -1060,7 +1063,7 @@ namespace YLErp.Modules.SwapModule
newEodPayPosition.id = 0;
newEodPayPosition.PositionId = position.id;
}
if (position.InterestMode == (int)InterestModeEnum. || position.InterestMode == (int)InterestModeEnum. || position.InterestMode == (int)InterestModeEnum.)
if (interestModes.Contains(position.InterestMode))
{
orginPv = eodPayPosition.InterestPrincipalFix;
}
@@ -397,10 +397,11 @@ namespace YLErp.Modules.SwapModule
// 删除预付金腿的资金记录(通过交易ID、日期和Action类型查找,一次性查询避免MySQL连接重用问题)
var swapTradeIds = swapEvents.Select(s => s.SwapTradeId).Distinct().ToList();
var actions = new List<string>() { ClientCashInCashOut._预付金返息, ClientCashInCashOut._互换 };
var premiumCashRecords = DbContext.ClientCashInCashOut
.Where(x => swapTradeIds.Contains(x.TradeId ?? 0)
&& x.HappenDate>=valueDate
&& x.Action == ClientCashInCashOut._预付金返息)
&& actions.Contains(x.Action))
.ToList();
if (premiumCashRecords.Any())
{