山证bug修复及功能 迁移

This commit is contained in:
吴方海
2024-06-04 18:19:49 +08:00
parent df65cd0add
commit acbd2e7678
39 changed files with 709 additions and 406 deletions
@@ -525,6 +525,8 @@ namespace YLErp.Modules.CalculationModule
public double PFE { get; set; }
public double QuotePFE { get; set; }
public double RealPnl { get;set; }
}
@@ -116,6 +116,7 @@ namespace YLErp.Modules.CalculationModule
{
QuoteFloatingWinLoss =Convert.ToDouble(lastEodSwap.FloatingPnL),
FloatingWinLoss = Convert.ToDouble(lastEodSwap.FloatingPnL) * rate,
RealPnl = Convert.ToDouble(lastEodSwap.RealizedPnL) * rate,
QuoteCommission = clientCashOut?.Money??0,
Commission = (clientCashOut?.Money ?? 0) * rate,
QuoteAnnualFee = 0,
@@ -151,33 +152,35 @@ namespace YLErp.Modules.CalculationModule
/// <returns></returns>
private static eod_swap GetEodSwapData(OtcTradeBase trade, YLContext db)
{
var eodSwap=new eod_swap();
var positions = db.swap_position.Where(x=>x.PosiQuantity>0&&!x.IsInitial&&x.SwapTradeId== trade.id).ToList();
var eodSwap = new eod_swap();
var positions = db.swap_position.Where(x => x.PosiQuantity > 0 && !x.IsInitial && x.SwapTradeId == trade.id).ToList();
eodSwap.SwapTradeId = trade.id;
eodSwap.NotionalValueLong = positions.Where(x => x.PositionType == (int)PositionTypeFlag.Long).Sum(s => s.PosiNotionalValue);
eodSwap.NotionalValueShort = positions.Where(x => x.PositionType == (int)PositionTypeFlag.Short).Sum(s => s.PosiNotionalValue);
eodSwap.NotionalValue = eodSwap.NotionalValueLong + eodSwap.NotionalValueShort;
eodSwap.DV01 = 0;
var lastEod = db.eod_swap.Where(x => x.SwapTradeId == trade.id).OrderByDescending(o => o.ValueDate).FirstOrDefault();
eodSwap.RealizedPnL = lastEod?.RealizedPnL ?? 0;
eodSwap.InterestPnL = lastEod?.InterestPnL ?? 0;
foreach (var item in positions)
{
decimal shortRatio = item.PositionType == (int)PositionTypeFlag.Long ? 1 : -1;//多空方向
int directionRatio = item.PosiDirection == (int)SwapDirectionEnum. ? 1 : -1;
var pv= item.PosiQuantity * shortRatio * item.ContractSize;
var pvNoPrice = item.PosiQuantity * item.ContractSize;
var pv = item.PosiQuantity * shortRatio * item.ContractSize;
var pvNoPrice = item.PosiQuantity * item.ContractSize;
decimal vobp = 0;
var data = DataCacheProvider.GetUnderlyingDataSource().GetData(item.UnderlyingCode);
if (data != null)
{
if (data.IsBond())
{
var dealDate = QdpCalendarHelper.GetNonHolidayDefore(valuedateBLL.ValueDate.AddDays(-1));
var bondPrice = EodPriceQueryService.GetBondPrice(dealDate, data.UnderlyingCode);
var bondPrice = EodPriceQueryService.GetBondPrice(valuedateBLL.ValueDate, data.UnderlyingCode);
vobp = bondPrice.Vobp ?? 0;
var price = Convert.ToDecimal(bondPrice.ClosePrice);
eodSwap.FloatingPnL = (price - item.PosiNetPrice) * item.PosiQuantity * item.ContractSize * shortRatio * directionRatio;
eodSwap.FloatingPnL = (price - item.PosiGrossPrice) * item.PosiQuantity * item.ContractSize * shortRatio * directionRatio;
}
}
if (shortRatio>0)
if (shortRatio > 0)
{
eodSwap.MarketValueLong += pv;
}
@@ -185,10 +188,10 @@ namespace YLErp.Modules.CalculationModule
{
eodSwap.MarketValueShort += pv;
}
eodSwap.PostionValue += pv;
eodSwap.DV01+= pvNoPrice * vobp * shortRatio* directionRatio * 0.01m;
eodSwap.NotionalValue += pvNoPrice;
eodSwap.DV01 += pvNoPrice * vobp * shortRatio * directionRatio * 0.01m;
}
eodSwap.PostionValue = eodSwap.InterestPnL + eodSwap.FloatingPnL;
return eodSwap;
}