bug修复

This commit is contained in:
吴方海
2025-04-18 14:12:26 +08:00
parent 54b920b852
commit e4ef5d7d25
25 changed files with 134 additions and 145 deletions
@@ -819,7 +819,7 @@ namespace YLErp.Modules.SwapModule
/// <param name="td"></param>
/// <param name="unwindPrice"></param>
/// <param name="unwindPriceFee"></param>
public void AuotoSwapUnwind(int tradeid, decimal unwindPrice, decimal unwindPriceFee, decimal unwindNetFee, decimal unwindNet, DateTime valueDate, decimal unwindQty, decimal mergeQty, decimal penddingFee)
public void AuotoSwapUnwind(int tradeid, decimal unwindPrice, decimal unwindPriceFee, decimal unwindNetFee, decimal unwindNet, DateTime valueDate, decimal unwindQty)
{
unwindPriceFee = decimal.Parse(unwindPriceFee.ToString("F10"));
var td = DbContext.trade.Find(tradeid);
@@ -884,10 +884,10 @@ namespace YLErp.Modules.SwapModule
floatEvent.TradingAmountNetFeeAvg = unwindNetFee;
floatEvent.TradingAmountNetAvg = unwindNet;
floatEvent.TradingFeePending = position.PosiTradingFeePending * unwindData.ClosePercent;
var mergeClosePercent = mergeQty == 0 ? 0 : unwindQty / mergeQty;
floatEvent.TradingFee = penddingFee * mergeClosePercent;
floatEvent.TradingFeePending = Math.Round(floatEvent.TradingFeePending, 2, MidpointRounding.AwayFromZero);
floatEvent.TradingFee = floatEvent.TradingFeePending;
floatEvent.MarkClosePnl = (unwindPrice - position.PosiGrossPrice) * unwindQty * floatRatio * longRatio;
floatEvent.MarkClosePnl = Math.Round(floatEvent.MarkClosePnl + (floatEvent.TradingFee * floatRatio * -1), ConsGlobal.MoneyRound, MidpointRounding.AwayFromZero);
floatEvent.MarkClosePnl = Math.Round(floatEvent.MarkClosePnl + (floatEvent.TradingFeePending*2 * floatRatio * -1), ConsGlobal.MoneyRound, MidpointRounding.AwayFromZero);
floatEvent.TradingAmount = unwindPrice * floatEvent.Quantity * floatEvent.ContractSize;
floatEvent.OptLog = "流水自动";
floatEvent.ClientId = td.ClientId;
@@ -301,7 +301,7 @@ namespace YLErp.Modules.SwapModule
var unwindEvents = flowEvents.Where(x => x.PositionId == posi.id).ToList();//当前日平仓信息
var realPosition = realPosiList.FirstOrDefault(s => s.PositionId == posi.id);
eod_swap_position eodPosi = new eod_swap_position();
if (eodPosition == null || td.TradeDate == settleDate)
if (eodPosition == null)
{
eodPosi = SaveCurrentEodInitalPosi(posi, td, settleDate, preSettleDate, unwindEvents);
}
@@ -1259,19 +1259,18 @@ namespace YLErp.Modules.SwapModule
curretEod.PosiNetFeePrice = position.PosiNetFeePrice;
curretEod.PosiNetNoFeePrice = position.PosiNetNoFeePrice;
curretEod.PosiQuantity = position.PosiQuantity;
curretEod.PosiTradingFee = -position.PosiTradingFee * directionRatio;
curretEod.PosiFeePending = -position.PosiTradingFeePending * directionRatio;
}
else
{
var eventTradingFee = openFlowEvents.Sum(s => s.TradingFee);
curretEod.PosiTradingFee = eod.PosiTradingFee - eventTradingFee * directionRatio;
var eventTradingFee = openFlowEvents.Sum(s => s.TradingFeePending);
curretEod.PosiFeePending = eod.PosiFeePending - eventTradingFee * directionRatio;
if (openFlowEvents.Count() == 0)
{
curretEod.PosiNetPrice = eod.PosiNetPrice;
curretEod.PosiGrossPrice = eod.PosiGrossPrice;
curretEod.PosiNetFeePrice = eod.PosiNetFeePrice;
curretEod.PosiNetNoFeePrice = eod.PosiNetNoFeePrice;
curretEod.PosiFeePending = curretEod.PosiFeePending<0 ? 0: curretEod.PosiFeePending;
}
else //平仓数量一定<持仓数量
{
@@ -412,6 +412,7 @@ namespace YLErp.Modules.SwapModule
interestPosition.interest_rule = swapFloatRate.interest_rule;
interestPosition.interest_rest_days = swapFloatRate.interest_rest_days;
interestPosition.IsAnnualized = swapFloatRate.is_annualized ?? false;
interestPosition.InterestType = swapFloatRate.interest_type??0;
}
var interval = new IntervalModel()
{