322 lines
9.2 KiB
C#
322 lines
9.2 KiB
C#
namespace YLErp.Modules.RiskExposure
|
|
{
|
|
public class EodRiskModel
|
|
{
|
|
//----------------------------------------
|
|
//导出用
|
|
public string UnderlyingCode { get; set; }
|
|
|
|
public string UnderlyingPrice { get; set; }
|
|
|
|
public string VarietyCode { get; set; }
|
|
|
|
//----------------------------------------
|
|
|
|
/// <summary>
|
|
/// 当日盈亏
|
|
/// </summary>
|
|
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; }
|
|
|
|
/// <summary>
|
|
/// 名义本金
|
|
/// </summary>
|
|
public double StockEqvNotional { get; set; }
|
|
/// <summary>
|
|
/// 有效名义本金
|
|
/// </summary>
|
|
public double StockEqvNotionalReal { get; set; }
|
|
|
|
/// <summary>
|
|
/// 场外名义本金
|
|
/// <para>期权+互换</para>
|
|
/// <para>只有汇总需要赋值</para>
|
|
/// </summary>
|
|
public double OtcStockEqvNotional { get; set; }
|
|
/// <summary>
|
|
/// 场外有效名义本金
|
|
/// <para>期权+互换</para>
|
|
/// <para>只有汇总需要赋值</para>
|
|
/// </summary>
|
|
public double OtcStockEqvNotionalReal { get; set; }
|
|
|
|
/// <summary>
|
|
/// 持仓量
|
|
/// </summary>
|
|
public double Position { get; set; }
|
|
|
|
/// <summary>
|
|
/// 持仓金额
|
|
/// </summary>
|
|
public double PositionCash { get; set; }
|
|
|
|
/// <summary>
|
|
/// 持仓手数
|
|
/// </summary>
|
|
public double PositionInLots { get; set; }
|
|
|
|
/// <summary>
|
|
/// 当日手续费
|
|
/// </summary>
|
|
public double DailyCommission { get; set; }
|
|
|
|
/// <summary>
|
|
/// 手续费
|
|
/// </summary>
|
|
public double Commission { get; set; }
|
|
|
|
/// <summary>
|
|
/// 持仓变化
|
|
/// </summary>
|
|
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; }
|
|
|
|
/// <summary>
|
|
/// 组合标的的公式信息
|
|
/// </summary>
|
|
public string SyntheticUnderlyingTipsInfo { get; set; }
|
|
|
|
public double? UnderlyingPrice { get; set; }
|
|
|
|
public string VarietyCode { get; set; }
|
|
|
|
/// <summary>
|
|
/// 敞口限额
|
|
/// </summary>
|
|
public double? VarietyOpenLimit { get; set; }
|
|
|
|
/// <summary>
|
|
/// 百分比符号,还是绝对值
|
|
/// </summary>
|
|
public string VarietyOpenLimitIcon { get; set; }
|
|
|
|
public string UnderlyingInstrumentType { get; set; }
|
|
|
|
/// <summary>
|
|
/// 期权期货组合
|
|
/// </summary>
|
|
public EodRiskModel PortfolioRisk { get; set; }
|
|
|
|
/// <summary>
|
|
/// 场外期权头寸
|
|
/// </summary>
|
|
public EodRiskModel OtcRisk { get; set; }
|
|
|
|
/// <summary>
|
|
/// 远期头寸
|
|
/// </summary>
|
|
public EodRiskModel ForwardRisk { get; set; }
|
|
|
|
/// <summary>
|
|
/// 掉期头寸
|
|
/// </summary>
|
|
public EodRiskModel SwapRisk { get; set; }
|
|
|
|
/// <summary>
|
|
/// 场内期权头寸
|
|
/// </summary>
|
|
public EodRiskModel ExOptionRisk { get; set; }
|
|
|
|
/// <summary>
|
|
/// 期货头寸
|
|
/// </summary>
|
|
public EodRiskModel FuturesRisk { get; set; }
|
|
|
|
|
|
public VarietyLimit VarietyLimit { get; set; }
|
|
}
|
|
|
|
public class UnderlyingRiskModelSortComparer : IComparer<UnderlyingRiskModel>
|
|
{
|
|
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);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 总计(最下面一行)
|
|
/// </summary>
|
|
public class RiskExposureReportSumModel
|
|
{
|
|
/// <summary>
|
|
/// 汇总栏
|
|
/// </summary>
|
|
public EodRiskModel PortfolioSum { get; set; }
|
|
|
|
/// <summary>
|
|
/// 场外
|
|
/// </summary>
|
|
public EodRiskModel OtcSum { get; set; }
|
|
|
|
/// <summary>
|
|
/// 场内
|
|
/// </summary>
|
|
public EodRiskModel ExOptionSum { get; set; }
|
|
|
|
/// <summary>
|
|
/// 标的交易
|
|
/// </summary>
|
|
public EodRiskModel FuturesSum { get; set; }
|
|
|
|
/// <summary>
|
|
/// 远期
|
|
/// </summary>
|
|
public EodRiskModel ForwardSum { get; set; }
|
|
|
|
/// <summary>
|
|
/// 收益互换
|
|
/// </summary>
|
|
public EodRiskModel SwapSum { get; set; }
|
|
}
|
|
|
|
public class VarietyRiskExposureModel
|
|
{
|
|
/// <summary>
|
|
/// 品种
|
|
/// </summary>
|
|
public string VarietyCode { get; set; }
|
|
|
|
public double? VarietyOpenLimit { get; set; }
|
|
|
|
public string VarietyOpenLimitIcon { get; set; }
|
|
|
|
public RiskExposureReportSumModel VarietySum { get; set; }
|
|
|
|
public List<UnderlyingRiskModel> 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<VarietyRiskExposureModel> ReportModels { get; set; }
|
|
|
|
//综合盈亏比例: ((收取的权利金 - 支付的权利金) + 对冲盈亏 - 期权估值)/对冲账户成本
|
|
public double TotalPnlRate { get; set; }
|
|
}
|
|
|
|
public class TrendChartModel
|
|
{
|
|
public List<string> XAxisData { get; set; }=new List<string>();
|
|
|
|
public List<List<string>> YAxisData { get; set; }= new List<List<string>>();
|
|
}
|
|
|
|
}
|