Example #1
0
        public void TestISMADirtyPrice1_1()
        {
            double accrualYearFraction = 297.0 / 365.0;

            int finalAccrualYearFraction = 0;

            int i = 8;

            double nextCoupon = 7.0;

            double next2Coupon = 7.0;

            double annualCoupon = 7.0;

            double finalCoupon = 0.0;

            int numberOfCouponPeriodsInAYear = 1;

            double ytm = .06;

            double discountFactorForOnePeriod = 1 / (1 + ytm / numberOfCouponPeriodsInAYear);

            var result = BondAnalytics.ISMADirtyPrice(accrualYearFraction,
                                                      finalAccrualYearFraction,
                                                      i,
                                                      nextCoupon,
                                                      next2Coupon,
                                                      annualCoupon, finalCoupon, numberOfCouponPeriodsInAYear, discountFactorForOnePeriod, ytm);

            Debug.WriteLine(String.Format("dirty price : {0}", result));
        }
Example #2
0
 /// <summary>
 /// Calculates the ISMA dirty bond price.
 /// </summary>
 /// <param name="accrualYearFraction">The first accrual coupon year fraction.</param>
 /// <param name="finalAccrualYearFraction">The final coupon year fraction. If regular this is zero.</param>
 /// <param name="numberOfFullCoupons">The number of full coupon periods remaining until redemption.
 /// The number of remaining coupon periods is therefore n+1;</param>
 /// <param name="nextCoupon">The next coupon payment. This may be partial or zero if the bond is trading ex div.</param>
 /// <param name="next2Coupon">The next 2 coupon.</param>
 /// <param name="annualCoupon">The annual coupon payment for 100 unit of face value.</param>
 /// <param name="finalCoupon">The final coupon with an odd final period. This is zero for all other bonds.</param>
 /// <param name="couponsPerYear">The number of coupon periods in a year.</param>
 /// <param name="periodDiscountFactor">The discount factor for one period, v = 1/(1+y/h)</param>
 /// <param name="annualYield">The required annual nominal redemption yield expressed as a decimal.</param>
 /// <returns>Te dirty price according to ISMA convention.</returns>
 public double ISMADirtyPrice(double accrualYearFraction, double finalAccrualYearFraction, int numberOfFullCoupons,
                              double nextCoupon, double next2Coupon, double annualCoupon, double finalCoupon, int couponsPerYear,
                              double periodDiscountFactor, double annualYield)
 {
     return(BondAnalytics.ISMADirtyPrice(accrualYearFraction, finalAccrualYearFraction, numberOfFullCoupons,
                                         nextCoupon, next2Coupon, annualCoupon, finalCoupon, couponsPerYear, periodDiscountFactor, annualYield));
 }
Example #3
0
        public void TestISMADirtyPrice0()
        {
            //var ytm = BondAnalytics.CalculateBondYTM(DateTime.Parse("15/05/13"), DateTime.Parse("15/11/08"),
            //.065, 2, 100, 113.27); 3.75-TYM
            //sorry should be around 3.7%
            DateTime matDate        = DateTime.Parse("15/05/13");
            DateTime lastCouponDate = DateTime.Parse("15/11/08");

            var couponRate = .065;

            double accrualYearFraction = (DateTime.Today - lastCouponDate).TotalDays / 365;

            //int finalAccrualYearFraction = 0;
            double finalAccrualYearFraction = 0.5 - accrualYearFraction;

            int numberOfCouponPeriodsInAYear = 2;

            //int i = (int)((matDate - lastCouponDate).TotalDays / 365) * numberOfCouponPeriodsInAYear;
            int i = 8;


            double nextCoupon = couponRate * 100 / numberOfCouponPeriodsInAYear;
            //double nextCoupon = 0;

            double next2Coupon = couponRate * 100 / numberOfCouponPeriodsInAYear;

            //double annualCoupon = couponRate * 100 / numberOfCouponPeriodsInAYear;
            double annualCoupon = couponRate * 100;

            //double finalCoupon = 0.0;
            double finalCoupon = couponRate * 100 * finalAccrualYearFraction;

            //double ytm = .037;
            double ytm = .037;

            double discountFactorForOnePeriod = 1 / (1 + ytm / numberOfCouponPeriodsInAYear);

            var result = BondAnalytics.ISMADirtyPrice(accrualYearFraction,
                                                      finalAccrualYearFraction,
                                                      i,
                                                      nextCoupon,
                                                      next2Coupon,
                                                      annualCoupon, finalCoupon, numberOfCouponPeriodsInAYear, discountFactorForOnePeriod, ytm);

            Debug.WriteLine(String.Format("dirty price : {0}", result));
        }
Example #4
0
        public void TestISMADirtyPrice3()
        {
            var result = BondAnalytics.ISMADirtyPrice(2.0 / 365.0, 0, 8, 7.0, 7.0, 7.0, 0.0, 1, 1 / (1.07), .07);

            Debug.WriteLine(String.Format("dirty price : {0}", result));
        }
Example #5
0
        public void TestISMADirtyPrice2()//On coupon date, but ex div.
        {
            var result = BondAnalytics.ISMADirtyPrice(0.0, 0, 8, 0.0, 7.0, 7.0, 0.0, 1, 1 / (1.07), .07);

            Debug.WriteLine(String.Format("dirty price : {0}", result));
        }
Example #6
0
        public void TestISMADirtyPrice1()
        {
            var result = BondAnalytics.ISMADirtyPrice(297.0 / 365.0, 0, 8, 7.0, 7.0, 7.0, 0.0, 1, .9434, .06);

            Debug.WriteLine(String.Format("dirty price : {0}", result));
        }