calculate() public static method

public static calculate ( QLNet.Instrument instrument, IPricingEngine engine, SimpleQuote volQuote, double targetValue, double accuracy, int maxEvaluations, double minVol, double maxVol ) : double
instrument QLNet.Instrument
engine IPricingEngine
volQuote SimpleQuote
targetValue double
accuracy double
maxEvaluations int
minVol double
maxVol double
return double
コード例 #1
0
ファイル: BarrierOption.cs プロジェクト: jmptrader/QLNet-1
        public double impliedVolatility(double targetValue, GeneralizedBlackScholesProcess process, double accuracy, int maxEvaluations, double minVol, double maxVol)
        {
            if (!(!isExpired()))
            {
                throw new ApplicationException("option expired");
            }

            SimpleQuote volQuote = new SimpleQuote();

            GeneralizedBlackScholesProcess newProcess = ImpliedVolatilityHelper.clone(process, volQuote);

            // engines are built-in for the time being
            IPricingEngine engine = null;

            switch (exercise_.type())
            {
            case Exercise.Type.European:
                engine = new AnalyticBarrierEngine(newProcess);
                break;

            case Exercise.Type.American:
            case Exercise.Type.Bermudan:
                throw new ApplicationException("Engine not available for non-European barrier option");

            default:
                throw new ApplicationException("unknown exercise type");
            }

            return(ImpliedVolatilityHelper.calculate(this, engine, volQuote, targetValue, accuracy, maxEvaluations, minVol, maxVol));
        }
コード例 #2
0
ファイル: DividendVanillaOption.cs プロジェクト: qed-/qlnet
        /*! \warning see VanillaOption for notes on implied-volatility
         *           calculation.
         */
        public double impliedVolatility(double targetValue, GeneralizedBlackScholesProcess process,
                                        double accuracy = 1.0e-4, int maxEvaluations = 100, double minVol = 1.0e-7, double maxVol = 4.0)
        {
            if (isExpired())
            {
                throw new ApplicationException("option expired");
            }

            SimpleQuote volQuote = new SimpleQuote();

            GeneralizedBlackScholesProcess newProcess = ImpliedVolatilityHelper.clone(process, volQuote);

            // engines are built-in for the time being
            IPricingEngine engine;

            switch (exercise_.type())
            {
            case Exercise.Type.European:
                engine = new AnalyticDividendEuropeanEngine(newProcess);
                break;

            case Exercise.Type.American:
                engine = new FDDividendAmericanEngine(newProcess);
                break;

            case Exercise.Type.Bermudan:
                throw new ApplicationException("engine not available for Bermudan option with dividends");

            default:
                throw new ArgumentException("unknown exercise type");
            }

            return(ImpliedVolatilityHelper.calculate(this, engine, volQuote, targetValue, accuracy,
                                                     maxEvaluations, minVol, maxVol));
        }