Esempio n. 1
0
        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(EnergyFutureExt obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }