Exemple #1
0
        public static ITreeAddInventoryGridCalculation <T> WithAct365ContinuouslyCompoundedInterestRateCurve <T>(
            [NotNull] this ITreeAddDiscountFactorFunc <T> addDiscountFactorFunc, TimeSeries <Day, double> act365ContCompInterestRates)
            where T : ITimePeriod <T>
        {
            if (addDiscountFactorFunc == null)
            {
                throw new ArgumentNullException(nameof(addDiscountFactorFunc));
            }

            double DiscountFactor(Day presentDay, Day cashFlowDay)
            {
                if (cashFlowDay <= presentDay)
                {
                    return(1.0);
                }
                if (!act365ContCompInterestRates.ContainsKey(cashFlowDay))
                {
                    throw new ArgumentException("Interest rate curves does not contain point for date " + cashFlowDay);
                }

                double interestRate = act365ContCompInterestRates[cashFlowDay];

                return(Math.Exp(-cashFlowDay.OffsetFrom(presentDay) / 365.0 * interestRate));
            }

            return(addDiscountFactorFunc.WithDiscountFactorFunc(DiscountFactor));
        }
Exemple #2
0
        public static ITreeAddInventoryGridCalculation <T> WithAct365ContinuouslyCompoundedInterestRate <T>(
            [NotNull] this ITreeAddDiscountFactorFunc <T> addDiscountFactorFunc, Func <Day, double> act365ContCompInterestRates)
            where T : ITimePeriod <T>
        {
            if (addDiscountFactorFunc == null)
            {
                throw new ArgumentNullException(nameof(addDiscountFactorFunc));
            }
            Func <Day, Day, double> discounter = StorageHelper.CreateAct65ContCompDiscounter(act365ContCompInterestRates);

            return(addDiscountFactorFunc.WithDiscountFactorFunc(discounter));
        }