Esempio n. 1
0
        /// <summary>
        /// Helper function used to validate the arguments in the function
        /// used to compute the Caplet/Floorlet price.
        /// </summary>
        /// <param name="discountFactor">Discount factor.</param>
        /// <param name="forwardRate">Forward rate.</param>
        /// <param name="sigma">Volatility.</param>
        private static void ValidateComputePriceArguments
            (double discountFactor,
            double forwardRate,
            double sigma)
        {
            const bool throwError = true;
            // Validate discount factor.
            const string discountFactorErrorMessage =
                "Discount factor used to price a Caplet/Floorlet must be positive";

            DataQualityValidator.ValidatePositive(discountFactor,
                                                  discountFactorErrorMessage,
                                                  throwError);
            // Validate forward rate.
            const string forwardRateErrorMessage =
                "Forward rate used to price a Caplet/Floorlet must be positive";

            DataQualityValidator.ValidatePositive(forwardRate,
                                                  forwardRateErrorMessage,
                                                  throwError);
            // Validate the forward rate.
            const string sigmaErrorMessage =
                "Volatility used to price a Caplet/Floorlet must be positive";

            DataQualityValidator.ValidatePositive(sigma,
                                                  sigmaErrorMessage,
                                                  throwError);
        }
Esempio n. 2
0
        /// <summary>
        /// Helper function used to validate all constructor arguments.
        /// </summary>
        /// <param name="notional">Caplet/Floorlet face value.</param>
        /// <param name="optionExpiry">Option expiry expressed in years
        /// as an ACT/365 day count.</param>
        /// <param name="strike">Option strike expressed as a decimal.</param>
        /// <param name="tau">Year fraction for the Caplet/Floorlet.</param>
        private static void ValidateConstructorArguments
            (decimal notional,
            decimal optionExpiry,
            decimal strike,
            decimal tau)
        {
            // Validate notional.
            const string notionalErrorMessage =
                "Notional for a Caplet/Floorlet must be positive";

            DataQualityValidator.ValidatePositive(notional,
                                                  notionalErrorMessage,
                                                  true);
            // Validate option expiry.
            const string optionExpiryErrorMessage =
                "Expiry for a Caplet/Floorlet cannot be negative";

            DataQualityValidator.ValidateMinimum(optionExpiry,
                                                 0m,
                                                 optionExpiryErrorMessage,
                                                 true);
            // Validate strike.
            const string strikeErrorMessage =
                "Strike for a Caplet/Floorlet must be positive";

            DataQualityValidator.ValidatePositive(strike,
                                                  strikeErrorMessage,
                                                  true);
            // Validate tau.
            const string tauErrorMessage =
                "Year fraction for a Caplet/Floorlet must be positive";

            DataQualityValidator.ValidatePositive(tau,
                                                  tauErrorMessage,
                                                  true);
        }