public BjerksundAndStensland2002Calculator(OptionType optionType, double strike, double spotPrice,
                                                   double maturityInYears, double standardDeviation, double riskFreeRate, double dividendRate,
                                                   double notional, InstrumentType underlyingInstrumentType,
                                                   double riskfreeDfAtExercise, double riskfreeDfAtMaturity,
                                                   double expiryDayRemainingLife = double.NaN, double timeIncrement = 0.0)
        {
            _isOptionOnForward = AnalyticalOptionPricerUtil.isForwardOption(underlyingInstrumentType);
            _optionType        = optionType;
            _X = strike;
            _S = spotPrice;
            _T = maturityInYears + timeIncrement;
            if (!double.IsNaN(expiryDayRemainingLife))
            {
                _T = expiryDayRemainingLife;
            }
            _sigma    = standardDeviation;
            _r        = riskFreeRate;
            _dividend = dividendRate;
            _b        = riskFreeRate - dividendRate;
            _notional = notional;

            _riskfreeDfAtExercise   = riskfreeDfAtExercise;
            _riskfreeDfAtMaturity   = riskfreeDfAtMaturity;
            _expiryDayRemainingLife = expiryDayRemainingLife;
        }
Exemple #2
0
            public OneTouchCalculator(
                BinaryRebateType binaryRebateType,
                double strike,
                double spotPrice,
                double sigma,
                double dividendRate,
                double riskFreeRate,
                double cashOrNothingAmount,
                double exerciseInYears,
                InstrumentType underlyingInstrumentType,
                double notional = 1.0)
            {
                _X                   = strike;
                _S                   = spotPrice;
                _notional            = notional;
                _cashOrNothingAmount = cashOrNothingAmount;
                _sigma               = sigma;
                _T                   = exerciseInYears;
                _binaryRebateType    = binaryRebateType;

                _r                 = riskFreeRate;
                _dividendRate      = dividendRate;
                _isOptionOnFutures = AnalyticalOptionPricerUtil.isFuturesOption(underlyingInstrumentType);
                _isOptionOnForward = AnalyticalOptionPricerUtil.isForwardOption(underlyingInstrumentType);
                _b                 = AnalyticalOptionPricerUtil.costOfCarry(_isOptionOnFutures || _isOptionOnForward, dividendRate, riskFreeRate);
            }
Exemple #3
0
            public BlackScholeCalculator(OptionType optionType,
                                         BinaryOptionPayoffType binaryOptionPayoffType,
                                         double strike,
                                         double spotPrice,
                                         double sigma,
                                         double dividendRate,
                                         double riskfreeRateAtExercise,
                                         double riskfreeRateAtMaturity,
                                         IDayCount curveDayCount,
                                         double cashOrNothingAmount,
                                         Date exerciseDate,
                                         Date maturityDate,
                                         Date valuationDate,
                                         IOption trade,
                                         InstrumentType underlyingInstrumentType,
                                         double notional               = 1.0,
                                         bool isDelayedPay             = false,
                                         double expiryDayRemainingLife = double.NaN,
                                         double timeIncrement          = 0.0)
            {
                _underlyingInstrumentType = underlyingInstrumentType;
                _isOptionOnFutures        = AnalyticalOptionPricerUtil.isFuturesOption(underlyingInstrumentType);
                _isOptionOnForward        = AnalyticalOptionPricerUtil.isForwardOption(underlyingInstrumentType);

                _optionType             = optionType;
                _binaryOptionPayoffType = binaryOptionPayoffType;
                _strike              = strike;
                _spotPrice           = spotPrice;
                _notional            = notional;
                _cashOrNothingAmount = cashOrNothingAmount;
                _sigma = sigma;

                _dividendRate           = dividendRate;
                _riskfreeRateAtExercise = riskfreeRateAtExercise;
                _riskfreeRateAtMaturity = riskfreeRateAtMaturity;

                _exerciseDate  = exerciseDate;
                _maturityDate  = maturityDate;
                _valuationDate = valuationDate;

                _trade = trade;

                _isDelayedPay           = isDelayedPay;
                _rfDfExerciseToMaturity = riskfreeRateAtMaturity / riskfreeRateAtExercise;

                _expiryDayRemainingLife = expiryDayRemainingLife;
                _timeIncrement          = timeIncrement;
                _curveDayCount          = curveDayCount;
            }
