Esempio n. 1
0
        public void Task_2_8_5()
        {
            // Variance Process Values
            double Kappa = 2;
            double Theta = 0.06;
            double Sigma = 0.4;
            double V0    = 0.04;
            double Rho   = 0.5;

            // Heston Model Params
            double InitialStockPrice = 100;
            double RiskFreeRate      = 0.1;

            // Option Params
            double Maturity = 9;

            // MC Simulation Params
            int NumberOfTrials    = (int)1e5;
            int NumberOfTimeSteps = (int)Math.Ceiling(365 * Maturity);

            VarianceProcessParameters varParams =
                new VarianceProcessParameters(Kappa, Theta, Sigma, V0, Rho);

            HestonModelParameters hestonModel =
                new HestonModelParameters(InitialStockPrice, RiskFreeRate, varParams);

            MonteCarloSettings monteCarloSettings =
                new MonteCarloSettings(NumberOfTrials, NumberOfTimeSteps);

            LookbackOptionMC lookbackOptionMC =
                new LookbackOptionMC(hestonModel, monteCarloSettings, Maturity);

            Assert.AreEqual(13.6299, lookbackOptionMC.Price(1), 1e-1);
        }
Esempio n. 2
0
        /// <summary>
        /// Price a lookback option in the Heston model using the
        /// a Monte-Carlo method. Accuracy will depend on number of time steps and samples </summary>
        /// <param name="parameters">Object implementing IHestonModelParameters interface, containing model parameters.</param>
        /// <param name="maturity">An object implementing IOption interface and containing option's maturity</param>
        /// <param name="monteCarloSimulationSettings">An object implementing IMonteCarloSettings object and containing simulation settings.</param>
        /// <returns>Option price</returns>
        public static double HestonLookbackOptionPriceMC(IHestonModelParameters parameters, IOption maturity, IMonteCarloSettings monteCarloSimulationSettings)
        {
            try
            {
                // Typecast maturity
                Option tempOption = (Option)maturity;

                // Create Monte Carlo Lookback option object
                LookbackOptionMC lookbackOptionMC =
                    new LookbackOptionMC((HestonModelParameters)parameters,
                                         (MonteCarloSettings)monteCarloSimulationSettings, maturity.Maturity);

                return(lookbackOptionMC.Price(Environment.ProcessorCount));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }