namespace YLErp.Modules.RiskExposure { public class EodRiskModel { //---------------------------------------- //导出用 public string UnderlyingCode { get; set; } public string UnderlyingPrice { get; set; } public string VarietyCode { get; set; } //---------------------------------------- /// /// 当日盈亏 /// public double DailyPnl { get; set; } public double Pnl { get; set; } public double Delta { get; set; } public double DeltaCash { get; set; } public double GammaCash { get; set; } public double DeltaInLots { get; set; } /// /// 名义本金 /// public double StockEqvNotional { get; set; } /// /// 有效名义本金 /// public double StockEqvNotionalReal { get; set; } /// /// 场外名义本金 /// 期权+互换 /// 只有汇总需要赋值 /// public double OtcStockEqvNotional { get; set; } /// /// 场外有效名义本金 /// 期权+互换 /// 只有汇总需要赋值 /// public double OtcStockEqvNotionalReal { get; set; } /// /// 持仓量 /// public double Position { get; set; } /// /// 持仓金额 /// public double PositionCash { get; set; } /// /// 持仓手数 /// public double PositionInLots { get; set; } /// /// 当日手续费 /// public double DailyCommission { get; set; } /// /// 手续费 /// public double Commission { get; set; } /// /// 持仓变化 /// public double PositionIncrementInLots { get; set; } public double PositionStockEqvNotional { get; set; } public double Gamma { get; set; } public double GammaInLots { get; set; } public double Theta { get; set; } public double Vega { get; set; } public double Rho { get; set; } public double dPnlDelta { get; set; } public double dPnlGamma { get; set; } public double dPnlVega { get; set; } public double dPnlTheta { get; set; } public double dPnlPsi { get; set; } public double CumulativeFloatProfitLoss { get; set; } public static EodRiskModel operator +(EodRiskModel sum1, EodRiskModel sum2) { if (sum1 == null && sum2 == null) { return null; } if (sum1 == null) { return sum2; } if (sum2 == null) { return sum1; } return new EodRiskModel { StockEqvNotional = sum1.StockEqvNotional + sum2.StockEqvNotional, StockEqvNotionalReal = sum1.StockEqvNotionalReal + sum2.StockEqvNotionalReal, OtcStockEqvNotional = sum1.OtcStockEqvNotional + sum2.OtcStockEqvNotional, OtcStockEqvNotionalReal = sum1.OtcStockEqvNotionalReal + sum2.OtcStockEqvNotionalReal, DailyPnl = sum1.DailyPnl + sum2.DailyPnl, Pnl = sum1.Pnl + sum2.Pnl, Delta = sum1.Delta + sum2.Delta, DeltaInLots = sum1.DeltaInLots + sum2.DeltaInLots, DeltaCash = sum1.DeltaCash + sum2.DeltaCash, Gamma = sum1.Gamma + sum2.Gamma, GammaCash = sum1.GammaCash + sum2.GammaCash, GammaInLots = sum1.GammaInLots + sum2.GammaInLots, Theta = sum1.Theta + sum2.Theta, Vega = sum1.Vega + sum2.Vega, Rho = sum1.Rho + sum2.Rho, dPnlDelta = sum1.dPnlDelta + sum2.dPnlDelta, dPnlGamma = sum1.dPnlGamma + sum2.dPnlGamma, dPnlVega = sum1.dPnlVega + sum2.dPnlVega, dPnlTheta = sum1.dPnlTheta + sum2.dPnlTheta, dPnlPsi = sum1.dPnlPsi + sum2.dPnlPsi, Commission = sum1.Commission + sum2.Commission, DailyCommission = sum1.DailyCommission + sum2.DailyCommission, Position = sum1.Position + sum2.Position, PositionInLots = sum1.PositionInLots + sum2.PositionInLots, PositionIncrementInLots = sum1.PositionIncrementInLots + sum2.PositionIncrementInLots }; } } public class UnderlyingRiskModel { public int UnderlyingId { get; set; } public string UnderlyingCode { get; set; } /// /// 组合标的的公式信息 /// public string SyntheticUnderlyingTipsInfo { get; set; } public double? UnderlyingPrice { get; set; } public string VarietyCode { get; set; } /// /// 敞口限额 /// public double? VarietyOpenLimit { get; set; } /// /// 百分比符号,还是绝对值 /// public string VarietyOpenLimitIcon { get; set; } public string UnderlyingInstrumentType { get; set; } /// /// 期权期货组合 /// public EodRiskModel PortfolioRisk { get; set; } /// /// 场外期权头寸 /// public EodRiskModel OtcRisk { get; set; } /// /// 远期头寸 /// public EodRiskModel ForwardRisk { get; set; } /// /// 掉期头寸 /// public EodRiskModel SwapRisk { get; set; } /// /// 场内期权头寸 /// public EodRiskModel ExOptionRisk { get; set; } /// /// 期货头寸 /// public EodRiskModel FuturesRisk { get; set; } public VarietyLimit VarietyLimit { get; set; } } public class UnderlyingRiskModelSortComparer : IComparer { private int GetTypeSortValue(UnderlyingRiskModel x) { if (x.UnderlyingInstrumentType == "Stock" && x.VarietyCode != "组合标的") { return 1; } if (x.UnderlyingInstrumentType == "Stock" && x.VarietyCode == "组合标的") { return 2; } if (x.UnderlyingInstrumentType == "CommodityFutures" && x.VarietyCode == "组合标的") { return 3; } return 4; } public int Compare(UnderlyingRiskModel x, UnderlyingRiskModel y) { var xSortValue = GetTypeSortValue(x); var ySortValue = GetTypeSortValue(y); if (xSortValue != ySortValue) { return xSortValue - ySortValue; } return String.Compare(x.UnderlyingCode, y.UnderlyingCode, StringComparison.Ordinal); } } /// /// 总计(最下面一行) /// public class RiskExposureReportSumModel { /// /// 汇总栏 /// public EodRiskModel PortfolioSum { get; set; } /// /// 场外 /// public EodRiskModel OtcSum { get; set; } /// /// 场内 /// public EodRiskModel ExOptionSum { get; set; } /// /// 标的交易 /// public EodRiskModel FuturesSum { get; set; } /// /// 远期 /// public EodRiskModel ForwardSum { get; set; } /// /// 收益互换 /// public EodRiskModel SwapSum { get; set; } } public class VarietyRiskExposureModel { /// /// 品种 /// public string VarietyCode { get; set; } public double? VarietyOpenLimit { get; set; } public string VarietyOpenLimitIcon { get; set; } public RiskExposureReportSumModel VarietySum { get; set; } public List UnderlyingRiskList { get; set; } public VarietyLimit varietyLimit { get; set; } } public class RiskExposureReportModel { public string ReportStart { get; set; } public string ReportEnd { get; set; } public RiskExposureReportSumModel Sum { get; set; } public List ReportModels { get; set; } //综合盈亏比例: ((收取的权利金 - 支付的权利金) + 对冲盈亏 - 期权估值)/对冲账户成本 public double TotalPnlRate { get; set; } } public class TrendChartModel { public List XAxisData { get; set; }=new List(); public List> YAxisData { get; set; }= new List>(); } }