Ejemplo n.º 1
0
 /// <summary>
 /// Evaluates the implied quote.
 /// </summary>
 /// <returns></returns>
 private Decimal EvaluateConvexityAdjustment(Decimal rate)
 {
     return(FuturesAnalytics.FuturesMarginWithArrearsConvexityAdjustment(rate,
                                                                         (double)AnalyticParameters.YearFraction,
                                                                         (double)AnalyticParameters.TimeToExpiry,
                                                                         (double)AnalyticParameters.Volatility));
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Evaluates the implied quote.
        /// </summary>
        /// <returns></returns>
        private Decimal EvaluateImpliedQuote()
        {
            var impliedRate = EvaluateImpliedRate();
            var result      = FuturesAnalytics.FuturesImpliedQuoteFromMarginAdjusted(impliedRate,
                                                                                     (double)AnalyticParameters.TimeToExpiry, (double)AnalyticParameters.Volatility);

            return(result);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
        public void FuturesImpliedQuoteWithArrearsTest()
        {
            decimal actual = FuturesAnalytics.FuturesImpliedQuoteWithArrears(0.055m, 3, 0.25, 0.2);

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

            actual = FuturesAnalytics.FuturesImpliedQuoteWithArrears(0.055m, 3, 0, 0.2);
            Assert.AreEqual(0.055m, actual);
        }
Ejemplo n.º 5
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");
     }
 }
Ejemplo n.º 7
0
 ///<summary>
 ///</summary>
 ///<param name="futuresPrice"></param>
 ///<param name="absoluteVol"></param>
 ///<param name="meanReversion"></param>
 ///<param name="valueDate"></param>
 ///<param name="expiryMonthYear"></param>
 ///<param name="xlHolidays"></param>
 ///<returns></returns>
 public double CMEConvexityAdjustment(double futuresPrice, double absoluteVol, double meanReversion, DateTime valueDate, DateTime expiryMonthYear, [Optional] Excel.Range xlHolidays)
 {
     object[,] values = xlHolidays.get_Value(System.Reflection.Missing.Value) as object[, ];
     object[,] holidays;
     if (values.GetType().Name == "Missing")
     {
         holidays       = new Object[1, 1];
         holidays[0, 0] = new DateTime(1, 1, 1);
     }
     else
     {
         holidays = ArrayHelper.RangeToMatrix(values);
     }
     return(FuturesAnalytics.CMEConvexityAdjustment(futuresPrice, absoluteVol, meanReversion, valueDate, expiryMonthYear, holidays));
 }
Ejemplo n.º 8
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);
        }
Ejemplo n.º 9
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);
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Evaluates the implied futures quote from a provided convexity adjusted forward.
 /// This currently only works for margined futures without an arrears adjustment.
 /// </summary>
 /// <param name="impliedRate"></param>
 /// <param name="timeToExpiry"></param>
 /// <param name="volatility"></param>
 /// <returns></returns>
 public decimal FuturesImpliedQuoteFromMarginAdjusted(decimal impliedRate, double timeToExpiry, double volatility)
 {
     return(FuturesAnalytics.FuturesImpliedQuoteFromMarginAdjusted(impliedRate, timeToExpiry, volatility));
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Evaluates the implied quote.
 /// </summary>
 /// <param name="rate"></param>
 /// <param name="timeToExpiry"></param>
 /// <param name="volatility"></param>
 /// <returns></returns>
 public decimal FuturesMarginConvexityAdjustment(decimal rate, double timeToExpiry, double volatility)
 {
     return(FuturesAnalytics.FuturesMarginConvexityAdjustment(rate, timeToExpiry, volatility));
 }
Ejemplo n.º 12
0
 ///<summary>
 ///</summary>
 ///<param name="contract"></param>
 ///<param name="futuresPrice"></param>
 ///<returns></returns>
 public double NZSFEBondTickValue(string contract, double futuresPrice)
 {
     contract = contract.ToUpper();
     return(FuturesAnalytics.NZSFEBondTickValue(contract, futuresPrice));
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Evaluates the implied futures quote from a provided convexity adjusted forward.
 /// This currently only works for margined futures without an arrears adjustment.
 /// </summary>
 /// <param name="impliedRate"></param>
 /// <param name="yearFraction"></param>
 /// <param name="timeToExpiry"></param>
 /// <param name="volatility"></param>
 /// <returns></returns>
 public Decimal FuturesImpliedQuoteWithArrears(Decimal impliedRate, double yearFraction, double timeToExpiry, double volatility)
 {
     return(FuturesAnalytics.FuturesImpliedQuoteWithArrears(impliedRate, yearFraction, timeToExpiry, volatility));
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Evaluates the implied quote.
 /// </summary>
 /// <returns></returns>
 private Decimal EvaluateConvexityAdjustment()
 {
     return(FuturesAnalytics.FuturesMarginConvexityAdjustment(AnalyticParameters.Rate,
                                                              (double)AnalyticParameters.TimeToExpiry, (double)AnalyticParameters.Volatility));
 }
Ejemplo n.º 15
0
 ///<summary>
 ///</summary>
 ///<param name="futuresPrice"></param>
 ///<returns></returns>
 public double SFEBillTickValue(double futuresPrice)
 {
     return(FuturesAnalytics.SFEBillTickValue(futuresPrice));
 }
Ejemplo n.º 16
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));
 }
Ejemplo n.º 17
0
 /// <summary>
 /// Evaluates the futures arrears convexity adjustment.
 /// </summary>
 /// <param name="rate"></param>
 /// <param name="yearFraction"></param>
 /// <param name="timeToExpiry"></param>
 /// <param name="volatility"></param>
 /// <returns></returns>
 public decimal FuturesMarginWithArrearsConvexityAdjustment(decimal rate, double yearFraction, double timeToExpiry, double volatility)
 {
     return(FuturesAnalytics.FuturesMarginWithArrearsConvexityAdjustment(rate, yearFraction, timeToExpiry, volatility));
 }
Ejemplo n.º 18
0
 ///<summary>
 ///</summary>
 ///<param name="contract"></param>
 ///<param name="futuresPrice"></param>
 ///<returns></returns>
 public double SFEBondPrice(string contract, double futuresPrice)
 {
     contract = contract.ToUpper();
     return(FuturesAnalytics.SFEBondPrice(contract, futuresPrice));
 }