namespace YLErp.Modules.EodModule.SettlementModule { /// /// 日终结算请求 /// public class EodSettlementRequest { bool _readonly; private DateTime _settleDate; protected string _volType; protected bool _useClosePrice; private IEnumerable _clientId; private bool _isSettleOtcTrades = true; private bool _isSettleExchangeTrades = true; public EodSettlementRequest(OptUserInfo userInfo) { UserInfo = userInfo ?? throw new ArgumentNullException(nameof(userInfo)); SuspensionUnderlyingIds = EodDataHelper.GetSuspensionUnderlyingIds(); } #region----属性只读---- public bool Readonly => _readonly; private void CheckReadonly() { if (_readonly) { throw new InvalidOperationException(); } } public EodSettlementRequest AsReadonly() { _readonly = true; return this; } #endregion public OptUserInfo UserInfo { get; } /// /// 结算日期 /// public DateTime SettleDate { get => _settleDate; set { CheckReadonly(); _settleDate = value; } } /// /// 结算用的波动率类型 /// public string VolType { get => _volType; set { CheckReadonly(); _volType = value; } } /// /// 是否使用收盘价结算 /// public bool UseClosePrice { get => _useClosePrice; set { CheckReadonly(); _useClosePrice = value; } } /// /// 是否结算衍生品交易(默认true) /// public bool IsSettleOtcTrades { get => _isSettleOtcTrades; set { CheckReadonly(); _isSettleOtcTrades = value; } } /// /// 只结算所给客户ID的交易 /// 注意:只用于衍生品交易结算时 /// public IEnumerable ClientIds { get => _clientId; set { CheckReadonly(); _clientId = value; } } /// /// 是否结算场内交易(默认true) /// public bool IsSettleExchangeTrades { get => _isSettleExchangeTrades; set { CheckReadonly(); _isSettleExchangeTrades = value; } } /// /// 停牌标的ID集合 /// public IEnumerable SuspensionUnderlyingIds { get; } /// /// 涨跌停标的集合 /// public IEnumerable DelayUnderlyIds { get; set; } /// /// 是否部分结算 /// public bool IsPartialSettlement { get { if (ClientIds!=null) { return true; } return !(IsSettleOtcTrades && IsSettleExchangeTrades); } } /// /// 是否延期交易 /// public bool IsDelayTrade { get; set; } /// /// 克隆对象(克隆后非只读) /// public EodSettlementRequest Clone(bool asReadonly = false) { var clone = (EodSettlementRequest)MemberwiseClone(); clone._readonly = asReadonly; return clone; } /// /// 返回收盘价或结算价 /// public string GetPriceType() { return UseClosePrice ? ConsGlobal.SettlePriceMode.收盘价 : ConsGlobal.SettlePriceMode.结算价; } public override string ToString() { var priceType = UseClosePrice ? "收盘价" : "结算价"; return $"{SettleDate:yyyy-MM-dd},{VolType},{priceType}"; } } }