diff --git a/YLErpDAL/Modules/SwapModule/SwapDealService.cs b/YLErpDAL/Modules/SwapModule/SwapDealService.cs
index e95b395b..2c4f24fe 100644
--- a/YLErpDAL/Modules/SwapModule/SwapDealService.cs
+++ b/YLErpDAL/Modules/SwapModule/SwapDealService.cs
@@ -1,7 +1,5 @@
using MoreLinq.Extensions;
using Newtonsoft.Json;
-using Qdp.Pricing.Library.Base.Utilities;
-using System.Linq.Expressions;
using YLErp.BLL;
using YLErp.BLL.Eod;
using YLErp.DBModels.Enums;
@@ -9,11 +7,11 @@ using YLErp.Derivatives.Interest;
using YLErp.Helpers;
using YLErp.Modules.DataProviderModule;
using YLErp.Modules.EodModule;
-using YLErp.Modules.TradeModule;
-using YLErp.Modules.TradeModule.DealModule;
using YLErp.Modules.SwapModule.FundingLegs;
using YLErp.Modules.SwapModule.Margin;
using YLErp.Modules.SwapModule.ReturnLegs;
+using YLErp.Modules.TradeModule;
+using YLErp.Modules.TradeModule.DealModule;
using YLErp.QdpModule;
namespace YLErp.Modules.SwapModule
@@ -1153,6 +1151,22 @@ namespace YLErp.Modules.SwapModule
? (int)SwapDirectionEnum.支付
: (int)SwapDirectionEnum.收取;
+ ///
+ /// 汇总保证金腿的平仓返还金额(SwapMarginAmount)和保证金返息(SwapMarginRebatePnl)。
+ /// 保证金方向与融资腿相反:interestRatio = InterestDirection==1 ? -1 : 1。
+ /// 待迁入 Margin 模块。
+ ///
+ private static void AccumulateMarginSettlement(List interestList, UnwindData unwindData)
+ {
+ foreach (var x in interestList)
+ {
+ if (!MarginModes.Contains(x.InterestMode)) continue;
+ var interestRatio = x.InterestDirection == 1 ? -1m : 1m;
+ unwindData.SwapMarginRebatePnl += x.InterestClosePnL;
+ unwindData.SwapMarginAmount += x.InterestPrincipal * interestRatio;
+ }
+ }
+
///
/// 初始化利息腿信息
///
@@ -1993,17 +2007,11 @@ namespace YLErp.Modules.SwapModule
unwindData.SwapMarginAmount = 0;
if (interestList != null)
{
+ AccumulateMarginSettlement(interestList.ToList(), unwindData);
interestList.ForEach(x =>
{
- if (MarginModes.Contains(x.InterestMode))
- {
- decimal interestRatio = x.InterestDirection == 1 ? -1m : 1m;
- unwindData.SwapMarginRebatePnl += x.InterestClosePnL;
- unwindData.SwapMarginAmount += x.InterestPrincipal * interestRatio;
- }
unwindData.SwapRealizedPnL += x.InterestClosePnL;
unwindData.SwapCloseAmount += x.InterestClosePnL;
-
});
}
unwindData.SwapCloseAmount = Math.Round(unwindData.SwapCloseAmount, 2, MidpointRounding.AwayFromZero);