Exemple #4
0
        public BlackScholeCalculator(OptionType optionType,
                                     double strike,
                                     double spotPrice,
                                     double sigma,
                                     double riskfreeRateAtExercise,
                                     double riskfreeRateAtMaturity,
                                     IDayCount curveDayCount,
                                     double dividendRate,
                                     Date maturityDate,
                                     Date exerciseDate,
                                     Date valuationDate,
                                     IOption trade,
                                     InstrumentType underlyingInstrumentType,
                                     double notional,
                                     double expiryDayRemainingLife,
                                     double timeIncrement = 0.0)
        {
            _underlyingInstrumentType = underlyingInstrumentType;
            _isOptionOnFutures        = AnalyticalOptionPricerUtil.isFuturesOption(underlyingInstrumentType);
            _isOptionOnForward        = AnalyticalOptionPricerUtil.isForwardOption(underlyingInstrumentType);

            _optionType             = optionType;
            _strike                 = strike;
            _spotPrice              = spotPrice;
            _notional               = notional;
            _sigma                  = sigma;
            _riskfreeRateAtMaturity = riskfreeRateAtMaturity;
            _riskfreeRateAtExercise = riskfreeRateAtExercise;
            _dividendRate           = dividendRate;

            _trade         = trade;
            _maturityDate  = maturityDate;
            _exerciseDate  = exerciseDate;
            _valuationDate = valuationDate;

            _riskfreeDfAtExercise = CalcDfFromZeroRate(_riskfreeRateAtExercise, _exerciseDate, _valuationDate);
            _riskfreeDfAtMaturity = CalcDfFromZeroRate(_riskfreeRateAtMaturity, _maturityDate, _valuationDate);

            //just a internal indicator
            _isDelayedPay = maturityDate.CompareTo(_exerciseDate) > 0;

            _expiryDayRemainingLife = expiryDayRemainingLife;
            _timeIncrement          = timeIncrement;
            _curveDayCount          = curveDayCount;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="BarrierOptionCalculator"/> class.
        /// </summary>
        /// <param name="optionType">Type of the option, Call or Put.</param>
        /// <param name="barrierType">UpAndIn, DownAndOut etc.</param>
        /// <param name="payoff">Option payoff, coupon/rebate/paticipationrate included.</param>
        /// <param name="barrier">Barrier level</param>
        /// <param name="secondarybarrier">Secondary barrier, only effective for double barrier options</param>
        /// <param name="strike">The strike.</param>
        /// <param name="spotPrice">The spot price.</param>
        /// <param name="exerciseInYears">The maturity in years.</param>
        /// <param name="standardDeviation">Volatility, measured by the standard deviation of the underlying.</param>
        /// <param name="riskFreeRate">Risk free rate</param>
        /// <param name="dividendRate">Continuous dividend rate</param>
        public BarrierOptionCalculator(OptionType optionType,
                                       BarrierType barrierType,
                                       double rebate,
                                       double barrier,
                                       double secondarybarrier,
                                       double strike,
                                       double spotPrice,
                                       double exerciseInYears,
                                       double standardDeviation,
                                       double riskFreeRate,
                                       double dividendRate,
                                       Date valuationDate,
                                       Date exerciseDate,
                                       Date underlyingMaturityDate,
                                       IDayCount dayCount,
                                       InstrumentType underlyingInstrumentType,
                                       double notional)
        {
            _isOptionOnFutures = AnalyticalOptionPricerUtil.isFuturesOption(underlyingInstrumentType);
            _isOptionOnForward = AnalyticalOptionPricerUtil.isForwardOption(underlyingInstrumentType);

            _optionType  = optionType;
            _barrierType = barrierType;
            _rebate      = rebate;
            _H           = barrier;
            _H2          = secondarybarrier;
            _X           = strike;
            _S           = spotPrice;
            _T           = exerciseInYears;
            _K           = rebate;
            _sigma       = standardDeviation;
            _r           = riskFreeRate;
            _dividend    = dividendRate;
            _b           = AnalyticalOptionPricerUtil.costOfCarry(_isOptionOnFutures || _isOptionOnForward, dividendRate, riskFreeRate);
            _dayCount    = dayCount;
            _notional    = notional;

            var riskfreeDfAtMaturity = CalcDfFromZeroRate(riskFreeRate, underlyingMaturityDate, valuationDate);
            var riskfreeDfAtExercise = CalcDfFromZeroRate(riskFreeRate, exerciseDate, valuationDate);

            _dfExerciseToMaturity = (_isOptionOnForward) ? riskfreeDfAtMaturity / riskfreeDfAtExercise : 1.0;

            // factors calculation
            switch (barrierType)
            {
            case BarrierType.DownAndIn:
            case BarrierType.DownAndOut:
                _yita = 1.0;
                break;

            case BarrierType.UpAndIn:
            case BarrierType.UpAndOut:
                _yita = -1.0;
                break;

            case BarrierType.DoubleTouchOut:
            case BarrierType.DoubleTouchIn:
                throw new PricingLibraryException("Double barrier shall use AnalyticalDoubleBarrierOptionEngine to calculate!");
            }

            _phi = optionType.Equals(OptionType.Call) ? 1.0 : -1.0;
        }