BugFix 互换本次名义本金取错
This commit is contained in:
@@ -199,16 +199,41 @@ namespace YLErp.Modules.TradeModule
|
||||
ProcessCategory = ResolveProcessCategory(td),
|
||||
InitGroupId = UserBLL.GetApprovalProcessGroup(userId)
|
||||
};
|
||||
// 了结场景:当次平仓名义本金 = 期初名义本金 × 平仓比例(UnwindPercentRate),取绝对值
|
||||
// 了结场景:取本次平仓名义本金
|
||||
if (td != null && ctx.ProcessCategory == ProcessCategoryConst.Close)
|
||||
{
|
||||
var tc = DbContext.trade_cash
|
||||
.Where(t => t.TradeId == td.id && t.ValidState == ConsGlobal.InValid && !t.IsDeleted)
|
||||
.OrderByDescending(t => t.id)
|
||||
.FirstOrDefault();
|
||||
if (tc != null && tc.UnwindPercentRate.HasValue && td.OriginalStockEqvNotional.HasValue)
|
||||
if (td.TradeType == "收益互换")
|
||||
{
|
||||
ctx.CurrentNotional = Math.Abs(td.OriginalStockEqvNotional.Value * tc.UnwindPercentRate.Value);
|
||||
// 互换:从 swap_event.EventData(JSON) 反序列化取 CloseNotionalValue
|
||||
var swapEvent = DbContext.swap_event
|
||||
.Where(x => x.SwapTradeId == td.id && !x.Invalid
|
||||
&& (x.EventType == (int)SwapEventTypeEnum.平仓 || x.EventType == (int)SwapEventTypeEnum.互换))
|
||||
.OrderByDescending(x => x.id)
|
||||
.FirstOrDefault();
|
||||
if (swapEvent != null && !string.IsNullOrEmpty(swapEvent.EventData))
|
||||
{
|
||||
try
|
||||
{
|
||||
var unwindData = Newtonsoft.Json.JsonConvert.DeserializeObject<UnwindData>(swapEvent.EventData);
|
||||
if (unwindData != null)
|
||||
{
|
||||
ctx.CurrentNotional = Math.Abs((double)unwindData.CloseNotionalValue);
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 期权:当次平仓名义本金 = 期初名义本金 × 平仓比例(UnwindPercentRate),取绝对值
|
||||
var tc = DbContext.trade_cash
|
||||
.Where(t => t.TradeId == td.id && t.ValidState == ConsGlobal.InValid && !t.IsDeleted)
|
||||
.OrderByDescending(t => t.id)
|
||||
.FirstOrDefault();
|
||||
if (tc != null && tc.UnwindPercentRate.HasValue && td.OriginalStockEqvNotional.HasValue)
|
||||
{
|
||||
ctx.CurrentNotional = Math.Abs(td.OriginalStockEqvNotional.Value * tc.UnwindPercentRate.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return ctx;
|
||||
|
||||
Reference in New Issue
Block a user