Exemple #1
0
        public void FuturesImpliedQuoteFromMarginAdjustedWithArrearsTest()
        {
            decimal actual = FuturesAnalytics.FuturesImpliedQuoteFromMarginAdjustedWithArrears(0.055m, 3, 0.25, 0.2);

            Assert.AreEqual(0.0550820401094303d, (double)actual, 0.000000001);

            actual = FuturesAnalytics.FuturesImpliedQuoteFromMarginAdjustedWithArrears(0.055m, 3, 0, 0.2);
            Assert.AreEqual(0.055m, actual);
        }
        /// <summary>
        /// Evaluates the implied quote.
        /// </summary>
        /// <returns></returns>
        private Decimal EvaluateImpliedQuote()
        {
            decimal impliedRate = EvaluateImpliedRate();
            var     result      = FuturesAnalytics.FuturesImpliedQuoteFromMarginAdjustedWithArrears(impliedRate,
                                                                                                    (double)AnalyticParameters.YearFraction,
                                                                                                    (double)AnalyticParameters.TimeToExpiry,
                                                                                                    (double)AnalyticParameters.Volatility);

            return(result);
        }
Exemple #3
0
 /// <summary>
 /// Evaluates the implied quote.
 /// </summary>
 /// <returns></returns>
 private Decimal EvaluateImpliedQuote()
 {
     try
     {
         var result = FuturesAnalytics.FuturesImpliedQuoteFromMarginAdjustedWithArrears(EvaluateImpliedRate(),
                                                                                        (double)AnalyticParameters.YearFraction,
                                                                                        (double)AnalyticParameters.TimeToExpiry,
                                                                                        (double)AnalyticParameters.Volatility);
         return(result);
     }
     catch
     {
         throw new System.Exception("Real solution does not exist");
     }
 }
 /// <summary>
 /// Evaluates the implied quote.
 /// </summary>
 /// <returns></returns>
 private Decimal EvaluateImpliedQuote()//TODo the aqdjustment needs to be at the rate, not the implied rate.
 {
     try
     {
         var result = FuturesAnalytics.FuturesImpliedQuoteFromMarginAdjustedWithArrears(EvaluateImpliedRate(),
                                                                                        (double)AnalyticParameters.YearFraction,
                                                                                        (double)AnalyticParameters.TimeToExpiry,
                                                                                        (double)AnalyticParameters.Volatility);
         return(result);
     }
     catch
     {
         throw new Exception("Real solution does not exist");
     }
 }
Exemple #5
0
        public void TestFuturesMarginWithArrearsConvexityAdjustment()
        {
            for (var i = 0; i < 10; i++)
            {
                var rate   = (decimal)(50 + i);
                var cvt    = FuturesAnalytics.FuturesMarginWithArrearsConvexityAdjustment(rate / 1000, 0.25, 3.0, .2);
                var result = FuturesAnalytics.FuturesImpliedQuoteFromMarginAdjustedWithArrears(rate / 1000 - cvt, 0.25, 3.0, .2);
                Debug.WriteLine(String.Format("rate : {0} convexity: {1} implied: {2}", rate / 1000, cvt * 10000, result));
            }
            decimal actual = FuturesAnalytics.FuturesMarginWithArrearsConvexityAdjustment(0.055m, 0.25, 3d, 0.2);

            Assert.AreEqual(0.0005720703761657d, (double)actual, 0.000000001);

            actual = FuturesAnalytics.FuturesMarginWithArrearsConvexityAdjustment(0.055m, 0.25, 0, 0.2);
            Assert.AreEqual(0, actual);
        }
Exemple #6
0
        public void FuturesImpliedQuoteFromMarginAdjustedTest()
        {
            for (var i = 0; i < 10; i++)
            {
                decimal rate                = 50 + i;
                decimal adjustedRate        = FuturesAnalytics.FuturesImpliedQuoteFromMarginAdjusted(rate / 1000, 3.0, .2);
                decimal arrearsAdjustedRate = FuturesAnalytics.FuturesImpliedQuoteWithArrears(adjustedRate, 0.25, 3.0, .2);
                decimal cvt = FuturesAnalytics.FuturesImpliedQuoteFromMarginAdjustedWithArrears(arrearsAdjustedRate, 3.0, 0.25, .2);
                Assert.AreEqual((double)rate / 1000, (double)cvt, 0.01);
                Debug.WriteLine(String.Format("rate : {0} adjustedRate: {1} arrearsAdjustedRate: {2} cvt: {3}", rate / 1000, adjustedRate, arrearsAdjustedRate, cvt));
            }

            decimal actual = FuturesAnalytics.FuturesImpliedQuoteFromMarginAdjusted(0.055m, 3, 0.2);

            Assert.AreEqual(0.055486651d, (double)actual, 0.000000001);

            actual = FuturesAnalytics.FuturesImpliedQuoteFromMarginAdjusted(0.055m, 0, 0.2);
            Assert.AreEqual(0.055m, actual);
        }
Exemple #7
0
 /// <summary>
 /// Evaluates the implied futures quote from a provided convexity adjusted forward.
 /// </summary>
 /// <param name="impliedRate"></param>
 /// <param name="timeToExpiry"></param>
 /// <param name="yearFraction"></param>
 /// <param name="volatility"></param>
 /// <returns></returns>
 public decimal FuturesImpliedQuoteFromMarginAdjustedWithArrears(decimal impliedRate, double yearFraction, double timeToExpiry, double volatility)
 {
     return(FuturesAnalytics.FuturesImpliedQuoteFromMarginAdjustedWithArrears(impliedRate, yearFraction, timeToExpiry, volatility));
 }