//------------------------------------------------------------------------------------------------
        private DiscountFactors getDFfromOTAsOfDatetime(DateTime dt, string curvename)
        //------------------------------------------------------------------------------------------------
        {

            TimeZone zone = TimeZone.CurrentTimeZone;
            DiscountFactors disc = null;
            DateTime utcTime = zone.ToUniversalTime(dt);
            DateTime curveStamp = (dt + (dt - utcTime)).AddHours(-1.1).AddDays(1); // Add a day to treat before T+1 midnight as T's close. Adjust to pick up the snap before 00:01

            var curves = m_carbonClient.GetInterestCurvesAsync(m_ccy, curvename, curveStamp);

            if (curves.Result == null || curves.Result.Count() == 0)
            {
                return disc;
            }

            var curve = curves.Result.First(); // Should only be one curve here

           // m_Log.InfoFormat(curve);
            var points = curve.Points.FirstOrDefault();
            if (points != null)
            {
                int N = points.CurvePoints.Count();
                DateTime[] curveDates = new DateTime[N+1];
                double[] curveDFs = new double[N+1];
                var curvePointList = points.CurvePoints.ToList();


                // Add the first discount factor of 1, consistent with the fincad format
                curveDates[0] = dt;
                curveDFs[0] = 1;

                // Assign build resuts to dates/DFs
                for (int k = 0; k < N; ++k)
                {
                    var curveDate = curvePointList[k].Date.ToDateTime();
                    var curveDF = curvePointList[k].Df;

                    curveDates[k+1] = curveDate;
                    curveDFs[k+1] = curveDF;
                }


                // Assign outputs
                disc = new DiscountFactors(curveDates, curveDFs);
            }

            if (disc != null)
            {
                //disc.PrintCurve();
            }
            else
            {
                m_Log.InfoFormat("No curve points on {0}", dt);
            }
            return disc;
        }
            tuples2DiscountFactors(SortedDictionary<DateTime, Tuple<DateTime, double>[]> inputs)
        //------------------------------------------------------------------------------------------------
        {
            SortedDictionary<DateTime, DiscountFactors> outputs = new SortedDictionary<DateTime, DiscountFactors>();
            foreach (var kvp in inputs)
            {
                DateTime dte = kvp.Key;
                Tuple<DateTime, double>[] input = kvp.Value;
                outputs[dte] = new DiscountFactors(input);
            }

            return outputs;
        }