using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using YLErp.Commons; namespace YLErp.DBModels { [Table("trade_cash")] public class trade_cash : TradeExtendBase, IClonable { public trade_cash() { if (this.id == 0 || this.CreateTime == null) { this.CreateTime = DateTime.Now; } } /// /// 事件发生日 /// 事件发生日和结算日不相同时,该字段应被赋值,其他场景该字段为Null /// 开仓时该字段存实际开仓日(非操作日期) /// 了结时该字段存实际了结日(非操作日期) /// 如遇节假日则国君为前一个交易日,其他为下一个交易日 /// [DisplayName("事件记录时间")] public DateTime? HappenedDate { set; get; } private double? _barrierPrice; /// /// 敲出障碍价格(仅当该笔流水为敲出流水的时候,这个字段才有值不为null) /// [DisplayName("敲出障碍价格")] public double? BarrierPrice { set { _barrierPrice = value.FormatValue(2); } get { return _barrierPrice; } } /// /// 该字段标记的无效并不是真的无效 /// 在复核和结算环节都会用到无效的记录 /// [DisplayName("是否有效")] public string ValidState { get; set; } /// /// 该字段标记该记录是否已被从系统中删除 /// 只有证券业报送时,会使用到已删除的数据 /// public bool IsDeleted { get; set; } public static string LogClass = "现金交割交易"; /// /// 期权类型 /// [NotMapped] [DisplayName("期权类型")] public string OptionType { get; set; } /// /// 行权价类型 /// [NotMapped] [DisplayName("行权价类型")] public string StrikeType { get; set; } /// /// 主交易Id /// public int ParentTradeId { get; set; } /// /// 分组主交易资金记录id /// public int ParentTradeCashId { get; set; } /// /// 交割方式 /// [DisplayName("交割方式")] public string ExceciseType { set; get; } /// /// 操作类型 /// [DisplayName("操作类型"), Required] public string Action { set; get; } /// /// 买卖方向 /// [DisplayName("买卖方向")] public string TradeType { set; get; } /// /// 交易表对应的交易类型 /// [NotMapped] public string Trade_TradeType { get; set; } /// /// 看涨看跌 /// [DisplayName("看涨看跌")] public string CallPut { set; get; } /// /// 行权价 /// [DisplayName("行权价")] public double? Strike { set; get; } [DisplayName("行权价")] [NotMapped] public string StrikeString { get; set; } /// /// 目前组合交易考虑只有两个行权价 /// [DisplayName("行权价")] [NotMapped] public double? StrikeTwo { get; set; } [DisplayName("行权价")] [NotMapped] public string StrikeTwoString { get; set; } /// /// 份额 /// [DisplayName("份额")] public double Notional { set; get; } /// /// 当前行权份额占原始份额的比例 /// 平仓时当前总持仓份额占原始份额的比例 /// [NotMapped] public double NotionalPercent { get; set; } /// /// 数量 /// [DisplayName("数量")] public double? TradeAmount { get; set; } private double _amount; /// /// 交割金额(包含额外金额,不包含权利金) /// [DisplayName("交割金额")] public double Amount { set { _amount = value.FormatValue(2); } get { return _amount; } } /// /// 计价交割金额 /// [DisplayName("计价交割金额")] public double? QuoteAmount { get; set; } [NotMapped] public double MinusAmount { get { return (-Amount); } } /// /// 实现盈亏(包含额外金额,包含权利金) /// 盯市报告用到 double /// [NotMapped] public string WinLoss { get; set; } /// /// 计价盈亏 -- 互换提前终止详情页用到--国君 /// [NotMapped] public string QuoteWinloss { get; set; } [NotMapped] public double WinLossDouble { get { double.TryParse(WinLoss, out var temp); return temp; } } /// /// 期末价格(包含亚式的执行均价) /// [DisplayName("期末价格")] public double? FinalPrice { get; set; } /// /// 期末现价 /// [DisplayName("期末现价")] public double? SpotPrice { get; set; } /// /// 平仓类型 /// [DisplayName("平仓类型")] public string UnwindType { set; get; } /// /// 平仓方式 0名义本金,1数量 /// [DisplayName("平仓方式")] public int? UnwindMethod { set; get; } /// /// 平仓方式名称 /// [NotMapped] public string UnwindMethodName { get { string[] methodName = new string[] { "名义本金", "数量" }; return methodName[UnwindMethod ?? 0]; } } /// /// 平仓总额 /// [DisplayName("平仓费总额")] [NotMapped] public string UnwindFee { get; set; } [DisplayName("平仓单价检查")] [NotMapped] public double? UnwindPriceCheck { get; set; } /// /// 平仓单价费率 /// [DisplayName("平仓单价检查")] [NotMapped] public double? UnwindPricePercentRateCheck { get; set; } /// /// 平仓单价 /// [DisplayName("平仓单价")] public double? UnwindPrice { get; set; } [DisplayName("期权价值")] [NotMapped] public double? SinglePV { get; set; } [DisplayName("期权价值")] [NotMapped] public double? SinglePVPercentRate { get; set; } /// /// 期权平仓价格/行权收益 /// 盯市报告用到 /// [NotMapped] public double SingleWinPrice { get; set; } [NotMapped] public string SingleWinPriceString { get; set; } /// /// 期权平仓价格/行权收益 比例 /// [NotMapped] public double SingleWinPricePercent { get; set; } /// /// 平仓份额 /// [DisplayName("平仓份额")] public double? UnwindNotional { get; set; } /// /// 平仓数量 /// [DisplayName("平仓数量")] public double? UnwindTradeAmount { get; set; } /// /// 平仓行权互换票息操作的初始名义本金占比(该字段用于算实现盈亏用到)当到期互换和票息,该字段设置为0 /// [DisplayName("平仓比例")] public double? UnwindPercentRate { get; set; } /// /// 平仓行权互换票息操作的初始名义本金占比 /// [DisplayName("平仓比例")] public double? NotionalPercentRate { get; set; } /// /// 平仓单价比例 /// [DisplayName("平仓单价")] public double? UnwindPricePercentRate { get; set; } /// /// 平仓行权份额 /// 盯市报告用到 /// [NotMapped] public string ActionNotional { get; set; } /// /// 平仓行权数量 /// 盯市报告用到 /// [NotMapped] public double ActionTradeAmount { get; set; } /// /// 平仓行权虚拟数量 /// 盯市报告用到 /// [NotMapped] public double ActionTradeAmountV { get; set; } /// /// 名义本金 /// [DisplayName("持仓名义本金")] [NotMapped] public double StockEqvNotional { get; set; } /// /// 平仓名义本金 /// //[NotMapped] [DisplayName("平仓名义本金")] public double? UnwindStockEqvNotional { get; set; } [DisplayName("成交名义本金")] [NotMapped] public double OriginalStockEqvNotional { get; set; } private double? _extraAmount; [DisplayName("额外金额")] public double? ExtraAmount { get { return _extraAmount; } set { _extraAmount = value.FormatValue(2); } } [DisplayName("默认金额")] [NotMapped] [DisplayFormat(DataFormatString = "{0:F2}", ApplyFormatInEditMode = true)] public double InitialAmount { get; set; } [DisplayName("平仓波动率")] public double? UnwindVol { get; set; } [DisplayName("波动率类型")] public string VolType { get; set; } [DisplayName("客户名称")] [NotMapped] public string ClientName { get; set; } [NotMapped] public string TraderName { get; set; } [DisplayName("标的代码")] [NotMapped] public string UnderlyingCode { get; set; } [DisplayName("标的名")] [NotMapped] public string UnderlyingName { get; set; } [NotMapped] public string UnderlyingInstrumentType { get; set; } [NotMapped] public bool IsMoneynessOptionData { get; set; } [NotMapped] public bool IsMoneynessOption { get; set; } [DisplayName("期初价格")] [NotMapped] public double InitialSpotPrice { get; set; } [DisplayName("有效行权价")] [NotMapped] public double ValidStrike { get; set; } [DisplayName("是否可以执行")] [NotMapped] public bool IsPossibleExec { get; set; } [DisplayName("行权费率(‱)")] [NotMapped] public double? ExerciseCostRatio { get; set; } /// /// 资金结算日 /// 资金发生日和结算日不相同时,该字段应被赋值为结算日 /// [DisplayName("操作时间")] public DateTime ValueDate { set; get; } /// /// 交易溢价 /// [DisplayName("了结溢价")] public double TradePremium { get; set; } /// /// 返还预付金 /// [DisplayName("返还预付金")] public double AdvanceMoney { get; set; } /// /// 起始日期 /// [NotMapped] public DateTime StartDate { get; set; } [NotMapped] public string ValueDateString { get { if (HappenedDate != null) { return HappenedDate.Value.ToString("yyyy-MM-dd"); } else if (ValueDate != DateTime.MinValue) { return ValueDate.ToString("yyyy-MM-dd"); } else { return ""; } } } public string Status { set; get; } /// /// 结算日 /// [DisplayName("结算日")] public DateTime? SettleDate { get; set; } /// /// 备注 /// [DisplayName("备注")] public string Comments { get; set; } /// /// 行权方式 /// [DisplayName("行权方式")] public string ExerciseWay { get; set; } /// /// 了结编号 /// [DisplayName("了结编号")] public string Number { get; set; } [DisplayName("看涨看跌")] [NotMapped] public string CallPutDesc { get { if (CallPut == "Call") { return "看涨"; } return "看跌"; } } [NotMapped] public string TradeNumber { get; set; } [NotMapped] public double? OriginalNotional { get; set; } [NotMapped] public double? TradeOriginalAmount { get; set; } [NotMapped] public int? UnderlyingId { get; set; } [DisplayName("计划期限")] [NotMapped] public double? DurationDays { get; set; } /// /// 期权类型 /// [NotMapped] public string BondType { get; set; } /// /// 交易确认日 /// 财务确认入账日期 /// 财务汇总页面赋值 /// public DateTime ConfirmDate { get; set; } /// /// 是否最终了结操作 /// 代表只有交易完全了结了,该值才会为true /// public bool IsLastAction { get; set; } public double? CurrencyRate { get; set; } /// /// 是否通过期权费率设置权利金 /// [NotMapped] public bool? IsUsePremiumRate { get; set; } /// /// 是否通过名义本金方式平仓 /// [NotMapped] public bool? IsUnwindStockEqvNotional { get; set; } /// /// 是否总额成交方式 /// [NotMapped] public bool? IsTradePricePayType { get; set; } /// /// 是否到期执行操作 /// [NotMapped] public bool? IsExpire { get; set; } [NotMapped] public double? ParticipationRate { get; set; } [NotMapped] public double? PrincipalSum { get; set; } [NotMapped] public double? OriginalPrincipalSum { get; set; } [NotMapped] public double? AnnualizeFactor { get; set; } /// /// 东证字段 平仓价格和用Mid Vol计算的PV差 /// [NotMapped] public double? Day1Pnl { get; set; } [NotMapped] public string BuySell { get; set; } [NotMapped] public trade_cash_swap trade_cash_swap { get; set; } = new trade_cash_swap(); public trade_cash Clone() { return (trade_cash)MemberwiseClone(); } /// /// 创建时间 /// public DateTime? CreateTime { get; set; } } [NotMapped] public class TradeCashDto : trade_cash { } }