コード例 #1
0
 private static string connDebugText(Product prod, int curveType, int tenorType, DateTime day)
 {
     return prod.Name + " : " +
             CURVE_TYPE.ToString(curveType) + " : " +
             TENOR_TYPE.ToString(tenorType) + " : " +
             day.ToShortDateString();
 }
コード例 #2
0
ファイル: Curve.cs プロジェクト: BertiFuchsi/GanovenFutter
        private SortedDictionary<DateTime, double> DataContainer; // @@@ provide the possiblity to handle this via a numerics interp curve, although really only surfaces

        #endregion Fields

        #region Constructors

        public Curve(Product product, int sourceType, int tenorType)
        {
            this.MyProduct = product;
            this.SourceType = sourceType;
            this.TenorType = tenorType;
            this.DataContainer = new SortedDictionary<DateTime, double>();
            this.MinMarketDate = DateTime.MaxValue;
            this.MaxMarketDate = DateTime.MinValue;
        }
コード例 #3
0
        public CurveReportItem(CurveReport curveRep, DateTime minDate, DateTime maxDate, DateTime singleDate, int curveType)
        {
            this.ParentCurveReport = curveRep;
            this.ParentProduct = DynamicData.Products[curveRep.ProductName];
            this.CurveType = curveType;
            this.MinDate = minDate;
            this.MaxDate = maxDate;
            this.SingleDate = singleDate;
            this.FLAG_FOR_DELETION = false;

            PostConstruct();
        }
コード例 #4
0
ファイル: VolCurve.cs プロジェクト: BertiFuchsi/GanovenFutter
        private Dictionary<int, DateTime> MinDeliveryDates; // <SurfaceType, date>

        #endregion Fields

        #region Constructors

        public VolCurve(Product product, int sourceType, int tenorType, int surfaceType, DateTime deliveryDate)
        {
            this.MyProduct = product;
            this.SourceType = sourceType;
            this.TenorType = tenorType;
            this.DeliveryDate = deliveryDate;
            this.InterpolationType = INTERPOLATION_TYPE.LINEAR; //@@@

            this.DataContainer = new SortedDictionary<DateTime, Dictionary<int, SortedDictionary<double, double>>>();
            this.MinDeliveryDates = new Dictionary<int, DateTime>();
            this.MaxDeliveryDates = new Dictionary<int, DateTime>();
        }
コード例 #5
0
        //// old DS RequestVolSurface obsolete with MarketDataLoader
        //public override VolSurface RequestVolSurface(Product prod, int tenorType, int surfaceType,
        //                                    DateTime marketDate, DateTime fromDate, DateTime toDate)
        //{
        //    VolSurface myVolSurface = new VolSurface(prod, SOURCE_TYPE.RWE_DS, tenorType, surfaceType, marketDate);
        //    SortedDictionary<DateTime, SortedDictionary<double, double>> ret;
        //    ret = RWE_API.MarketInterface_Wrapper.GetVolDict("DSCharting_Forward", TENOR_TYPE.ToStringDS(tenorType), prod.RWE_DS_Commodity, prod.RWE_DS_Vol_Product,
        //        marketDate, fromDate, toDate);
        //    myVolSurface.SetSurface(ret);
        //    return myVolSurface;
        //}
        public override Curve RequestCurve(Product prod, int tenorType, int curveType,
                                    DateTime marketDate, DateTime fromDate, DateTime toDate)
        {
            if (curveType != CURVE_TYPE.FWD_CURVE) throw new NotImplementedException();

            Curve myCurve = new Curve(prod, SOURCE_TYPE.RWE_DS, tenorType, marketDate);

            SortedDictionary<DateTime, double> ret;
            ret = RWE_API.MarketInterface_Wrapper.GetCurveDict("DSCharting_Forward", TENOR_TYPE.ToStringDS(tenorType), prod.RWE_DS_Commodity, prod.RWE_DS_Product,
                marketDate, fromDate, toDate);

            myCurve.SetCurve(new SortedList<DateTime, double>(ret));
            return myCurve;
        }
コード例 #6
0
        public override SortedDictionary<DateTime, SortedDictionary<double, double>> RequestFWDVolSurface(Product prod, int tenorType, int surfaceType, int dataType, int sourceType, DateTime delDateFrom, DateTime delDateTo, DateTime marketDate)
        {
            // get csv data
            string filePath = Path.Combine(tempVolPath, (prod.Name == "TTF" ? TTFSuffix : NBPSuffix) + marketDate.ToString("yyyy_MM_dd") + ".csv");
            List<string[]> parsedData = new List<string[]>();

            try
            {
                using (TextFieldParser parser = new TextFieldParser(filePath))
                {
                    parser.TextFieldType = FieldType.Delimited;
                    parser.SetDelimiters(",");
                    while (!parser.EndOfData)
                    {
                        parsedData.Add(parser.ReadFields());
                    }
                }
            }
            catch (Exception e)
            {
                Debugger.AddDebugLine("CSV: "
                            + (prod.Name == "TTF" ? TTFSuffix : NBPSuffix) + marketDate.ToString("yyyy_MM_dd") + ".csv"
                            + " : " + e.ToString());
                return null;
            }

            // post processing [old Endur Data: 1lom = current month] this is all very bad @@@
            SortedDictionary<DateTime, SortedDictionary<double, double>> vol = new SortedDictionary<DateTime, SortedDictionary<double, double>>();

            string[] runArray = parsedData.First();
            int maxCol = runArray.Contains("1cd") ? Array.FindIndex(runArray, w => w == "1cd") : runArray.GetUpperBound(0);

            DateTime delDate;
            int iRow = 3;
            foreach (var item in parsedData.Skip(3)) // skip strikes, cod, 1lom
            {
                TradingCenter.TCTenorSelector(marketDate, TENOR_TYPE.MONTH, 4 - iRow);
                delDate = TradingCenter.TCTenorSelector(marketDate, TENOR_TYPE.MONTH, 4 - iRow);
                vol.Add(delDate, new SortedDictionary<double, double>());

                for (int k = 1; k <= maxCol; k++)
                {
                    vol[delDate].Add(Double.Parse(runArray[k], System.Globalization.NumberStyles.Float),
                                    double.Parse(item[k]));
                }
                iRow++;
            }
            return vol;
        }
コード例 #7
0
        private string CreateObjectName(Product prod, int tenorType, int surfaceType, int dataType, int sourceType, DateTime delDate)
        {
            string surfaceTypeSuffix = null;
            string sourceTypeSuffix = null;
            string stripBulletSuffix = null;
            string tenorSuffix = null;
            string commSuffix = null;
            string prodSuffix = null;

            switch (surfaceType)
            {
                case SURFACE_TYPE.MONEYNESS: surfaceTypeSuffix = "_MNS"; break;
                case SURFACE_TYPE.DELTA: surfaceTypeSuffix = "_DEL"; break;
                default: throw new NotImplementedException();
            }

            switch (sourceType)
            {
                case SOURCE_TYPE.RWE: sourceTypeSuffix = "IMPL_VOL"; break;
                case SOURCE_TYPE.EXCH: sourceTypeSuffix = "EXCH-VOL"; break;
            }

            stripBulletSuffix = "_BULLET"; // calculate strips yourself

            switch (tenorType)
            {
                case TENOR_TYPE.MONTH: tenorSuffix = "_M_" + delDate.ToString("MMMyy").ToUpper(); break;
                case TENOR_TYPE.QUARTER:
                    int qrt =  ((int)TradingCenter.TCTenorSelector(delDate, tenorType).Month / 3) + 1;
                    tenorSuffix = "_Q_" + qrt + "Q" + delDate.ToString("yy");
                    break;
                case TENOR_TYPE.SEASON: tenorSuffix = "_S_" + (delDate.Month == 4 ? "SUM" : "WIN") + delDate.ToString("yy"); break;
             }

            switch(prod.Commodity.ToUpper())
            {
                case "GAS": commSuffix = "_GAS"; break;
            }

            prodSuffix = "_" + prod.Name.ToUpper() + "_NATGAS";
            // map products , i.e. api2... @@@

            return @"LOCAL/" + sourceTypeSuffix + commSuffix + prodSuffix + tenorSuffix + surfaceTypeSuffix + stripBulletSuffix;
        }
