Files
zszq-trs/YLErpDAL/Modules/ScenarioModule/Models/ScenarioUnderlyingModel.cs
T
2024-05-09 14:06:26 +08:00

82 lines
2.1 KiB
C#

namespace YLErp.Modules.ScenarioModule
{
/// <summary>
/// 情景分析标的参数
/// </summary>
public class ScenarioUnderlyingModel
{
/// <summary>
/// [out]标的品种代码
/// </summary>
public string VarietyCode { get; set; }
/// <summary>
/// [in]标的代码
/// </summary>
public string UnderlyingCode { get; set; }
/// <summary>
/// [in]标的价格
/// </summary>
public double? UnderlyingPrice { get; set; }
/// <summary>
/// [in]分红率
/// </summary>
public double? DividenRate { get; set; }
/// <summary>
/// 分红率(初始传入)
/// </summary>
internal double? OriDividenRate { get; set; }
/// <summary>
/// [in]波动率
/// </summary>
public double? ConstVol { get; set; }
/// <summary>
/// 波动率(初始传入)
/// </summary>
internal double? OriVol { get; set; }
double? _preVol, _preDividenRate;
internal void SetVol(double value)
{
if (_preVol == null)
{
ConstVol = _preVol = value;
}
else if (!double.IsNaN(_preVol.Value) && Math.Abs(_preVol.Value - value) > 1e-6)
{
ConstVol = null;
_preVol = double.NaN;
}
}
internal void SetDividenRate(double value)
{
if (_preDividenRate == null)
{
DividenRate = _preDividenRate = value;
}
else if (!double.IsNaN(_preDividenRate.Value) && Math.Abs(_preDividenRate.Value - value) > 1e-6)
{
DividenRate = null;
_preDividenRate = double.NaN;
}
}
public override string ToString()
{
return $"{VarietyCode}--{UnderlyingCode}--price:{UnderlyingPrice}--div:{DividenRate}--vol:{ConstVol}";
}
public ScenarioUnderlyingModel Clone()
{
return (ScenarioUnderlyingModel)MemberwiseClone();
}
}
}