#EQD-5718 【缺陷转需求】-国联民生-利息端计息方式与结算规则扩充
This commit is contained in:
@@ -136,7 +136,15 @@ namespace YLErp.Modules.SwapModule
|
||||
var grossPrice = curEodPosis.Where(x => x.PosiDirection > 0).FirstOrDefault()?.PosiGrossPrice ?? 0;
|
||||
//处理利息腿
|
||||
DealInterests(interestList, eodPositions, todyEodPositions, settleDate, td, flowEvents, autoInterests, lastEodSwap, posiLongNotional, posiShortNotional, closePosiNotional, grossPrice, orginPv);
|
||||
DealAutoInterests(autoInterests, td, settleDate, preDealDate, posiLongNotional + posiShortNotional);
|
||||
//获取自动互换的 interval 信息,用于确定结算日期
|
||||
IntervalModel autoInterval = null;
|
||||
foreach (var interest in interestList)
|
||||
{
|
||||
autoInterval = interest.SwapIntervalList.FirstOrDefault(x => x.Date == settleDate && x.Settlement == 1);
|
||||
if (autoInterval != null)
|
||||
break;
|
||||
}
|
||||
DealAutoInterests(autoInterests, td, settleDate, preDealDate, posiLongNotional + posiShortNotional, autoInterval);
|
||||
//多空组合判断是否已到到期日且无持仓信息
|
||||
if (longShort && td.ExerciseDate.Value == settleDate && allPositionQty == 0)
|
||||
{
|
||||
@@ -361,7 +369,8 @@ namespace YLErp.Modules.SwapModule
|
||||
/// <param name="td"></param>
|
||||
/// <param name="settleDate"></param>
|
||||
/// <param name="swapDeals"></param>
|
||||
private void DealAutoInterests(List<swap_flow_event> autoInterests, trade td, DateTime settleDate, DateTime? preDealDate, decimal StockEqvNotional)
|
||||
/// <param name="interval">自动互换观察日信息,用于获取结算日期</param>
|
||||
private void DealAutoInterests(List<swap_flow_event> autoInterests, trade td, DateTime settleDate, DateTime? preDealDate, decimal StockEqvNotional, IntervalModel interval)
|
||||
{
|
||||
if (autoInterests.Count == 0)
|
||||
{
|
||||
@@ -387,17 +396,20 @@ namespace YLErp.Modules.SwapModule
|
||||
unwindData.SwapCloseAmount = unwindData.SwapCloseAmount + x.InterestClosePnL;
|
||||
unwindData.SwapRealizedPnL = unwindData.SwapCloseAmount;
|
||||
});
|
||||
SaveAutoSwapDeal(td, autoInterests, unwindData);
|
||||
SaveAutoSwapDeal(td, autoInterests, unwindData, interval);
|
||||
}
|
||||
/// <summary>
|
||||
/// 保存自动互换数据信息
|
||||
/// </summary>
|
||||
/// <param name="td"></param>
|
||||
/// <param name="swap_Deal"></param>
|
||||
private long SaveAutoSwapDeal(trade td, List<swap_flow_event> flowEvents, UnwindData unwindData)
|
||||
/// <param name="interval">自动互换观察日信息,用于获取结算日期</param>
|
||||
private long SaveAutoSwapDeal(trade td, List<swap_flow_event> flowEvents, UnwindData unwindData, IntervalModel interval)
|
||||
{
|
||||
//td.UnWindDate = unwindData.ValueDate;
|
||||
int clientCashId = AddClientCashInCashOut(td, Convert.ToDouble(-unwindData.SwapCloseAmount), ClientCashInCashOut.系统操作_互换, unwindData.ValueDate);
|
||||
//优先使用 interval.SettlementDate 作为资金记录发生日期,如果没有则使用 ValueDate
|
||||
var cashHappenDate = interval?.SettlementDate ?? unwindData.ValueDate;
|
||||
int clientCashId = AddClientCashInCashOut(td, Convert.ToDouble(-unwindData.SwapCloseAmount), ClientCashInCashOut.系统操作_互换, cashHappenDate);
|
||||
string data = JsonConvert.SerializeObject(unwindData);
|
||||
var swapEvent = new SwapEventService(this).AddSwapEventDate(unwindData.ValueDate, unwindData.SwapTradeId, (int)SwapEventTypeEnum.自动互换, data, clientCashId, true, "系统操作-自动互换");//将互换总额存入事件
|
||||
flowEvents.ForEach(x =>
|
||||
@@ -777,7 +789,7 @@ 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.固定值)
|
||||
if (position.InterestMode == (int)InterestModeEnum.固定值||position.InterestMode == (int)InterestModeEnum.初始预付金 || position.InterestMode == (int)InterestModeEnum.追加预付金)
|
||||
{
|
||||
orginPv = eodPayPosition.InterestPrincipalFix;
|
||||
}
|
||||
@@ -872,7 +884,7 @@ namespace YLErp.Modules.SwapModule
|
||||
newEodPayPosition = eodPayPosition.Clone();
|
||||
newEodPayPosition.id = 0;
|
||||
}
|
||||
if (position.InterestMode == (int)InterestModeEnum.固定值)
|
||||
if (position.InterestMode == (int)InterestModeEnum.固定值 || position.InterestMode == (int)InterestModeEnum.初始预付金 || position.InterestMode == (int)InterestModeEnum.追加预付金)
|
||||
{
|
||||
orginPv = eodPayPosition.InterestPrincipalFix;
|
||||
}
|
||||
@@ -911,7 +923,6 @@ namespace YLErp.Modules.SwapModule
|
||||
newEodPayPosition.InterestType = position.InterestType;
|
||||
newEodPayPosition.FloatRate = interests.Count > 0 ? interests.First().FloatRate ?? 0 : 0;
|
||||
newEodPayPosition.FloatRateUnderlyingCode = position.FloatRateUnderlyingCode;
|
||||
newEodPayPosition.InterestFeePending = 0;
|
||||
newEodPayPosition.interest_rest_days = position.interest_rest_days;
|
||||
newEodPayPosition.interest_rule = position.interest_rule;
|
||||
//利息端估值用信息
|
||||
@@ -1013,7 +1024,7 @@ namespace YLErp.Modules.SwapModule
|
||||
newEodPayPosition.id = 0;
|
||||
newEodPayPosition.PositionId = position.id;
|
||||
}
|
||||
if (position.InterestMode == (int)InterestModeEnum.固定值)
|
||||
if (position.InterestMode == (int)InterestModeEnum.固定值 || position.InterestMode == (int)InterestModeEnum.初始预付金 || position.InterestMode == (int)InterestModeEnum.追加预付金)
|
||||
{
|
||||
orginPv = eodPayPosition.InterestPrincipalFix;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user