public static object eqCurveCommodForwardPrice( [ExcelArgument(Description = "index id ")] string ObjectId, [ExcelArgument(Description = "forward date ")] DateTime date, [ExcelArgument(Description = "trigger ")] object trigger) { if (ExcelUtil.CallFromWizard()) { return(""); } string callerAddress = ExcelUtil.getActiveCellAddress(); try { if (!ObjectId.Contains('@')) { ObjectId = "IDX@" + ObjectId; } CommodityIndexExt idx = OHRepository.Instance.getObject <CommodityIndexExt>(ObjectId); Date dt = EliteQuant.EQConverter.ConvertObject <Date>(date); // double price = idx.price(dt); double price = idx.forwardPrice(dt); return(price); } catch (Exception e) { ExcelUtil.logError(callerAddress, System.Reflection.MethodInfo.GetCurrentMethod().Name.ToString(), e.Message); return("#EQ_ERR!"); } }
public EnergyVanillaSwapExt(bool payer, double fixedPrice, CommodityIndexExt index, PricingPeriodExts PricingPeriodExts, string commodityName, YieldTermStructureHandle payLegTermStructure, YieldTermStructureHandle receiveLegTermStructure) : this(NQuantLibcPINVOKE.new_EnergyVanillaSwapExt__SWIG_2(payer, fixedPrice, CommodityIndexExt.getCPtr(index), PricingPeriodExts.getCPtr(PricingPeriodExts), commodityName, YieldTermStructureHandle.getCPtr(payLegTermStructure), YieldTermStructureHandle.getCPtr(receiveLegTermStructure)), true) { if (NQuantLibcPINVOKE.SWIGPendingException.Pending) { throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve(); } }
public static string eqCurveCommodIndex( [ExcelArgument(Description = "index id ")] string ObjectId, [ExcelArgument(Description = "index name ")] string indexname, [ExcelArgument(Description = "curve id ")] string curveId, [ExcelArgument(Description = "calendar")] string calendar, [ExcelArgument(Description = "trigger ")] object trigger) { if (ExcelUtil.CallFromWizard()) { return(""); } string callerAddress = ExcelUtil.getActiveCellAddress(); try { calendar = "NULL"; CommodityCurveExt curve = OHRepository.Instance.getObject <CommodityCurveExt>(curveId); CommodityIndexExt idx = new CommodityIndexExt(indexname, curve, new NullCalendar()); // Store the index and return its id string id = "IDX@" + ObjectId; OHRepository.Instance.storeObject(id, idx, callerAddress); id += "#" + (String)DateTime.Now.ToString(@"HH:mm:ss"); return(id); } catch (Exception e) { ExcelUtil.logError(callerAddress, System.Reflection.MethodInfo.GetCurrentMethod().Name.ToString(), e.Message); return("#EQ_ERR!"); } }
public RelinkableCommodityIndexExtHandle(CommodityIndexExt arg0) : this(NQuantLibcPINVOKE.new_RelinkableCommodityIndexExtHandle__SWIG_0(CommodityIndexExt.getCPtr(arg0)), true) { if (NQuantLibcPINVOKE.SWIGPendingException.Pending) { throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve(); } }
public EnergyBasisSwapExt(CommodityIndexExt payIndex, CommodityIndexExt receiveIndex, PricingPeriodExts PricingPeriodExts, string commodityName, YieldTermStructureHandle payLegTermStructure, YieldTermStructureHandle receiveLegTermStructure) : this(NQuantLibcPINVOKE.new_EnergyBasisSwapExt__SWIG_2(CommodityIndexExt.getCPtr(payIndex), CommodityIndexExt.getCPtr(receiveIndex), PricingPeriodExts.getCPtr(PricingPeriodExts), commodityName, YieldTermStructureHandle.getCPtr(payLegTermStructure), YieldTermStructureHandle.getCPtr(receiveLegTermStructure)), true) { if (NQuantLibcPINVOKE.SWIGPendingException.Pending) { throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve(); } }
public void linkTo(CommodityIndexExt arg0) { NQuantLibcPINVOKE.RelinkableCommodityIndexExtHandle_linkTo(swigCPtr, CommodityIndexExt.getCPtr(arg0)); if (NQuantLibcPINVOKE.SWIGPendingException.Pending) { throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve(); } }
public CommodityIndexExt index() { CommodityIndexExt ret = new CommodityIndexExt(NQuantLibcPINVOKE.EnergyFutureExt_index(swigCPtr), true); if (NQuantLibcPINVOKE.SWIGPendingException.Pending) { throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public CommodityIndexExt __deref__() { CommodityIndexExt ret = new CommodityIndexExt(NQuantLibcPINVOKE.CommodityIndexExtHandle___deref__(swigCPtr), true); if (NQuantLibcPINVOKE.SWIGPendingException.Pending) { throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public static object eqInstCommodityFuture( [ExcelArgument(Description = "id of instrument ")] string ObjectId, [ExcelArgument(Description = "name of instrument ")] string name, // given by user, could be the same as objectid [ExcelArgument(Description = "buy/sell (1/-1) ")] int buysell, [ExcelArgument(Description = "trade price ")] double tradePrice, [ExcelArgument(Description = "trade quantity ")] double quantity, [ExcelArgument(Description = "start date ")] DateTime startdate, [ExcelArgument(Description = "end date ")] DateTime enddate, [ExcelArgument(Description = "id of commodity index ")] string indexid, [ExcelArgument(Description = "id of discount curve ")] string discountId, [ExcelArgument(Description = "trigger ")] object trigger) { if (ExcelUtil.CallFromWizard()) { return(""); } string callerAddress = ""; callerAddress = ExcelUtil.getActiveCellAddress(); try { Xl.Range rng = ExcelUtil.getActiveCellRange(); CommodityIndexExt idx = OHRepository.Instance.getObject <CommodityIndexExt>(indexid); YieldTermStructureHandle discountcurve = OHRepository.Instance.getObject <YieldTermStructureHandle>(discountId); Date refDate = discountcurve.referenceDate(); EliteQuant.Date sd = EliteQuant.EQConverter.ConvertObject <EliteQuant.Date>(startdate); EliteQuant.Date ed = EliteQuant.EQConverter.ConvertObject <EliteQuant.Date>(enddate); PricingPeriodExt pp = new PricingPeriodExt(sd, ed, sd, quantity); // pay at start date EnergyFutureExt ef = new EnergyFutureExt(buysell, pp, tradePrice, idx, name, discountcurve); // Store the futures and return its id string id = "Fut@" + ObjectId; OHRepository.Instance.storeObject(id, ef, callerAddress); id += "#" + (String)DateTime.Now.ToString(@"HH:mm:ss"); return(id); } catch (Exception e) { ExcelUtil.logError(callerAddress, System.Reflection.MethodInfo.GetCurrentMethod().Name.ToString(), e.Message); return("#EQ_ERR!"); } }
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(CommodityIndexExt obj) { return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr); }
public EnergyFutureExt(int buySell, PricingPeriodExt PricingPeriodExt, double tradePrice, CommodityIndexExt index, string commodityName, YieldTermStructureHandle discountTermStructure) : this(NQuantLibcPINVOKE.new_EnergyFutureExt(buySell, PricingPeriodExt.getCPtr(PricingPeriodExt), tradePrice, CommodityIndexExt.getCPtr(index), commodityName, YieldTermStructureHandle.getCPtr(discountTermStructure)), true) { if (NQuantLibcPINVOKE.SWIGPendingException.Pending) { throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve(); } }
public static object eqInstCommodityVanillaSwap( [ExcelArgument(Description = "id of instrument ")] string ObjectId, [ExcelArgument(Description = "name of instrument ")] string name, [ExcelArgument(Description = "payer/receiver (1/0) ")] bool payer, [ExcelArgument(Description = "trade price ")] double fixedPrice, [ExcelArgument(Description = "trade quantity ")] double[] quantities, [ExcelArgument(Description = "start date ")] object[] startdates, [ExcelArgument(Description = "end date ")] object[] enddates, [ExcelArgument(Description = "id of commodity index ")] string indexid, [ExcelArgument(Description = "id of discount curve ")] string discountId, [ExcelArgument(Description = "trigger ")] object trigger) { if (ExcelUtil.CallFromWizard()) { return(""); } string callerAddress = ""; callerAddress = ExcelUtil.getActiveCellAddress(); try { //bool ispayer = string.Compare(payer.ToUpper(), "PAYER") == 0 ? true : false; bool ispayer = payer; if (startdates.Length != enddates.Length) { return("size mismatch"); } Xl.Range rng = ExcelUtil.getActiveCellRange(); CommodityIndexExt idx = OHRepository.Instance.getObject <CommodityIndexExt>(indexid); YieldTermStructureHandle discountcurve = OHRepository.Instance.getObject <YieldTermStructureHandle>(discountId); Date refDate = discountcurve.referenceDate(); PricingPeriodExts pps = new PricingPeriodExts(startdates.Length); for (int i = 0; i < startdates.Length; i++) { if (ExcelUtil.isNull(startdates[i])) { continue; } //EliteQuant.Date sd = Conversion.ConvertObject<EliteQuant.Date>((DateTime)startdates[i], "date"); //EliteQuant.Date ed = Conversion.ConvertObject<EliteQuant.Date>((DateTime)enddates[i], "date"); Date sd = new Date(Convert.ToInt32(startdates[i])); Date ed = new Date(Convert.ToInt32(enddates[i])); PricingPeriodExt pp = new PricingPeriodExt(sd, ed, sd, quantities[i]); pps.Add(pp); } EnergyVanillaSwapExt evs = new EnergyVanillaSwapExt(ispayer, fixedPrice, idx, pps, name, discountcurve, discountcurve, Frequency.Monthly, new NullCalendar()); // Store the futures and return its id string id = "Swp@" + ObjectId; OHRepository.Instance.storeObject(id, evs, callerAddress); id += "#" + (String)DateTime.Now.ToString(@"HH:mm:ss"); return(id); } catch (Exception e) { ExcelUtil.logError(callerAddress, System.Reflection.MethodInfo.GetCurrentMethod().Name.ToString(), e.Message); return("#EQ_ERR!"); } }
public static object eqInstCommodityBasisSwap( [ExcelArgument(Description = "id of instrument ")] string ObjectId, [ExcelArgument(Description = "name of instrument ")] string name, [ExcelArgument(Description = "trade quantity ")] double[] quantities, [ExcelArgument(Description = "start date ")] object[] startdates, [ExcelArgument(Description = "end date ")] object[] enddates, [ExcelArgument(Description = "payCoeff ")] double[] payCoeff, [ExcelArgument(Description = "recCoeff ")] double[] recCoeff, [ExcelArgument(Description = "paySpread ")] double[] paySprd, [ExcelArgument(Description = "recSpread ")] double[] recSprd, [ExcelArgument(Description = "id of pay leg index ")] string payeridxid, [ExcelArgument(Description = "id of rec leg index ")] string recidxid, [ExcelArgument(Description = "id of pay leg discount curve ")] string paydiscountId, [ExcelArgument(Description = "id of rec leg discount curve ")] string recdiscountId, [ExcelArgument(Description = "trigger ")] object trigger) { if (ExcelUtil.CallFromWizard()) { return(""); } string callerAddress = ""; callerAddress = ExcelUtil.getActiveCellAddress(); try { if (startdates.Length != enddates.Length) { return("size mismatch"); } Xl.Range rng = ExcelUtil.getActiveCellRange(); CommodityIndexExt payeridx = OHRepository.Instance.getObject <CommodityIndexExt>(payeridxid); CommodityIndexExt recidx = OHRepository.Instance.getObject <CommodityIndexExt>(recidxid); YieldTermStructureHandle paydiscountcurve = OHRepository.Instance.getObject <YieldTermStructureHandle>(paydiscountId); YieldTermStructureHandle recdiscountcurve = OHRepository.Instance.getObject <YieldTermStructureHandle>(recdiscountId); Date refDate = paydiscountcurve.referenceDate(); PricingPeriodExts pps = new PricingPeriodExts(startdates.Length); for (int i = 0; i < startdates.Length; i++) { //EliteQuant.Date sd = Conversion.ConvertObject<EliteQuant.Date>((DateTime)startdates[i], "date"); //EliteQuant.Date ed = Conversion.ConvertObject<EliteQuant.Date>((DateTime)enddates[i], "date"); Date sd = new Date(Convert.ToInt32(startdates[i])); Date ed = new Date(Convert.ToInt32(enddates[i])); PricingPeriodExt pp = new PricingPeriodExt(sd, ed, sd, quantities[i], payCoeff[i], recCoeff[i], paySprd[i], recSprd[i]); pps.Add(pp); } EnergyBasisSwapExt ebs = new EnergyBasisSwapExt(payeridx, recidx, pps, name, paydiscountcurve, recdiscountcurve, Frequency.Monthly, new NullCalendar()); // Store the futures and return its id string id = "Swp@" + ObjectId; OHRepository.Instance.storeObject(id, ebs, callerAddress); id += "#" + (String)DateTime.Now.ToString(@"HH:mm:ss"); return(id); } catch (Exception e) { ExcelUtil.logError(callerAddress, System.Reflection.MethodInfo.GetCurrentMethod().Name.ToString(), e.Message); return("#EQ_ERR!"); } }