コード例 #8
0
        public override VolSurface RequestVolSurface(Product prod, int tenorType, int surfaceType, 
                                            DateTime marketDate, DateTime fromDate, DateTime toDate)
        {
            VolSurface myVolSurface = new VolSurface(prod, SOURCE_TYPE.RWE_DS, tenorType, surfaceType, marketDate);

            object[,] vol_raw = RWE_API.MarketDataLoader_Wrapper.GetVolGrid("iVol_NG_" + prod.Name + "_P_" + (tenorType == TENOR_TYPE.DAY? "D" : "M"),
                                                                        marketDate, fromDate, toDate);

            // convert object[,] to SortedDict
            DateTime delDate;
            SortedDictionary<DateTime, SortedDictionary<double, double>> vol = new SortedDictionary<DateTime, SortedDictionary<double, double>>();
            for (int i = 1; i < vol_raw.GetLength(0); i++)
            {
                delDate = (DateTime)vol_raw[i,0];
                vol.Add(delDate, new SortedDictionary<double,double>());
                for (int j = 1; j < vol_raw.GetLength(1); j++)
                {
                    vol[delDate].Add((double)vol_raw[0, j], (double)vol_raw[i, j]);
                }
            }
            myVolSurface.SetSurface(vol);
            return myVolSurface;
        }
コード例 #9
0
 public override SortedDictionary<DateTime, SortedDictionary<double, double>> RequestDEVLPVolSurface(Product prod, int tenorType, int surfaceType, int dataType, int sourceType, DateTime delDate, DateTime marketDateFrom, DateTime marketDateTo)
 {
     string finalName = CreateObjectName(prod, tenorType, surfaceType, dataType, sourceType, delDate);
     return RWE_API.FinCacheLoader.GetSurface(CacheDir, finalName, finalName, marketDateFrom, marketDateTo);
 }
コード例 #10
0
 public override SortedDictionary<DateTime, SortedDictionary<double, double>> RequestFWDVolSurface(Product prod, int tenorType, int surfaceType, int dataType, int sourceType, DateTime delDateFrom, DateTime delDateTo, DateTime marketDate)
 {
     throw new NotImplementedException();
 }
コード例 #11
0
        public override SortedDictionary<DateTime, double> RequestFWDCurve(Product prod, int tenorType, int dataType, int sourceType, DateTime delDateFrom, DateTime delDateTo, DateTime marketDate)
        {
            SortedDictionary<DateTime, double> ret;
            ret = RWE_API.MarketInterface_Wrapper.GetCurveDict("DSCharting_Forward", TENOR_TYPE.ToStringDS(tenorType), prod.RWE_DS_Commodity, tenorType == TENOR_TYPE.DAY? prod.RWE_DS_Product_Daily : prod.RWE_DS_Product,
                marketDate, delDateFrom, delDateTo);

            if (ret.Count == 0)
            {
                Debugger.AddDebugLine("Sequence contains no elements");
                return null;
            }
            return ret;
        }
コード例 #12
0
        public override SortedDictionary<DateTime, SortedDictionary<double, double>> RequestFWDVolSurface(Product prod, int tenorType, int surfaceType, int dataType, int sourceType, DateTime delDateFrom, DateTime delDateTo, DateTime marketDate)
        {
            object[,] vol_raw = RWE_API.MarketDataLoader_Wrapper.GetVolGrid("iVol_NG_" + prod.Name + "_P_" + (tenorType == TENOR_TYPE.DAY ? "D" : "M"), marketDate, delDateFrom, delDateTo);
            if (vol_raw.GetUpperBound(0) == 0 && vol_raw.GetUpperBound(1) == 0)
            {
                if (vol_raw[0, 0].ToString().Contains("Sequence contains no elements")) ;
                {
                    Debugger.AddDebugLine(vol_raw[0, 0].ToString());
                    return null;
                }
                throw new ArgumentException(vol_raw[0, 0].ToString());
            }

            // convert object[,] to SortedDict
            DateTime delDate;
            SortedDictionary<DateTime, SortedDictionary<double, double>> vol = new SortedDictionary<DateTime, SortedDictionary<double, double>>();
            for (int i = 1; i < vol_raw.GetLength(0); i++)
            {
                delDate = (DateTime)vol_raw[i, 0];
                vol.Add(delDate, new SortedDictionary<double, double>());
                for (int j = 1; j < vol_raw.GetLength(1); j++)
                {
                    vol[delDate].Add((double)vol_raw[0, j], (double)vol_raw[i, j]);
                }
            }
            return vol;
        }
