77 lines
2.7 KiB
C#
77 lines
2.7 KiB
C#
using YLErp.Modules.CalculationModule.Abstract;
|
|
|
|
namespace YLErp.Modules.CalculationModule
|
|
{
|
|
/// <summary>
|
|
/// 计算检查帮助类
|
|
/// </summary>
|
|
public static class CalcCheckHelper
|
|
{
|
|
/// <summary>
|
|
/// 检查IOptionCalcDataProvider接口实现
|
|
/// </summary>
|
|
public static T CheckOptionCalcDataProvider<T>(T dataProvider) where T : class, IOptionCalcDataProvider
|
|
{
|
|
if (dataProvider is null)
|
|
{
|
|
throw new ArgumentException("接口实现类 不能为null", nameof(IOptionCalcDataProvider));
|
|
}
|
|
|
|
if (dataProvider.UnderlyingDataProvider is null)
|
|
{
|
|
throw new ArgumentException("UnderlyingDataProvider 不能为null", nameof(IOptionCalcDataProvider));
|
|
}
|
|
|
|
if (dataProvider.UnderlyingPriceProvider is null)
|
|
{
|
|
throw new ArgumentException("UnderlyingPriceProvider 不能为null", nameof(IOptionCalcDataProvider));
|
|
}
|
|
|
|
if (dataProvider.VolatilityDataProvider is null)
|
|
{
|
|
throw new ArgumentException("VolatilityDataProvider 不能为null", nameof(IOptionCalcDataProvider));
|
|
}
|
|
|
|
if (dataProvider.TradeExtendDataProvider is null)
|
|
{
|
|
throw new ArgumentException("TradeExtendDataProvider 不能为null", nameof(IOptionCalcDataProvider));
|
|
}
|
|
|
|
return dataProvider;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 检查IHedgePnlCalcContext接口实现
|
|
/// </summary>
|
|
public static T CheckHedgePnlCalcContext<T>(T context) where T : class, IHedgePnlCalcContext
|
|
{
|
|
if (context is null)
|
|
{
|
|
throw new ArgumentException("接口实现类 不能为null", nameof(IHedgePnlCalcContext));
|
|
}
|
|
|
|
if (context.UnderlyingDataProvider is null)
|
|
{
|
|
throw new ArgumentException("UnderlyingDataProvider 不能为null", nameof(IHedgePnlCalcContext));
|
|
}
|
|
|
|
if (context.UnderlyingPriceProvider is null)
|
|
{
|
|
throw new ArgumentException("UnderlyingPriceProvider 不能为null", nameof(IHedgePnlCalcContext));
|
|
}
|
|
|
|
if (context.UnderlyingSettlePriceProvider is null)
|
|
{
|
|
throw new ArgumentException("UnderlyingSettlePriceProvider 不能为null", nameof(IHedgePnlCalcContext));
|
|
}
|
|
|
|
if (context.ExchangeOptionPriceProvider is null)
|
|
{
|
|
throw new ArgumentException("ExchangePriceProvider 不能为null", nameof(IHedgePnlCalcContext));
|
|
}
|
|
|
|
return context;
|
|
}
|
|
}
|
|
}
|