public static string eqIRCurveLiborBasisSwapHelper( [ExcelArgument(Description = "(String) id of rate helper object ")] String ObjectId, [ExcelArgument(Description = "(String) base leg (usually USDLIB3M) ")] String baseLeg, [ExcelArgument(Description = "(String) basis leg (USDLIB1M, USDLIB6M, etc) ")] String basisLeg, [ExcelArgument(Description = "(double) basis spread ")] double basis, [ExcelArgument(Description = "(String) basis swap tenor (1Y, 2Y, etc) ")] String tenor, [ExcelArgument(Description = "Discount Curve (USDLIB3M or USDOIS) ")] String discount, [ExcelArgument(Description = "trigger ")] object trigger) { if (ExcelUtil.CallFromWizard()) { return(""); } string callerAddress = ExcelUtil.getActiveCellAddress(); try { // use default value. Eonia and ois has same convention if (!baseLeg.Contains('@')) { baseLeg = "IDX" + baseLeg; } EliteQuant.IborIndex baseidx = OHRepository.Instance.getObject <EliteQuant.IborIndex>(baseLeg); EliteQuant.IborIndex basisidx = null; switch (basisLeg.ToUpper()) { case "USDLIB1M": basisidx = new EliteQuant.USDLibor(new EliteQuant.Period(1, EliteQuant.TimeUnit.Months)); break; case "USDLIB6M": basisidx = new EliteQuant.USDLibor(new EliteQuant.Period(6, EliteQuant.TimeUnit.Months)); break; case "USDLIB12M": basisidx = new EliteQuant.USDLibor(new EliteQuant.Period(12, EliteQuant.TimeUnit.Months)); break; default: break; } EliteQuant.YieldTermStructure curve = null; EliteQuant.YieldTermStructureHandle yth = null; if (!discount.Contains('@')) { discount = "CRV@" + discount; } if (!ExcelUtil.isNull(discount)) { curve = OHRepository.Instance.getObject <EliteQuant.YieldTermStructure>(discount); yth = new EliteQuant.YieldTermStructureHandle(curve); } EliteQuant.QuoteHandle basis_ = new EliteQuant.QuoteHandle(new EliteQuant.SimpleQuote(basis)); EliteQuant.Period tenor_ = EliteQuant.EQConverter.ConvertObject <EliteQuant.Period>(tenor); // arithmetic average, not compounded. USBG EliteQuant.RateHelper rh = new EliteQuant.IBORBasisRateHelper(2, tenor_, basis_, baseidx, basisidx, yth); string id = "RHBAS@" + ObjectId; OHRepository.Instance.storeObject(id, rh, callerAddress); return(id + "#" + DateTime.Now.ToString("HH:mm:ss")); } catch (Exception e) { ExcelUtil.logError(callerAddress, System.Reflection.MethodInfo.GetCurrentMethod().Name.ToString(), e.Message); return("#EQ_ERR!"); } }
public static string eqIRCurveSwapRateHelper( [ExcelArgument(Description = "(String) id of rate helper object ")] String ObjectId, [ExcelArgument(Description = "(double) quote of swap rate ")] double quote, [ExcelArgument(Description = "(String) forward start month, e.g. 7D, 3M ")] String Tenor, [ExcelArgument(Description = " spread ")] double spread, [ExcelArgument(Description = " name of swap curve(USDLIB3M, USDLIB1M, USDLIB6M, USDLIB12M) ")] string idx, [ExcelArgument(Description = " id of discount curve (USDOIS) ")] string discount, [ExcelArgument(Description = "trigger ")] object trigger) { if (ExcelUtil.CallFromWizard()) { return(""); } string callerAddress = ExcelUtil.getActiveCellAddress(); try { // use default value EliteQuant.IborIndex idx_usdlibor = null; EliteQuant.QuoteHandle rate_ = new EliteQuant.QuoteHandle(new EliteQuant.SimpleQuote(quote)); EliteQuant.Period tenor_ = EliteQuant.EQConverter.ConvertObject <EliteQuant.Period>(Tenor); if (ExcelUtil.isNull(spread)) { spread = 0.0; } EliteQuant.QuoteHandle spread_ = new EliteQuant.QuoteHandle(new EliteQuant.SimpleQuote(spread)); EliteQuant.RateHelper rh = null; if (ExcelUtil.isNull(idx)) { idx_usdlibor = new EliteQuant.USDLibor(new EliteQuant.Period(3, EliteQuant.TimeUnit.Months)); } else { switch (idx) { case "USDLIB1M": idx_usdlibor = new EliteQuant.USDLibor(new EliteQuant.Period(1, EliteQuant.TimeUnit.Months)); break; case "USDLIB6M": idx_usdlibor = new EliteQuant.USDLibor(new EliteQuant.Period(6, EliteQuant.TimeUnit.Months)); break; case "USDLIB12M": idx_usdlibor = new EliteQuant.USDLibor(new EliteQuant.Period(12, EliteQuant.TimeUnit.Months)); break; default: idx_usdlibor = new EliteQuant.USDLibor(new EliteQuant.Period(3, EliteQuant.TimeUnit.Months)); break; } } if (ExcelUtil.isNull(discount)) { rh = new EliteQuant.SwapRateHelper(rate_, tenor_, cal_usd_gbp, EliteQuant.Frequency.Semiannual, bdc_usd, dc_30_360, idx_usdlibor); } else { if (!discount.Contains('@')) { discount = "CRV@" + discount; } EliteQuant.YieldTermStructure curve = OHRepository.Instance.getObject <EliteQuant.YieldTermStructure>(discount); EliteQuant.YieldTermStructureHandle yth = new EliteQuant.YieldTermStructureHandle(curve); rh = new EliteQuant.SwapRateHelper(rate_, tenor_, cal_usd_gbp, EliteQuant.Frequency.Semiannual, bdc_usd, dc_30_360, idx_usdlibor, spread_, new EliteQuant.Period(0, EliteQuant.TimeUnit.Days), yth); } string id = "RHSWP@" + ObjectId; OHRepository.Instance.storeObject(id, rh, callerAddress); return(id + "#" + DateTime.Now.ToString("HH:mm:ss")); } catch (Exception e) { ExcelUtil.logError(callerAddress, System.Reflection.MethodInfo.GetCurrentMethod().Name.ToString(), e.Message); return("#EQ_ERR!"); } }