コード例 #1
0
        public static object eqIRCurveLoadCurveFromDisk(
            [ExcelArgument(Description = "asofdate ")] DateTime asofdate,
            [ExcelArgument(Description = "Interpolation Method (Linear, LogLinear) ")] string interp,
            [ExcelArgument(Description = "trigger ")] object trigger)
        {
            if (ExcelUtil.CallFromWizard())
            {
                return("");
            }

            string callerAddress = "";

            callerAddress = ExcelUtil.getActiveCellAddress();

            try
            {
                Xl.Range rng = ExcelUtil.getActiveCellRange();
                if (ExcelUtil.isNull(asofdate))
                {
                    asofdate = DateTime.Today;
                }

                string[]             curves = new string[] { "USDOIS", "USDLIB3M", "USDLIB1M", "USDLIB6M", "USDLIB12M" };
                string               path;
                EliteQuant.IborIndex idx = new EliteQuant.USDLibor(new EliteQuant.Period(3, EliteQuant.TimeUnit.Months));

                foreach (var s in curves)
                {
                    string targetcurve;
                    if (s.Contains("@"))
                    {
                        targetcurve = s;
                    }
                    else
                    {
                        targetcurve = "CRV@" + s;
                    }

                    string interpmethod;
                    if (ExcelUtil.isNull(interp))
                    {
                        interpmethod = "LOGLINEAR";
                    }
                    else
                    {
                        interpmethod = interp.ToUpper();
                    }

                    path = EliteQuant.ConfigManager.Instance.IRRootDir + @"Curves\"
                           + EliteQuant.EQConverter.DateTimeToString(asofdate) + "\\";

                    string[] crv = System.IO.File.ReadAllLines(path + s + ".csv");

                    EliteQuant.DateVector   dtv   = new EliteQuant.DateVector();
                    EliteQuant.DoubleVector discv = new EliteQuant.DoubleVector();
                    foreach (var c in crv)
                    {
                        string[] cc = c.Split(',');
                        Date     dt = new Date(Convert.ToInt32(cc[0]));
                        dtv.Add(dt);
                        discv.Add(Convert.ToDouble(cc[1]));
                    }

                    YieldTermStructure yth = null;

                    if (interpmethod == "LINEAR")
                    {
                        yth = new EliteQuant.LinearDiscountCurve(dtv, discv, idx.dayCounter(), idx.fixingCalendar());
                    }
                    else
                    {
                        yth = new EliteQuant.DiscountCurve(dtv, discv, idx.dayCounter(), idx.fixingCalendar());
                    }

                    string targetcrvid = "CRV@" + s;
                    OHRepository.Instance.storeObject(targetcrvid, yth, callerAddress);     // callerAddress or null ?
                }

                return(asofdate);
            }
            catch (Exception e)
            {
                ExcelUtil.logError(callerAddress, System.Reflection.MethodInfo.GetCurrentMethod().Name.ToString(), e.Message);
                return(e.Message);
            }
        }