コード例 #1
0
        /// <summary>
        /// Get price factors.
        /// </summary>
        private void PreValue(PriceFactorList factors)
        {
            var deal = (CalendarSpreadOption)Deal;

            // Get forward price samples.
            fForwardSample = factors.Get <ForwardPriceSample>(deal.Sampling_Type);

            // Get ReferencePrice price factors.
            fReferencePrice1 = factors.GetInterface <IReferencePrice>(deal.Reference_Type);
            fReferencePrice2 = factors.GetInterface <IReferencePrice>(deal.Reference_Type);

            // Get ReferenceVol price factors.
            // Default to Reference Type if Reference Vol Type is not set.
            if (string.IsNullOrEmpty(deal.Reference_Vol_Type))
            {
                fReferenceVol1 = factors.Get <ReferenceVol>(deal.Reference_Type);
                fReferenceVol2 = factors.Get <ReferenceVol>(deal.Reference_Type);
            }
            else
            {
                fReferenceVol1 = factors.Get <ReferenceVol>(deal.Reference_Vol_Type);
                fReferenceVol2 = factors.Get <ReferenceVol>(deal.Reference_Vol_Type);
            }

            // Get correlation price factor based on the ID of the forward price.
            fCorrelations = factors.Get <ForwardPriceCorrelations>(fReferencePrice1.GetForwardPrice());

            // Get FX rate price factors.
            fFxRate            = factors.GetInterface <IFxRate>(deal.Currency);
            fFxPayoffRate      = factors.GetInterface <IFxRate>(deal.DealCurrency());
            fPriceFactorFxRate = factors.GetInterface <IFxRate>(fReferencePrice1.DomesticCurrency());

            // Get discount rate price factor.
            fDiscountRate = factors.GetInterface <IInterestRate>(InterestRateUtils.GetRateId(deal.Discount_Rate, deal.Currency));
        }
コード例 #2
0
        /// <summary>
        /// Returns the energy option pricer.
        /// </summary>
        protected virtual EnergySpreadOptionPricer GetEnergyOptionPricer(ForwardPriceSample forwardSample, IReferencePrice referencePrice, ReferenceVol referenceVol, double baseDate, double tExpiry, double periodStart, double periodEnd, double realisedAverage, TDate realisedAverageDate, VectorScopedCache.Scope cache)
        {
            // Price samples
            List <TDate> priceSamples = forwardSample.GetSamplesList(periodStart, periodEnd).ToList();

            return(new EnergySpreadOptionPricer(
                       baseDate,
                       tExpiry,
                       priceSamples,
                       forwardSample.Offset,
                       realisedAverage,
                       realisedAverageDate,
                       referencePrice,
                       referenceVol,
                       fFxRate,
                       fPriceFactorFxRate,
                       fFxPayoffRate,
                       cache));
        }