山证bug修复迁移

This commit is contained in:
吴方海
2024-06-21 13:45:43 +08:00
parent 7fece8679a
commit 1684bae60d
6 changed files with 55 additions and 23 deletions
@@ -1401,9 +1401,9 @@ namespace YLErp.BLL.Eod
var clientEodSwaps = data.GroupBy(g => g.SwapTradeId).ToList();
foreach (var item in clientEodSwaps)
{
var eodSwapList= item.OrderBy(o => o.ValueDate).ToList();
var eodSwap = eodSwapList[eodSwapList.Count-1];
var lastEodSwap= eodSwapList.Count<=1?null: eodSwapList[eodSwapList.Count - 2];
var eodSwapList = item.OrderBy(o => o.ValueDate).ToList();
var eodSwap = eodSwapList[eodSwapList.Count - 1];
var lastEodSwap = eodSwapList.Count <= 1 ? null : eodSwapList[eodSwapList.Count - 2];
//潜在行权收益等于实值额
balance.PotentialSurpluses += -Convert.ToDouble(eodSwap.PostionValue);
//持仓市值
@@ -1411,17 +1411,17 @@ namespace YLErp.BLL.Eod
balance.RoundedPositionPv += Math.Round(Convert.ToDouble(eodSwap.PostionValue), 2);
balance.SellPv += -Convert.ToDouble(eodSwap.MarketValueShort);
//持仓盈亏
var pnl = eodSwap.FloatingPnL + eodSwap.InterestPnL;
var lastPnl = lastEodSwap?.FloatingPnL??0 + lastEodSwap?.InterestPnL??0;
var pnl = eodSwap.PostionValue;
var lastPnl = lastEodSwap?.PostionValue;
//当日盈亏
if (eodSwap.ValueDate == startDate)
{
balance.DaliyPnl += Convert.ToDouble(pnl- lastPnl+ eodSwap.TdRealizedPnL);
balance.DaliyPnl += Convert.ToDouble(pnl - lastPnl + eodSwap.TdRealizedPnL);
balance.RoundedDaliyPnl += Math.Round(Convert.ToDouble(pnl - lastPnl), 2);
balance.UpdateDate = balance.UpdateDate > eodSwap.OptTime ? balance.UpdateDate : eodSwap.OptTime;
}
balance.WinLoss += Convert.ToDouble(eodSwap.TdRealizedPnL);
balance.PositionPnl += Convert.ToDouble(pnl);
balance.RoundedPositionPnl += Math.Round(Convert.ToDouble(pnl), 2);
//期权空头浮动盈利=∑max(期权空头持仓*(期权合约成本价-期权合约现价), 0) 从客户角度看的
@@ -157,7 +157,7 @@ namespace YLErp.Modules.CalculationModule
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;
var lastEod = db.eod_swap.Where(x => x.SwapTradeId == trade.id).OrderByDescending(o => o.ValueDate).FirstOrDefault();
var lastEod = db.eod_swap.Where(x => x.SwapTradeId == trade.id && x.ValueDate <= valuedateBLL.ValueDate).OrderByDescending(o => o.ValueDate).FirstOrDefault();
eodSwap.RealizedPnL = lastEod?.RealizedPnL ?? 0;
eodSwap.InterestPnL = lastEod?.InterestPnL ?? 0;
foreach (var item in positions)
@@ -186,7 +186,7 @@ namespace YLErp.Modules.CalculationModule
}
eodSwap.NotionalValue += pvNoPrice;
}
eodSwap.PostionValue = eodSwap.InterestPnL + eodSwap.FloatingPnL;
eodSwap.PostionValue = lastEod?.PostionValue ?? 0;
return eodSwap;
}
@@ -903,7 +903,7 @@ namespace YLErp.Modules.EodModule.SettlementModule
WinLoss += Convert.ToDouble(item.TdRealizedPnL) * (-1);
var lastPv = lastEodSwap != null ? Convert.ToDouble(lastEodSwap.PostionValue) * (-1) : 0;
eodPnlSum.LastPvSum = eodPnlSum.LastPvSum.HasValue ? eodPnlSum.LastPvSum + lastPv : lastPv;
var pnl = item.FloatingPnL + item.InterestPnL;
var pnl = item.PostionValue;
eodPnlSum.PvSum = eodPnlSum.PvSum.HasValue ? eodPnlSum.PvSum - Convert.ToDouble(item.PostionValue) : Convert.ToDouble(item.PostionValue) * (-1);
eodPnlSum.SellPvSum = eodPnlSum.SellPvSum.HasValue ? eodPnlSum.SellPvSum - Convert.ToDouble(item.MarketValueShort) : Convert.ToDouble(item.MarketValueShort) * (-1);
eodPnlSum.RoundedPvSum = eodPnlSum.RoundedPvSum.HasValue ? eodPnlSum.RoundedPvSum - Math.Round(Convert.ToDouble(item.PostionValue), 2) : Math.Round(Convert.ToDouble(item.PostionValue), 2) * (-1);
@@ -912,8 +912,8 @@ namespace YLErp.Modules.EodModule.SettlementModule
RoundedPositionPnl += Math.Round(Convert.ToDouble(pnl), 2) * (-1);
TotalPnl += Convert.ToDouble(item.RealizedPnL) * (-1);
ClientSellPositionPnl += Math.Max(-Convert.ToDouble(item.MarketValueShort), 0);
var lastPnl = lastEodSwap != null ? lastEodSwap.FloatingPnL + lastEodSwap.InterestPnL : 0;
DailyPnl += Convert.ToDouble(pnl - lastPnl+item.TdRealizedPnL) * (-1);
var lastPnl = lastEodSwap != null ? lastEodSwap.PostionValue : 0;
DailyPnl += Convert.ToDouble(pnl - lastPnl + item.TdRealizedPnL) * (-1);
//PayableMargin += Convert.ToDouble(item.InitMarginLoss + item.InitMarginGain+ item.PostionMarginLoss + item.PostionMarginGain);
}
var clientmarignQuery = marignQuery.Where(x => x.ClientId == client.id&&x.StructureType!="多空组合");
@@ -5056,7 +5056,7 @@ namespace YLErp.Modules.RiskModule
lastPrice = bondPrice != null ? bondPrice.ClosePrice : (um.Price ?? 0) * Convert.ToDouble(ConsGlobal.bondPriceMultiple);
}
}
currentValue += lastPrice * Math.Abs(item.Position) - Math.Abs(item.PositionCost);
currentValue += lastPrice * item.Position - item.PositionCost;
}
return currentValue;
}
@@ -17,6 +17,7 @@ function CombookingHub() {
// 创建SignalR连接并连接到服务器上的Hub
var bookconnection = new signalR.HubConnectionBuilder()
.withUrl('/swapflow/combookinghub')
.withAutomaticReconnect()
.build();
bookconnection.start()
.then(function () {
@@ -51,17 +52,26 @@ function CombookingHub() {
$('#msg').text(msg);
getList();
});
// 监听连接关闭,启动启动重连
bookconnection.Closed += async (error) => {
await Task.Delay(3 * 1000);
await bookconnection.StartAsync();
};
// 监听连接关闭,启动重连
bookconnection.onclose(async (error) => {
console.log("连接断开");
// 等待3秒后尝试重新连接
setTimeout(async () => {
try {
await bookconnection.start();
console.log("已重新连接");
} catch (err) {
console.error("重新连接失败: ", err);
}
}, 3000); // 3秒
});
}
// 流水重置交互
function ResetHub() {
// 创建SignalR连接并连接到服务器上的Hub
var connection = new signalR.HubConnectionBuilder()
.withUrl('/swapflow/resethub')
.withAutomaticReconnect()
.build();
connection.start()
.then(function () {
@@ -99,11 +109,19 @@ function ResetHub() {
layer.close(progressBar);
getList();
});
// 监听连接关闭,启动启动重连
connection.Closed += async (error) => {
await Task.Delay(3 * 1000);
await connection.StartAsync();
};
// 监听连接关闭,启动重连
connection.onclose(async (error) => {
console.log("连接断开");
// 等待3秒后尝试重新连接
setTimeout(async () => {
try {
await connection.start();
console.log("已重新连接");
} catch (err) {
console.error("重新连接失败: ", err);
}
}, 3000); // 3秒
});
}
//标的选择组件
const vueUnderlying = function () {
@@ -1128,6 +1128,7 @@ function SendEmailHub() {
// 创建SignalR连接并连接到服务器上的Hub
var connection = new signalR.HubConnectionBuilder()
.withUrl('/tradeconfirm/sendemailhub')
.withAutomaticReconnect()
.build();
connection.start()
.then(function () {
@@ -1167,4 +1168,17 @@ function SendEmailHub() {
main.waitMe(false);
SearchClick(true);
});
// 监听连接关闭,启动重连
connection.onclose(async (error) => {
console.log("连接断开");
// 等待3秒后尝试重新连接
setTimeout(async () => {
try {
await connection.start();
console.log("已重新连接");
} catch (err) {
console.error("重新连接失败: ", err);
}
}, 3000); // 3秒
});
}