fix: 计算浮动端平仓盈亏分红

This commit is contained in:
gongpei
2025-10-22 16:14:32 +08:00
parent 652334925d
commit 80a2b4057d
4 changed files with 32 additions and 4 deletions
@@ -322,6 +322,12 @@ namespace YLErp.DBModels
/// </summary>
public long? InnerCode { get; set; }
/// <summary>
/// 债券增值税
/// </summary>
[Column("value_added_tax")]
public decimal? ValueAddedTax { get; set; }
public override string ToString()
{
return $"{UnderlyingCode}--{UnderlyingName}--{id}--{UnderlyingInstrumentType}";
+14 -1
View File
@@ -881,8 +881,10 @@ namespace YLErp.Modules.SwapModule
floatEvent.TradingFeePending = Math.Round(floatEvent.TradingFeePending, ConsGlobal.MoneyRound, MidpointRounding.AwayFromZero);
floatEvent.TradingFee = closeFee;
BondPaymentService bondPaymentService = new BondPaymentService(UserInfo);
var tax = GetUnderlyingTax(floatEvent.UnderlyingCode);
var payments = bondPaymentService.GetBondPayments(floatEvent.UnderlyingCode, td.StartDate.Value, floatEvent.UnwindDate.Value);
floatEvent.DividendIn = bondPaymentService.CalcPayment(payments, unwindQty, longRatio, floatRatio);
var payment = bondPaymentService.CalcPayment(payments, unwindQty, longRatio, floatRatio);
floatEvent.DividendIn = payment / (1 + tax) * (1 - tax);
floatEvent.DividendIn = Math.Round(floatEvent.DividendIn, 2, MidpointRounding.AwayFromZero);
floatEvent.DividendPending = bondPaymentService.CalcPayment(payments, floatEvent.PositionQty ?? 0, longRatio, floatRatio);
@@ -910,6 +912,17 @@ namespace YLErp.Modules.SwapModule
CalcCloseAmount(unwindData);
DealUnwind(unwindData, td);
}
public decimal GetUnderlyingTax(string code)
{
var data = DataCacheProvider.GetUnderlyingDataSource().GetData(code);
if (data == null)
{
return 0;
}
return data.ValueAddedTax ?? 0;
}
/// <summary>
/// 衡泰新增平仓事件
/// </summary>
@@ -1142,10 +1142,13 @@ namespace YLErp.Modules.SwapModule
int directionRatio = eod.PosiDirection == (int)SwapDirectionEnum. ? 1 : -1;
curretEod.PosiStatus = curretEod.PosiQuantity == 0 ? 1 : 0;
var price = UnderlyingCodePrice(eod.UnderlyingCode, dealDate, out decimal vobp);
decimal tax = um.ValueAddedTax ?? 0;
BondPaymentService bondPaymentService = new BondPaymentService(UserInfo);
if (valueDate > td.StartDate.Value && (curretEod.PosiQuantity > 0 || valueDate == td.UnWindDate))
{
curretEod.TdPosiDividend = bondPaymentService.CalcPayment(curretEod.UnderlyingCode, eod.ValueDate, valueDate, curretEod.PosiQuantity, shortRatio, directionRatio);
decimal payment = bondPaymentService.CalcPayment(curretEod.UnderlyingCode, eod.ValueDate, valueDate, curretEod.PosiQuantity, shortRatio, directionRatio);
// 考虑增值税
curretEod.TdPosiDividend = payment / (1 - tax) * (1 + tax);
}
curretEod.PosiDividendSum = eod.PosiDividendSum + curretEod.TdPosiDividend;
curretEod.PosiQuantity = eod.PosiQuantity;
@@ -1162,6 +1165,7 @@ namespace YLErp.Modules.SwapModule
curretEod.TdCloseFee = 0;
curretEod.TdCloseQty = 0;
curretEod.TdCloseMtmPnl = 0;
// 需要计算平仓盈亏分红
curretEod.TdCloseDividend = 0;
curretEod.RealizedMtmPnL = eod.RealizedMtmPnL + curretEod.TdCloseMtmPnl;
curretEod.RealizedDividend = eod.RealizedDividend + curretEod.TdCloseDividend;
@@ -1204,6 +1208,7 @@ namespace YLErp.Modules.SwapModule
if (curretEod == null)
{
curretEod = eod.Clone();
curretEod.TdPosiDividend = 0;
curretEod.id = 0;
curretEod.ValueDate = valueDate;
}
@@ -1224,10 +1229,14 @@ namespace YLErp.Modules.SwapModule
curretEod.PosiDividendSum = eod.PosiDividendSum + curretEod.TdPosiDividend;
curretEod.PosiProfitSum = curretEod.PosiMtmPnL + curretEod.PosiDividendSum + curretEod.PosiFeePending;
curretEod.RealizedMtmPnL = eod.RealizedMtmPnL + curretEod.TdCloseMtmPnl;
curretEod.RealizedDividend = eod.RealizedDividend + curretEod.TdCloseDividend;
//curretEod.RealizedDividend = eod.RealizedDividend + curretEod.TdCloseDividend;
curretEod.RealizedFee = eod.RealizedFee + curretEod.TdCloseFee;
curretEod.RealizedPnl = eod.RealizedPnl + curretEod.TdCloseMtmPnl;
curretEod.PosiStatus = curretEod.PosiQuantity == 0 ? 1 : 0;
var closeQty = unwindEvents.Where(x => x.EventType == (int)SwapFlowEventTypeEnum.).ToList().Sum(s => s.Quantity);
// 等于 平仓数量/昨天剩余平仓数量 * 昨日浮动端分红
curretEod.TdCloseDividend = closeQty / eod.PosiQuantity * eod.TdPosiDividend;
curretEod.RealizedDividend = curretEod.RealizedDividend + curretEod.TdCloseDividend;
if (curretEod.PosiStatus == 1)
{
curretEod.PosiNotionalValue = 0;
@@ -34,7 +34,7 @@
var colModelGrid = [{
name: '', label: '操作', index: '', width: 120, formatter: showToolName
}, {
name: 'payment_date', label: '支付日期', index: 'ValueDate', width: 120, formatter: 'date'
name: 'payment_date', label: '支付日期', index: 'payment_date', width: 120, formatter: 'date'
}, {
name: 'MarketName', label: '市场', index: 'MarketName', width: 200
}, {