#TRS-ZS-584 保证金中台获取数据的视图提供调整为日终收盘后入库
This commit is contained in:
@@ -0,0 +1,187 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace YLErp.DBModels
|
||||
{
|
||||
/// <summary>
|
||||
/// 资金监控视图
|
||||
/// </summary>
|
||||
[Table("client_balance_view")]
|
||||
public class ClientBalanceView : DBModelBase
|
||||
{
|
||||
/*客户编号 客户名称 交易总数 名义本金总额 当日交易数 当日交易名义本金
|
||||
持仓名义本金 持仓笔数 实现盈亏 持仓盈亏 期初结存 出金入金 初保账户 追保账户 其他收支
|
||||
期末结存 初始保证金金额 维持保证金金额 盯市金额 履约保证金比例 可用资金 追保金额 可取资金*/
|
||||
/// <summary>
|
||||
/// 估值时间
|
||||
/// </summary>
|
||||
[Column("valuedate")]
|
||||
public DateTime ValueDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 客户编号
|
||||
/// </summary>
|
||||
[Column("number")]
|
||||
public string Number { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 客户名称
|
||||
/// </summary>
|
||||
[Column("name")]
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 交易总数
|
||||
/// </summary>
|
||||
[Column("total_trade_count")]
|
||||
public int TotalTradeCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 名义本金总额
|
||||
/// </summary>
|
||||
[Column("total_notional_principal")]
|
||||
public double TotalNotionalPrincipal { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 当日交易数
|
||||
/// </summary>
|
||||
[Column("transaction_pen_number")]
|
||||
public int TransactionPenNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 当日交易名义本金
|
||||
/// </summary>
|
||||
[Column("today_notional_principal")]
|
||||
public double TodayNotionalPrincipal { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 持仓名义本金
|
||||
/// </summary>
|
||||
[Column("position_notional_principal")]
|
||||
public double PositionNotionalPrincipal { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 持仓笔数
|
||||
/// </summary>
|
||||
[Column("current_holding_pennumber")]
|
||||
public int CurrentHoldingPenNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 实现盈亏
|
||||
/// </summary>
|
||||
[Column("win_loss")]
|
||||
public double WinLoss { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 持仓盈亏
|
||||
/// </summary>
|
||||
[Column("position_pnl")]
|
||||
public double PositionPnl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 持仓盈亏(四舍五入)
|
||||
/// </summary>
|
||||
[Column("rounded_position_pnl")]
|
||||
public double RoundedPositionPnl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 期初结存
|
||||
/// </summary>
|
||||
[Column("last_day_remain_fund")]
|
||||
public double LastDayRemainFund { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 出金入金
|
||||
/// </summary>
|
||||
[Column("net_fund_all")]
|
||||
public double NetFundAll { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 初保账户
|
||||
/// </summary>
|
||||
[Column("net_fund")]
|
||||
public double NetFund { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 追保账户
|
||||
/// </summary>
|
||||
[Column("vm_fund_sum")]
|
||||
public double VmFundSum { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 其他收支
|
||||
/// </summary>
|
||||
[Column("other_fund")]
|
||||
public double OtherFund { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 期末结存
|
||||
/// </summary>
|
||||
[Column("amount_fund")]
|
||||
public double AmountFund { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 初始保证金金额
|
||||
/// </summary>
|
||||
[Column("my_side_margin")]
|
||||
public double MySideMargin { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 维持保证金金额
|
||||
/// </summary>
|
||||
[Column("maintenance_margin")]
|
||||
public double MaintenanceMargin { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 盯市金额
|
||||
/// </summary>
|
||||
[Column("swap_market_amount")]
|
||||
public double SwapMarketAmount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 履约保证金比例
|
||||
/// </summary>
|
||||
[Column("swap_market_amount_percent")]
|
||||
public decimal SwapMarketAmountPercent { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 可用资金
|
||||
/// </summary>
|
||||
[Column("available_amount")]
|
||||
public double AvailableAmount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 追保金额
|
||||
/// </summary>
|
||||
[Column("insured_amount")]
|
||||
public double InsuredAmount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 可取资金
|
||||
/// </summary>
|
||||
[Column("desirable_fund")]
|
||||
public double DesirableFund { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 交易手续费
|
||||
/// </summary>
|
||||
[Column("trade_fee")]
|
||||
public double TradeFee { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 利息盈亏
|
||||
/// </summary>
|
||||
[Column("interest_pnl")]
|
||||
public double InterestPnl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 更新日期
|
||||
/// </summary>
|
||||
[Column("updatetime")]
|
||||
public DateTime Updatetime { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
using BaseOUDAL;
|
||||
using DocumentFormat.OpenXml.Bibliography;
|
||||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
using NPOI.SS.UserModel;
|
||||
using YLErp.BLL.Eod;
|
||||
using YLErp.DBModels;
|
||||
@@ -109,9 +111,9 @@ namespace YLErp.BLL.EodSettlement
|
||||
clientIdS.AddRange(clientIdList);
|
||||
using (var db = new YLContext())
|
||||
{
|
||||
//系统交易日
|
||||
var valuedate = valuedateBLL.ValueDate;
|
||||
var lastpushLog = db.push_log.Where(x => x.data_type == (int)SwapPushDataEnum.日终估值获取 && x.data_state == (int)SwapPushDataStateEnum.接收处理成功&&x.create_time> valuedate).OrderByDescending(o => o.create_time).FirstOrDefault();
|
||||
//系统交易日
|
||||
var valuedate = valuedateBLL.ValueDate;
|
||||
var lastpushLog = db.push_log.Where(x => x.data_type == (int)SwapPushDataEnum.日终估值获取 && x.data_state == (int)SwapPushDataStateEnum.接收处理成功 && x.create_time > valuedate).OrderByDescending(o => o.create_time).FirstOrDefault();
|
||||
//获取根据系统时间
|
||||
var lastBalanceDate = EodOperationBase.GetLastSettlementDate(valuedate);
|
||||
// 获取定义文件预付金率设置
|
||||
@@ -149,9 +151,9 @@ namespace YLErp.BLL.EodSettlement
|
||||
FundJson = t.FundJson,
|
||||
PFE = t.PFE,
|
||||
EAD = t.EAD,
|
||||
LastSettlemetTime=t.OptDate,
|
||||
TradeFee=t.trade_fee_sum??0,
|
||||
InterestPnl=t.interest_pnl_sum??0
|
||||
LastSettlemetTime = t.OptDate,
|
||||
TradeFee = t.trade_fee_sum ?? 0,
|
||||
InterestPnl = t.interest_pnl_sum ?? 0
|
||||
};
|
||||
|
||||
var sumDatas = sumQuery.ToArray();
|
||||
@@ -176,15 +178,15 @@ namespace YLErp.BLL.EodSettlement
|
||||
balance.Coupon = data.Coupon;
|
||||
balance.CashInCashOutProductChange = data.CashInCashOutProductChange;
|
||||
balance.WinLoss = data.WinLoss;
|
||||
balance.TradeFee=data.TradeFee;
|
||||
balance.TradeFee = data.TradeFee;
|
||||
balance.InterestPnl = data.InterestPnl;
|
||||
//起始时间 有值 和 WinLoss 区分 -- 国投不含当天
|
||||
balance.WinLossSum = data.WinLoss;
|
||||
balance.FundJson = data.FundJson;
|
||||
balance.PFE = data.PFE;
|
||||
balance.EAD = data.EAD;
|
||||
balance.LastSettlemetTime = endDate <= lastDate? data.LastSettlemetTime:null;
|
||||
balance.LastHTSettlemetTime = lastpushLog==null?"未同步": lastpushLog.update_time.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
balance.LastSettlemetTime = endDate <= lastDate ? data.LastSettlemetTime : null;
|
||||
balance.LastHTSettlemetTime = lastpushLog == null ? "未同步" : lastpushLog.update_time.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -286,7 +288,7 @@ namespace YLErp.BLL.EodSettlement
|
||||
TdWinLoss = t.WinLoss,
|
||||
MarginJson = cs.PVJsons,
|
||||
MaintenanceLine = t.MaintenanceLine,
|
||||
TotalNominal=t.TotalNominal,
|
||||
TotalNominal = t.TotalNominal,
|
||||
InFundSum = t.InFundSum,
|
||||
OutFundSum = t.OutFundSum,
|
||||
VmInFundSum = t.vm_in_fund_sum,
|
||||
@@ -308,7 +310,7 @@ namespace YLErp.BLL.EodSettlement
|
||||
balance.FreezePremium = data.FreezePremium;
|
||||
balance.ReceivablesPremium = data.ReceivablesPremium;
|
||||
balance.AmountFund = data.AmountFund;
|
||||
|
||||
|
||||
|
||||
balance.TotalCredit = data.TotalCredit;
|
||||
balance.PayableMargin = data.PayableMargin;
|
||||
@@ -324,7 +326,7 @@ namespace YLErp.BLL.EodSettlement
|
||||
balance.TwoSideMargin = data.TwoSideMargin;
|
||||
balance.OtherSideMargin = data.OtherSideMargin;
|
||||
balance.MySideMargin = data.MySideMargin;
|
||||
balance.MaintenanceMargin=data.MaintenanceMargin;
|
||||
balance.MaintenanceMargin = data.MaintenanceMargin;
|
||||
balance.IsPayableMarginManual = data.IsPayableMarginManual;
|
||||
balance.IsPayableMarginLock = data.IsPayableMarginLock;
|
||||
balance.FrozenMarginMoney = data.FrozenMarginMoney;
|
||||
@@ -352,8 +354,8 @@ namespace YLErp.BLL.EodSettlement
|
||||
balance.ClientType = client.SwapTradeType ?? 0;
|
||||
balance.ClientName = client.Name;
|
||||
balance.MaintenanceLine = data.MaintenanceLine ?? 0;
|
||||
balance.PositionNotionalPrincipal = data.TotalNominal??0;
|
||||
|
||||
balance.PositionNotionalPrincipal = data.TotalNominal ?? 0;
|
||||
|
||||
balance.OutFundSum = data.OutFundSum ?? 0;
|
||||
balance.InFundSum = data.InFundSum ?? 0;
|
||||
balance.VmInFundSum = data.VmInFundSum ?? 0;
|
||||
@@ -365,9 +367,9 @@ namespace YLErp.BLL.EodSettlement
|
||||
// 是否追保=盯市金额小于维持保证金额
|
||||
balance.NeedAddMargin = balance.SwapMarketAmount < balance.MaintenanceMargin;
|
||||
// 追保金额=初始保证金金额-盯市金额
|
||||
balance.MarginByPayableMarginTotal = balance.NeedAddMargin ? (balance.MySideMargin - balance.SwapMarketAmount):0;
|
||||
balance.MarginByPayableMarginTotal = balance.NeedAddMargin ? (balance.MySideMargin - balance.SwapMarketAmount) : 0;
|
||||
// 可取资金=Math.Max(期末结存-min(持仓盈亏,0)-初始保证金,0)
|
||||
balance.DesirableFund = Math.Max(balance.MarginBalance + Math.Min(balance.RoundedPositionPnl, 0),0);
|
||||
balance.DesirableFund = Math.Max(balance.MarginBalance + Math.Min(balance.RoundedPositionPnl, 0), 0);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1392,7 +1394,7 @@ namespace YLErp.BLL.EodSettlement
|
||||
}
|
||||
|
||||
var clientTradePosiQuery = tradePosiQuery.Where(x => x.ClientId == balance.ClientId && x.p.PosiQuantity > 0 && x.p.ValueDate == searchDate);
|
||||
balance.PositionCount = clientTradePosiQuery.Select(s=>s.id).Distinct().Count();
|
||||
balance.PositionCount = clientTradePosiQuery.Select(s => s.id).Distinct().Count();
|
||||
var PosiNotionalValue = clientTradePosiQuery.Sum(o => o.p.PosiNotionalValue);
|
||||
balance.PositionNotionalPrincipal = Convert.ToDouble(PosiNotionalValue);
|
||||
}
|
||||
@@ -1403,12 +1405,12 @@ namespace YLErp.BLL.EodSettlement
|
||||
public static void FillClientBalanceHisTradeFee()
|
||||
{
|
||||
List<int> marginTypes = new List<int>() { (int)InterestModeEnum.追加预付金, (int)InterestModeEnum.初始预付金 };
|
||||
var clients= DataCacheProvider.GetClientDataSource().AsQueryable().Where(x=>x.ProcessStatus=="已开户").ToList();
|
||||
var clients = DataCacheProvider.GetClientDataSource().AsQueryable().Where(x => x.ProcessStatus == "已开户").ToList();
|
||||
using var db = new YLContext();
|
||||
var firstEodStatusDate = db.eodStatus.OrderBy(o=>o.ValueDate).FirstOrDefault();
|
||||
if (firstEodStatusDate!=null)
|
||||
var firstEodStatusDate = db.eodStatus.OrderBy(o => o.ValueDate).FirstOrDefault();
|
||||
if (firstEodStatusDate != null)
|
||||
{
|
||||
var firstDate=firstEodStatusDate.ValueDate;
|
||||
var firstDate = firstEodStatusDate.ValueDate;
|
||||
var preBalanceDate = valuedateBLL.GetNonHolidayDefore(valuedateBLL.ValueDate.AddDays(-1));
|
||||
while (firstDate < valuedateBLL.ValueDate)
|
||||
{
|
||||
@@ -1416,18 +1418,18 @@ namespace YLErp.BLL.EodSettlement
|
||||
{
|
||||
var interestPnl = 0d;
|
||||
var tradeFee = 0d;
|
||||
var clientBalance=db.ClientBalanceDaily.FirstOrDefault(x => x.ClientId == client.id && x.BalanceDate == firstDate);
|
||||
var clientBalance = db.ClientBalanceDaily.FirstOrDefault(x => x.ClientId == client.id && x.BalanceDate == firstDate);
|
||||
var clientBalancePre = db.ClientBalanceDaily.FirstOrDefault(x => x.ClientId == client.id && x.BalanceDate == preBalanceDate);
|
||||
if (clientBalance != null)
|
||||
{
|
||||
// 互换平仓信息
|
||||
var clientEventFlowQuery = from eod in db.swap_flow_event.Where(x => x.EventDate <= firstDate && x.EventDate > preBalanceDate &&x.ClientId== client.id &&x.DataState==(int)SwapFlowDateStateEnum.完成&&x.EventType==(int)SwapFlowEventTypeEnum.平仓)
|
||||
join t in db.trade.Where(x => x.TradeType == "收益互换" && x.ValidState != ConsGlobal.InValid ) on eod.SwapTradeId equals t.id
|
||||
select eod;
|
||||
var clientEventFlowQuery = from eod in db.swap_flow_event.Where(x => x.EventDate <= firstDate && x.EventDate > preBalanceDate && x.ClientId == client.id && x.DataState == (int)SwapFlowDateStateEnum.完成 && x.EventType == (int)SwapFlowEventTypeEnum.平仓)
|
||||
join t in db.trade.Where(x => x.TradeType == "收益互换" && x.ValidState != ConsGlobal.InValid) on eod.SwapTradeId equals t.id
|
||||
select eod;
|
||||
var clientEodSwaps = clientEventFlowQuery.ToList();
|
||||
foreach (var item in clientEodSwaps.GroupBy(x => x.SwapTradeId))
|
||||
{
|
||||
|
||||
|
||||
var eventPosi = item.FirstOrDefault(t => t.PayDirection > 0);
|
||||
|
||||
var eventInterests = item.Where(t => t.PayDirection == 0).ToList();
|
||||
@@ -1441,14 +1443,14 @@ namespace YLErp.BLL.EodSettlement
|
||||
}
|
||||
interestPnl += Convert.ToDouble(interest.InterestClosePnL) * (-1);
|
||||
}
|
||||
|
||||
tradeFee += Convert.ToDouble(eventPosi.TradingFee+ eventPosi.TradingFeePending) * (-1);
|
||||
|
||||
tradeFee += Convert.ToDouble(eventPosi.TradingFee + eventPosi.TradingFeePending) * (-1);
|
||||
}
|
||||
clientBalance.trade_fee = tradeFee;
|
||||
clientBalance.interest_pnl = interestPnl;
|
||||
clientBalance.trade_fee_sum = clientBalance.trade_fee;
|
||||
clientBalance.interest_pnl_sum = clientBalance.interest_pnl;
|
||||
if (clientBalancePre!=null)
|
||||
if (clientBalancePre != null)
|
||||
{
|
||||
clientBalance.trade_fee_sum += clientBalancePre.trade_fee_sum;
|
||||
clientBalance.interest_pnl_sum += clientBalancePre.interest_pnl_sum;
|
||||
@@ -1456,7 +1458,7 @@ namespace YLErp.BLL.EodSettlement
|
||||
db.SaveChanges();
|
||||
}
|
||||
}
|
||||
preBalanceDate= firstDate;
|
||||
preBalanceDate = firstDate;
|
||||
firstDate = valuedateBLL.GetNonHoliday(firstDate.AddDays(1));
|
||||
}
|
||||
}
|
||||
@@ -1467,9 +1469,9 @@ namespace YLErp.BLL.EodSettlement
|
||||
/// <param name="clientId"></param>
|
||||
/// <param name="clientMarginTemplates"></param>
|
||||
/// <returns></returns>
|
||||
private static client_marginrate GetClientMarginRate(int clientId, List<client_marginrate> clientMarginTemplates)
|
||||
private static client_marginrate GetClientMarginRate(int clientId, List<client_marginrate> clientMarginTemplates)
|
||||
{
|
||||
var marinRate = clientMarginTemplates.Where(x => x.ClientId == clientId ).FirstOrDefault();
|
||||
var marinRate = clientMarginTemplates.Where(x => x.ClientId == clientId).FirstOrDefault();
|
||||
if (marinRate == null)
|
||||
{
|
||||
marinRate = clientMarginTemplates.Where(x => x.ClientId == 0).FirstOrDefault();
|
||||
@@ -1548,5 +1550,96 @@ namespace YLErp.BLL.EodSettlement
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static List<ClientBalanceView> queryClientRiskMonitor(ClientRiskMonitorReq req)
|
||||
{
|
||||
if (!req.SearchDate.HasValue)
|
||||
{
|
||||
req.SearchDate = valuedateBLL.ValueDate;
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(req.marginShownType))
|
||||
{
|
||||
req.marginShownType = "default";
|
||||
}
|
||||
if (req.ClientIds == null || req.ClientIds.Count <= 0)
|
||||
{
|
||||
var clientService = new ClientQueryService(OptUserInfo.SystemUser);
|
||||
var predicate = clientService.CreatePredicate(new ClientReq() { ValueDate = req.SearchDate });
|
||||
req.ClientIds = clientService.GetClientListByWhere(predicate).Select(o => o.id).Distinct().ToList();
|
||||
}
|
||||
var result = ClientBalanceUtility.GetClientRiskMonitorForShanXiGuShou(req.ClientIds, req.SearchDate.Value, req.marginShownType);
|
||||
if (result == null)
|
||||
{
|
||||
return new List<ClientBalanceView>();
|
||||
}
|
||||
//精简字段
|
||||
var resultList = result.Select(item => new ClientBalanceView
|
||||
{
|
||||
ValueDate = req.SearchDate.Value,
|
||||
Number = item.ClientNumber ?? "",
|
||||
Name = item.ClientName ?? "",
|
||||
TotalTradeCount = item.TotalTradeCount,
|
||||
TotalNotionalPrincipal = item.TotalNotionalPrincipal,
|
||||
TransactionPenNumber = item.TradeCount,
|
||||
TodayNotionalPrincipal = item.TodayNotionalPrincipal,
|
||||
PositionNotionalPrincipal = item.PositionNotionalPrincipal,
|
||||
CurrentHoldingPenNumber = item.PositionCount,
|
||||
WinLoss = item.WinLoss,
|
||||
PositionPnl = item.PositionPnl,
|
||||
RoundedPositionPnl = item.RoundedPositionPnl,
|
||||
LastDayRemainFund = item.LastDayRemainFund,
|
||||
NetFundAll = item.NetFundAll,
|
||||
NetFund = item.NetFund,
|
||||
VmFundSum = item.VmFundSum,
|
||||
OtherFund = item.OtherFund,
|
||||
AmountFund = item.AmountFund,
|
||||
MySideMargin = item.MySideMargin,
|
||||
MaintenanceMargin = item.MaintenanceMargin,
|
||||
SwapMarketAmount = item.SwapMarketAmount,
|
||||
SwapMarketAmountPercent = item.SwapMarketAmountPercent,
|
||||
AvailableAmount = item.AvailableAmount,
|
||||
InsuredAmount = item.MarginByPayableMarginTotal,
|
||||
DesirableFund = item.DesirableFund,
|
||||
TradeFee = item.TradeFee,
|
||||
InterestPnl = item.InterestPnl,
|
||||
Updatetime = DateTime.Now
|
||||
}).ToList();
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存客户资金监控结果, 用于浙商数据采集
|
||||
/// </summary>
|
||||
/// <param name="valueDate"></param>
|
||||
public static void saveClientRiskMonitor(DateTime valueDate)
|
||||
{
|
||||
LogFactory.GetLogger("saveClientRiskMonitor").Info($"开始执行 {valueDate:yyyy-MM-dd} 数据落库操作");
|
||||
var req = new ClientRiskMonitorReq
|
||||
{
|
||||
SearchDate = valueDate
|
||||
};
|
||||
var list = queryClientRiskMonitor(req);
|
||||
if (list.Count == 0)
|
||||
{
|
||||
LogFactory.GetLogger("saveClientRiskMonitor").Info($"{valueDate:yyyy-MM-dd} 记录数为0,跳过落库");
|
||||
}
|
||||
using (var db = new YLContext())
|
||||
{
|
||||
db.BulkDelete<ClientBalanceView>($"ValueDate='{valueDate:yyyy-MM-dd}'");
|
||||
db.clientBalanceView.AddRange(list);
|
||||
db.SaveChanges();
|
||||
}
|
||||
LogFactory.GetLogger("saveClientRiskMonitor").Info($"{valueDate:yyyy-MM-dd} 记录数为{list.Count},落库完成");
|
||||
}
|
||||
|
||||
public class ClientRiskMonitorReq
|
||||
{
|
||||
public List<int> ClientIds { get; set; }
|
||||
|
||||
public DateTime? SearchDate { get; set; }
|
||||
|
||||
public string marginShownType { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -400,5 +400,7 @@ namespace YLErp.BLL
|
||||
public DbSet<TrsOpenConfig> trs_open_config { get; set; }
|
||||
public DbSet<TrsAcountManage> trs_account_manage { get; set; }
|
||||
public DbSet<TrsAccountManageDetail> trs_account_manage_detail { get; set; }
|
||||
|
||||
public DbSet<ClientBalanceView> clientBalanceView { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Text;
|
||||
using YLErp.BLL.EodSettlement;
|
||||
using YLErp.Configuration;
|
||||
using YLErp.Modules.EodFileModule;
|
||||
using YLErp.Modules.EodModule.CompanySpecial;
|
||||
@@ -423,6 +424,7 @@ where {nameof(t.TaskStartTime)}>'{startDateStr}' and {nameof(t.TaskState)}={(int
|
||||
}
|
||||
}
|
||||
}
|
||||
ClientBalanceUtility.saveClientRiskMonitor(eodTask.ValueDate);
|
||||
new EodFileService(this.OptUser).GenerateFileAfterEod(eodTask.ValueDate);
|
||||
//执行下一日
|
||||
eodTask.ValueDate = eodTask.ValueDate.AddDays(1);
|
||||
|
||||
@@ -1,129 +1,24 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Data;
|
||||
using YLErp.BLL.EodSettlement;
|
||||
using YLErp.Modules.ClientModule;
|
||||
using YLErp.Modules.VolatilityModule;
|
||||
using static YLErp.BLL.EodSettlement.ClientBalanceUtility;
|
||||
|
||||
namespace YLErp.Web.WebAPI.Controllers
|
||||
{
|
||||
public class ClientBalanceController
|
||||
{
|
||||
|
||||
///
|
||||
/// </summary>
|
||||
[HttpPost("m/api/ClientBalance/GetClientRsikMonitor")]
|
||||
public JsonResult GetClientRsikMonitor([FromBody]MonitorReq req)
|
||||
[HttpPost("m/api/ClientBalance/GetClientRiskMonitor")]
|
||||
public JsonResult GetClientRsikMonitor([FromBody] ClientRiskMonitorReq req)
|
||||
{
|
||||
LogFactory.GetLogger("GetClientRsikMonitor请求").Info(JsonHelper.Serialize(req));
|
||||
if (!req.SearchDate.HasValue)
|
||||
{
|
||||
req.SearchDate = valuedateBLL.ValueDate;
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(req.marginShownType))
|
||||
{
|
||||
req.marginShownType = "default";
|
||||
}
|
||||
if (req.ClientIds == null || req.ClientIds.Count <= 0)
|
||||
{
|
||||
req.ClientIds = DataCacheProvider.GetClientDataSource().AsQueryable().Select(o => o.id).Distinct().ToList();
|
||||
}
|
||||
var result = ClientBalanceUtility.GetClientRiskMonitorForShanXiGuShou(req.ClientIds, req.SearchDate.Value, req.marginShownType);
|
||||
//精简字段
|
||||
var resultList = result.Select(item => new resultParam
|
||||
{
|
||||
Number = item.ClientNumber,
|
||||
Name = item.ClientName,
|
||||
TotalTradeCount = item.TotalTradeCount,
|
||||
TotalNotionalPrincipal = item.TotalNotionalPrincipal,
|
||||
TransactionPenNumber = item.TradeCount,
|
||||
TodayNotionalPrincipal = item.TodayNotionalPrincipal,
|
||||
PositionNotionalPrincipal = item.PositionNotionalPrincipal,
|
||||
CurrentHoldingPenNumber = item.PositionCount,
|
||||
WinLoss = item.WinLoss,
|
||||
PositionPnl = item.PositionPnl,
|
||||
RoundedPositionPnl = item.RoundedPositionPnl,
|
||||
LastDayRemainFund = item.LastDayRemainFund,
|
||||
NetFundAll = item.NetFundAll,
|
||||
NetFund = item.NetFund,
|
||||
VmFundSum = item.VmFundSum,
|
||||
OtherFund = item.OtherFund,
|
||||
AmountFund = item.AmountFund,
|
||||
MySideMargin = item.MySideMargin,
|
||||
MaintenanceMargin = item.MaintenanceMargin,
|
||||
SwapMarketAmount = item.SwapMarketAmount,
|
||||
SwapMarketAmountPercent = item.SwapMarketAmountPercent,
|
||||
AvailableAmount = item.AvailableAmount,
|
||||
InsuredAmount = item.MarginByPayableMarginTotal,
|
||||
DesirableFund = item.DesirableFund
|
||||
}).ToList();
|
||||
var resultList = queryClientRiskMonitor(req);
|
||||
LogFactory.GetLogger().Info($"GetClientRsikMonitor: {JsonHelper.Serialize(resultList)}");
|
||||
return new JsonResult(resultList);
|
||||
}
|
||||
|
||||
public class MonitorReq
|
||||
{
|
||||
public List<int> ClientIds { get; set; }
|
||||
|
||||
public DateTime? SearchDate { get; set; }
|
||||
|
||||
public string marginShownType { get; set; }
|
||||
}
|
||||
|
||||
public class resultParam
|
||||
{
|
||||
/*客户编号 客户名称 交易总数 名义本金总额 当日交易数 当日交易名义本金
|
||||
持仓名义本金 持仓笔数 实现盈亏 持仓盈亏 期初结存 出金入金 初保账户 追保账户 其他收支
|
||||
期末结存 初始保证金金额 维持保证金金额 盯市金额 履约保证金比例 可用资金 追保金额 可取资金*/
|
||||
|
||||
public string Number { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
public int TotalTradeCount { get; set; }
|
||||
|
||||
public double TotalNotionalPrincipal { get; set; }
|
||||
|
||||
public int TransactionPenNumber { get; set; }
|
||||
|
||||
public double TodayNotionalPrincipal { get; set; }
|
||||
|
||||
public double PositionNotionalPrincipal { get; set; }
|
||||
|
||||
public int CurrentHoldingPenNumber { get; set; }
|
||||
|
||||
public double WinLoss { get; set; }
|
||||
|
||||
public double PositionPnl { get; set; }
|
||||
|
||||
public double RoundedPositionPnl { get; set; }
|
||||
|
||||
public double LastDayRemainFund { get; set; }
|
||||
|
||||
public double NetFundAll { get; set; }
|
||||
|
||||
public double NetFund { get; set; }
|
||||
|
||||
public double VmFundSum { get; set; }
|
||||
|
||||
public double OtherFund { get; set; }
|
||||
|
||||
public double AmountFund { get; set; }
|
||||
|
||||
public double MySideMargin { get; set; }
|
||||
|
||||
public double MaintenanceMargin { get; set; }
|
||||
|
||||
public double SwapMarketAmount { get; set; }
|
||||
|
||||
public decimal SwapMarketAmountPercent { get; set; }
|
||||
|
||||
public double AvailableAmount { get; set; }
|
||||
|
||||
public double InsuredAmount { get; set; }
|
||||
|
||||
public double DesirableFund { get; set; }
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user