public void SetResultToCurrentState()
 {
     if (AreDatesLinked)
     {
         Result = new InventoryEntry(SelectedItemType,
                                     Enumerable.Repeat(ExpiryDates.First().DateTimeOffset.DateTime, SelectedCountIndex + 1));
     }
     else
     {
         Result = new InventoryEntry(SelectedItemType, ExpiryDates.Select(x => x.DateTimeOffset.DateTime));
     }
 }
Пример #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PriceableSimpleIRCap"/> class.
        /// </summary>
        /// <param name="baseDate">The base date.</param>
        /// <param name="interestRateCap">An interest Rate Cap.</param>
        /// <param name="properties">THe properies, including strike information.</param>
        /// <param name="fixingCalendar">The fixing Calendar.</param>
        /// <param name="paymentCalendar">The payment Calendar.</param>
        /// <param name="marketQuotes">The market Quote: premium, normal flat volatility or lognormal flat volatility.</param>
        public PriceableSimpleIRCap(DateTime baseDate, SimpleIRCapNodeStruct interestRateCap, NamedValueSet properties,
                                    IBusinessCalendar fixingCalendar, IBusinessCalendar paymentCalendar, BasicAssetValuation marketQuotes)
            : base(baseDate, interestRateCap.DateAdjustments, ReversePeriodMultiplier(interestRateCap.SpotDate), interestRateCap.Calculation, marketQuotes)
        {
            Id          = interestRateCap.SimpleIRCap.id;
            IsCap       = true;
            SimpleIRCap = interestRateCap.SimpleIRCap;
            var spotDate = GetSpotDate(baseDate, fixingCalendar, interestRateCap.SpotDate);

            if (SimpleIRCap != null)
            {
                var unadjustedDates =
                    Analytics.Schedulers.DateScheduler.GetUnadjustedDateSchedule(spotDate, SimpleIRCap.term,
                                                                                 SimpleIRCap.paymentFrequency);
                AdjustedPeriodDates = AdjustedDateScheduler.GetAdjustedDateSchedule(unadjustedDates,
                                                                                    PaymentBusinessDayAdjustments.businessDayConvention, paymentCalendar);
                //Adjust for the spot period backwards!
                ExpiryDates = AdjustedDateScheduler.GetAdjustedDateSchedule(AdjustedPeriodDates,
                                                                            FixingBusinessDayOffset, fixingCalendar);
                //Remove the last date, which is not an expiry date.
                ExpiryDates.RemoveAt(ExpiryDates.Count - 1);
                TimesToExpiry = GetTimesToExpiry(ExpiryDates, baseDate);
                //Set the strike scalar. This must be after the number of expiry dates has been set.
                var quotes = new List <BasicQuotation>(marketQuotes.quote);
                //For the default cap the spot rate is used.
                SetQuote("SpotRate", quotes);
                //If the strike is not provided it must be calculated!!
                SetQuote("Strike", quotes);
                //Set the spot date.
                AdjustedStartDate = AdjustedPeriodDates[0];
                RiskMaturityDate  = ExpiryDates[ExpiryDates.Count - 1];
                OptionsExpiryDate = ExpiryDates[ExpiryDates.Count - 1];
                if (Strike != null && Strikes == null)
                {
                    Strikes = CreateList((decimal)Strike, TimesToExpiry.Count);
                }
                if (Notionals == null)
                {
                    Notionals = CreateList(InitialNotional, TimesToExpiry.Count);
                }
            }
            if (ExpiryDates[0] <= BaseDate)
            {
                IncludeFirstPeriod = false;
            }
            if (DiscountingType != null)
            {
                ModelIdentifier = "DiscountCapAsset";
            }
        }
        public void GridView_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            int value     = Convert.ToInt32(((GridViewItem)e.AddedItems.FirstOrDefault()).Content);
            var dateTimes = new List <DateTimeOffsetWrapper>(value);

            for (int i = 0; i < value; i++)
            {
                dateTimes.Add(new DateTimeOffsetWrapper {
                    DateTimeOffset = DateTime.Today
                });
            }

            using (ExpiryDates.SuspendCount())
                using (ExpiryDates.SuspendNotifications())
                {
                    ExpiryDates.Clear();
                    ExpiryDates.AddRange(dateTimes);
                }
        }