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