Ejemplo n.º 1
0
        public static List<PriceCurvesModel> GetNordpoolMarketCurves(DateTime dateTime)
        {
            var file = string.Format(@"mcp_data_report_{0}-00_00_00",
                dateTime.ToString("dd-MM-yyyy"));

            string filePath = GetAppDataServerPathWith(@"\NordpoolSpot\" + file);

            var dd = new DataDownloader();
            var er = new Utils.ExcelReader();
            Stream fs;
            List<PriceCurvesModel> priceCurvesModels;

            /* If it doesn't exist, download it */
            if (!File.Exists(filePath + ".json"))
            {
                var data = dd.DownloadFile(file + ".xls");
                fs = new MemoryStream(data);
                priceCurvesModels = er.ReadNordPoolSpotPriceCurves(fs);
                fs.Dispose();
                Commons.SaveFileAsJson(filePath + ".json", priceCurvesModels);
            }
            else
            {
                var json = File.ReadAllText(filePath + ".json");
                priceCurvesModels = JsonConvert.DeserializeObject<List<PriceCurvesModel>>(json);
            }

            return priceCurvesModels;
        }
Ejemplo n.º 2
0
        public static void ExcelToJsonSeriesPredictors3(DataItem di)
        {
            var er = new Utils.ExcelReader();

            Func<string, int, int, List<HistoricalPrice>> excelRead = (string path, int fromColumn, int toColumn) =>
            {
                var cols = new List<List<HistoricalPrice>>();
                for (int i = fromColumn; i <= toColumn; i++)
                {
                    cols.Add(er.ReadNordPoolSpotHistoricalPricesInterop(DataDownloader.SavePath + path, i));
                }

                //needs to be done, since the sum is not already consistently calculated
                //assumed same data lengths, ofc
                for (int i = 0; i < cols[0].Count; i++)
                {
                    decimal? val = 0m;

                    for (int j = 1; j < cols.Count; j++)
                    {
                        val += cols[j][i].Value;
                    }

                    cols[0][i].Value += val;
                }

                return cols[0];
            };

            var nd = new DataDownloader();

            Func<int, List<HistoricalPrice>> readYear = (int year) =>
            {
                var p = nd.BuildFileName(di, Resolution.Hourly, FromYear(year));
                if (di == DataItem.Hydro_Reservoir)
                    return excelRead(p, 2, 4);
                else if (di == DataItem.Wind_Power)
                    return excelRead(p, 3, 4);
                else throw new Exception("Not compatible");
            };

            var hd = readYear(2013);
            hd.AddRange(readYear(2014));
            hd.AddRange(readYear(2015));

            // do here some preprocessing?... interpolate missing and ourliers... but not spikes
            var negvs = hd.Where(x => x.Value < 0).ToList();
            var nulls = hd.Where(x => !x.Value.HasValue).ToList();

            var name = nd.BuildFileName(di, Country.All, Resolution.Hourly);
            nd.SaveFileAsJson(GetAppDataServerPath() + name + ".json", hd);
        }
Ejemplo n.º 3
0
        //only for consumption and production...
        public static void ExcelToJsonSeriesPredictors1(DataItem di)
        {
            var er = new Utils.ExcelReader();

            Func<string, List<HistoricalPrice>> excelRead = (string path) =>
            {

                var hdx1 = er.ReadNordPoolSpotHistoricalPricesInterop(DataDownloader.SavePath + path, 3);
                var hdx2 = er.ReadNordPoolSpotHistoricalPricesInterop(DataDownloader.SavePath + path, 4);
                var hdx3 = er.ReadNordPoolSpotHistoricalPricesInterop(DataDownloader.SavePath + path, 5);
                var hdx4 = er.ReadNordPoolSpotHistoricalPricesInterop(DataDownloader.SavePath + path, 6);

                //needs to be done, since the sum is not already consistently calculated
                for (int i = 0; i < hdx1.Count; i++)
                {
                    hdx1[i].Value = hdx2[i].Value + hdx3[i].Value + hdx4[i].Value;
                }

                return hdx1;
            };

            var nd = new DataDownloader();

            Func<int, List<HistoricalPrice>> readYear = (int year) =>
            {
                var p = nd.BuildFileName(di, Country.All, Resolution.Hourly, FromYear(year));
                return excelRead(p);
            };

            var hd = readYear(2013);
            hd.AddRange(readYear(2014));
            hd.AddRange(readYear(2015));

            // do here some preprocessing?... interpolate missing and ourliers... but not spikes
            var negvs = hd.Where(x => x.Value < 0).ToList();
            var nulls = hd.Where(x => !x.Value.HasValue).ToList();

            var name = nd.BuildFileName(di, Country.All, Resolution.Hourly);
            nd.SaveFileAsJson(GetAppDataServerPath() + name + ".json", hd);
        }
Ejemplo n.º 4
0
        public static void ExcelToJsonSeries(DataItem di)
        {
            Func<int, string, string> downloadMethod = (int p1, string p2) => p2.Substring(p1);

            var er = new Utils.ExcelReader();
            var nd = new DataDownloader();
            var p = nd.BuildFileName(DataItem.Elspot_Prices, Resolution.Hourly, FromYear(2013), Currency.EUR);
            var hd = er.ReadNordPoolSpotHistoricalPricesInterop(DataDownloader.SavePath + p, 3);

            p = nd.BuildFileName(DataItem.Elspot_Prices, Resolution.Hourly, FromYear(2014), Currency.EUR);
            var hd1 = er.ReadNordPoolSpotHistoricalPricesInterop(DataDownloader.SavePath + p, 3);
            hd.AddRange(hd1);

            p = nd.BuildFileName(DataItem.Elspot_Prices, Resolution.Hourly, FromYear(2015), Currency.EUR);
            var hd2 = er.ReadNordPoolSpotHistoricalPricesInterop(DataDownloader.SavePath + p, 3);
            hd.AddRange(hd2);

            // do here some preprocessing?... interpolate missing and ourliers... but not spikes
            var negvs = hd.Where(x => x.Value < 0).ToList();
            var nulls = hd.Where(x => !x.Value.HasValue).ToList();

            var name = nd.BuildFileName(DataItem.Elspot_Prices, Resolution.Hourly, Currency.EUR);
            nd.SaveFileAsJson(GetAppDataServerPath() + name + ".json", hd);
        }