ParameterBase.Clone() 保留运行时类型深拷贝; ValueCalculator 两个薄接入方法; GreeksBumpCalculator/GreeksRiskFactor 引擎。加法性重定价桥,不动现有定价输出。
37 lines
1.6 KiB
C#
37 lines
1.6 KiB
C#
using Qdp.Foundation.Implementations;
|
||
|
||
namespace YLErp.BLL.Calculation.V2.Parameter
|
||
{
|
||
public class ParameterBase
|
||
{
|
||
public DateTime ValueDate { get; set; }
|
||
public string EngineName { get; set; }
|
||
public string DiscountCurveName { get; set; }
|
||
//如果RiskFreeRate有值,则使用如果RiskFreeRate,忽略DiscountCurveName
|
||
public double? RiskFreeRate { get; set; }
|
||
public Dictionary<string, double> SpotPrices { get; set; }
|
||
public Dictionary<Date, double> Dividends { get; set; }
|
||
public double? OverrideTTM { get; set; }
|
||
public bool HasNightMarket { get; set; }
|
||
public bool PreciseTimeMode { get; set; }
|
||
public int maturityShift { get; set; }
|
||
|
||
/// <summary>
|
||
/// 深拷贝(保留运行时类型)。
|
||
/// <para>
|
||
/// 用 MemberwiseClone 保证克隆对象与 <c>this</c> 运行时类型一致——
|
||
/// 例如 <c>VanillaOptionParameter</c> 克隆后仍是 <c>VanillaOptionParameter</c>,
|
||
/// 否则 ValueCalculator 内 <c>parameter as VanillaOptionParameter</c> 会因类型退化为基类而得到 null。
|
||
/// 引用型字段 SpotPrices/Dividends 单独深拷,避免对克隆体 bump 时污染原参数。
|
||
/// </para>
|
||
/// </summary>
|
||
public virtual ParameterBase Clone()
|
||
{
|
||
var clone = (ParameterBase)MemberwiseClone();
|
||
clone.SpotPrices = SpotPrices == null ? null : new Dictionary<string, double>(SpotPrices);
|
||
clone.Dividends = Dividends == null ? null : new Dictionary<Date, double>(Dividends);
|
||
return clone;
|
||
}
|
||
}
|
||
}
|