Esempio n. 1
0
 public void AutocallableKnockInBarrierRipperWorks()
 {
     foreach (var testPair in _testFilePathAndKnockInBarrierDictionary)
     {
         string             testFilePath           = testPair.Key;
         string             textToParse            = GeneralUtils.GetStringFromTextFile(testFilePath);
         AutocallableRipper ripper                 = DealRipperFactory.GetAutocallableRipper(textToParse);
         double             expectedKnockInBarrier = testPair.Value;
         double             rippedKnockInBarrier   = ripper.GetKnockInBarrier();
         Assert.AreEqual(expectedKnockInBarrier, rippedKnockInBarrier);
     }
 }
Esempio n. 2
0
        protected virtual void parse(AutocallableContainer container, AutocallableRipper ripper)
        {
            base.parse(container, ripper);
            DateTime [] couponObservationDates;
            try
            {
                DateTime [] callObservationDates = ripper.GetCallObservationDates();
                container.CallObservationDates = callObservationDates;
                try
                {
                    couponObservationDates           = ripper.GetCouponObservationDates();
                    container.CouponObservationDates = couponObservationDates;
                }
                catch
                {
                    string warning = "Unable to extract coupon observation dates on their own so " +
                                     "assuming they are the same as the call observation dates.";
                    Debug.WriteLine(warning);
                    container.CouponObservationDates = callObservationDates;
                }
            }
            catch (DetailParsingException)
            {
                string warning = "Unable to extract call observation dates on their own so assuming " +
                                 "they are the same as the coupon observation dates.";
                Debug.WriteLine(warning);
                couponObservationDates           = ripper.GetCouponObservationDates();
                container.CouponObservationDates = couponObservationDates;
                container.CallObservationDates   = couponObservationDates;
            }
            container.CouponAmountPerPeriod = ripper.GetCouponPerPeriod();
            container.CouponBarrier         = ripper.GetCouponBarrier();
            double knockInBarrier = ripper.GetKnockInBarrier();

            // If the KI Barrier is less than one, it is likely that it represents a % amount.
            if (knockInBarrier < 1)
            {
                knockInBarrier = knockInBarrier * container.InitialUnderlyingLevel;
            }
            container.KnockInBarrier = knockInBarrier;
            // If we fail to rip the coupon frequency, we "swallow" the error because we can
            // ultimately determine it by the distance between coupon observation dates.
            try
            {
                if (ripper.CouponFrequency == null)
                {
                    container.CouponFrequency = ripper.GetCouponFrequency();
                }
                else
                {
                    container.CouponFrequency = ripper.CouponFrequency;
                }
            }
            catch (Exception) { }

            // If we failed to parse the Final Valuation Date on its own, then we set it equal to the last coupon
            // observation date
            if (container.FinalValuationDate.IsEmpty())
            {
                string warning = String.Format("Final Valuation Date empty in AutocallableFactory for " +
                                               "Cusip {0}. Therefore, assuming it is the final coupon " +
                                               "observation date.", container.Cusip);
                Debug.WriteLine(warning);
                container.FinalValuationDate = container.CouponObservationDates.Last();
            }
        }