using YLErp.Modules.CalculationModule.Abstract;
namespace YLErp.Modules.CalculationModule
{
///
/// 计算检查帮助类
///
public static class CalcCheckHelper
{
///
/// 检查IOptionCalcDataProvider接口实现
///
public static T CheckOptionCalcDataProvider(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;
}
///
/// 检查IHedgePnlCalcContext接口实现
///
public static T CheckHedgePnlCalcContext(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;
}
}
}