Files
zszq-trs/YLErpDAL/BLL/Calculation/Engine/OptionEngineFactoryBase.cs
T
2024-05-09 14:06:26 +08:00

36 lines
1.3 KiB
C#

using Qdp.Pricing.Base.Enums;
using Qdp.Pricing.Library.Common.Interfaces;
using Qdp.Pricing.Library.Options.MonteCarlo;
namespace YLErp.BLL.Calculation.Engine
{
public abstract class OptionEngineFactoryBase : IOptionEngineFactory
{
public abstract IEngine GetEngine(string engineName = null, OptionExercise exercise = OptionExercise.European, params object[] additionalParams);
protected virtual IEngine CreateGenericMonteCarloEngine(params object[] parameters)
{
int parallelDegree = PS.Config.ErpElement.QdpParallelDegree, numberOfSimulation = 50000;
bool useConstRate = true, useConstVol = true;
if (parameters.Length > 0)
{
parallelDegree = (int)parameters[0];
}
if (parameters.Length > 1)
{
numberOfSimulation = (int)parameters[1];
}
if (parameters.Length > 2)
{
useConstRate = (bool)parameters[2];
}
if (parameters.Length > 3)
{
useConstVol = (bool)parameters[3];
}
return new GenericMonteCarloEngine(parallelDegree, numberOfSimulation, useConstRate: useConstRate, useConstVol: useConstVol);
}
}
}