コード例 #13
0
 public SortedList<DateTime, double> GetFwdCurve(Product prod, int sourceType, int tenorType, DateTime delDateFrom, DateTime delDateTo, DateTime marketDate)
 {
     return prod.ReturnCurveSeries(sourceType).GetFwdCurve(tenorType, delDateFrom, delDateTo, marketDate);
 }
コード例 #14
0
        // @@@ why 'object' for strikeParam, should this not only be double?
        private static KeyValuePair<int, double> OptSurfaceInput(Product prod, object surfaceType, object strikeParam)
        {
            int k;
            if (surfaceType is ExcelDna.Integration.ExcelMissing)
            {
                k = prod.DefaultVolSurfaceType;
            }
            else if (int.TryParse((String)surfaceType, out k))
            {
                // nothign to do
                // @@@ very ugly, how to improve?
            }
            else
            {
                k = SURFACE_TYPE.ToInt((String)surfaceType);
            }

             //k = surfaceType is ExcelDna.Integration.ExcelMissing? prod.DefaultVolSurfaceType : Convert.ToInt32(surfaceType);
            return new KeyValuePair<int, double>(k, strikeParam is ExcelDna.Integration.ExcelMissing? SURFACE_TYPE.GetDefaultStrikeParam(k) : Convert.ToDouble(strikeParam));
        }
コード例 #15
0
 public SortedList<DateTime, double> GetFwdCurveFromDates(Product prod, int sourceType, int tenorType, List<DateTime> delDateArr, DateTime marketDate)
 {
     return prod.ReturnCurveSeries(sourceType).GetFwdCurveFromDates(tenorType, delDateArr, marketDate);
 }
コード例 #16
0
ファイル: Curve.cs プロジェクト: BertiFuchsi/GanovenFutter
 /* delivery date is optional (omitted for for GRAN_TYPE == SPOT) */
 public Curve(Product product, int sourceType, int tenorType, DateTime deliveryDate)
     : this(product, sourceType, tenorType)
 {
     this.DeliveryDate = deliveryDate;
 }
コード例 #17
0
 public override VolSurface RequestVolSurface(Product prod, int tenorType, int surfaceType, DateTime marketDate, DateTime fromDate, DateTime toDate)
 {
     throw new NotImplementedException();
 }
コード例 #18
0
        public Dictionary<int, Dictionary<DateTime, Curve>> DataContainer; // <tenorType, <DeliveryStart, Curve>>

        #endregion Fields

        #region Constructors

        public CurveSeries(Product myProduct, int sourceType)
        {
            this.DataContainer = new Dictionary<int, Dictionary<DateTime, Curve>>();
            this.MyProduct = myProduct;
            this.SourceType = sourceType;
        }
コード例 #19
0
 public static SortedList<DateTime, double> GetDevlpCurveFromDates(Product prod, int sourceType, int tenorType, DateTime delDate, List<DateTime> marketDateArr)
 {
     return prod.ReturnCurveSeries(sourceType).GetDevlpCurveFromDates(tenorType, delDate, marketDateArr);
 }
コード例 #20
0
 public static double GetValue(Product prod, int sourceType, int tenorType, DateTime delStart, DateTime marketDate)
 {
     return prod.ReturnCurveSeries(sourceType).GetValue(tenorType, delStart, marketDate);
 }
コード例 #21
0
ファイル: Trade.cs プロジェクト: BertiFuchsi/GanovenFutter
 public void PostConstruct()
 {
     MyProduct = DynamicData.GetProduct(ProductName);
     SplitTradelets();
 }
コード例 #22
0
 public override SortedDictionary<DateTime, double> RequestDEVLPCurve(Product prod, int tenorType, int dataType, int sourceType, DateTime delDate, DateTime marketDateFrom, DateTime marketDateTo)
 {
     throw new NotImplementedException();
 }
コード例 #23
0
 public override Curve RequestCurve(Product prod, int tenorType, int curveType, DateTime marketDate, DateTime fromDate, DateTime toDate)
 {
     throw new NotImplementedException();
 }