Exemplo n.º 1
0
        public List <IEnumerable <TimeSerieRow.Versioned> > DataRequestVersioned(int id, string provider, LocalDate start, LocalDate end)
        {
            var _cfg = _config(provider);

            LocalDateTime s = new LocalDateTime(start.Year, start.Month, start.Day, 0, 0);
            LocalDateTime e = new LocalDateTime(end.Year, end.Month, end.Day, 0, 0);
            List <IEnumerable <TimeSerieRow.Versioned> > versionList = new List <IEnumerable <TimeSerieRow.Versioned> >();

            QueryService qs       = new QueryService(_cfg);
            var          versions = MetadataRequestVersioned(id.ToString(), provider, s, e); // Get all versions for date range.

            Console.WriteLine("Requesting versioned data...");
            foreach (var v in versions)
            {
                try
                {
                    var query = qs.CreateVersioned()
                                .ForMarketData(id)
                                .InAbsoluteDateRange(v.RangeStart, v.RangeEnd)
                                .InGranularity(Granularity.Day)
                                .ForVersion(v.Version.Value)
                                .ExecuteAsync().ConfigureAwait(true).GetAwaiter().GetResult();

                    versionList.Add(query);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.InnerException);
                }
            }
            return(versionList);
        }
Exemplo n.º 2
0
        public void VerWithMultipleMarketDataWindowMUV()
        {
            using (var httpTest = new HttpTest())
            {
                var qs = new QueryService(_cfg);

                var ver = qs.CreateVersioned()
                          .ForMarketData(new int[] { 100000001, 100000002, 100000003 })
                          .InGranularity(Granularity.Day)
                          .InRelativePeriod(Period.FromDays(5))
                          .ForMUV()
                          .ExecuteAsync().Result;

                httpTest.ShouldHaveCalled($"{_cfg.BaseAddress}query/v1.0/vts/MUV/Day/P5D"
                                          .SetQueryParam("id", new int[] { 100000001, 100000002, 100000003 }))
                .WithVerb(HttpMethod.Get)
                .Times(1);
            }
        }
Exemplo n.º 3
0
        public void VerWithMultipleMarketDataWindowVersion()
        {
            using (var httpTest = new HttpTest())
            {
                var qs = new QueryService(_cfg);

                var ver = qs.CreateVersioned()
                          .ForMarketData(new int[] { 100000001, 100000002, 100000003 })
                          .InGranularity(Granularity.Day)
                          .ForVersion(new LocalDateTime(2018, 07, 19, 12, 0))
                          .InRelativeInterval(RelativeInterval.RollingMonth)
                          .ExecuteAsync().Result;

                httpTest.ShouldHaveCalled($"{_cfg.BaseAddress}query/v1.0/vts/Version/2018-07-19T12:00:00/Day/RollingMonth"
                                          .SetQueryParam("id", new int[] { 100000001, 100000002, 100000003 }))
                .WithVerb(HttpMethod.Get)
                .Times(1);
            }
        }
Exemplo n.º 4
0
        public void VerWithMultipleMarketDataWindowLastOfMonths()
        {
            using (var httpTest = new HttpTest())
            {
                var qs = new QueryService(_cfg);

                var ver = qs.CreateVersioned()
                          .ForMarketData(new int[] { 100000001, 100000002, 100000003 })
                          .InGranularity(Granularity.Day)
                          .ForLastOfMonths(new LocalDate(2018, 5, 22), new LocalDate(2018, 7, 23))
                          .InRelativePeriodRange(Period.FromWeeks(2), Period.FromDays(20))
                          .ExecuteAsync().Result;

                httpTest.ShouldHaveCalled($"{_cfg.BaseAddress}query/v1.0/vts/LastOfMonths/2018-05-22/2018-07-23/Day/P2W/P20D"
                                          .SetQueryParam("id", new int[] { 100000001, 100000002, 100000003 }))
                .WithVerb(HttpMethod.Get)
                .Times(1);
            }
        }
Exemplo n.º 5
0
        public void VerInPeriodRelativePeriodRangeLastOfMonths()
        {
            using (var httpTest = new HttpTest())
            {
                var qs = new QueryService(_cfg);

                var ver = qs.CreateVersioned()
                          .ForMarketData(new int[] { 100000001 })
                          .InGranularity(Granularity.Day)
                          .ForLastOfMonths(Period.FromMonths(-4))
                          .InRelativePeriodRange(Period.FromMonths(-2), Period.FromDays(5))
                          .ExecuteAsync().Result;

                httpTest.ShouldHaveCalled($"{_cfg.BaseAddress}query/v1.0/vts/LastOfMonths/P-4M/Day/P-2M/P5D"
                                          .SetQueryParam("id", 100000001))
                .WithVerb(HttpMethod.Get)
                .Times(1);
            }
        }
Exemplo n.º 6
0
        public void VerInAbsoluteDateRangeMUV()
        {
            using (var httpTest = new HttpTest())
            {
                var qs = new QueryService(_cfg);

                var ver = qs.CreateVersioned()
                          .ForMarketData(new int[] { 100000001 })
                          .InGranularity(Granularity.Day)
                          .ForMUV()
                          .InAbsoluteDateRange(new LocalDate(2018, 7, 22), new LocalDate(2018, 7, 23))
                          .ExecuteAsync().Result;

                httpTest.ShouldHaveCalled($"{_cfg.BaseAddress}query/v1.0/vts/MUV/Day/2018-07-22/2018-07-23"
                                          .SetQueryParam("id", 100000001))
                .WithVerb(HttpMethod.Get)
                .Times(1);
            }
        }
Exemplo n.º 7
0
        public void VerInRelativePeriodRangeExtractionWindowMUV()
        {
            using (var httpTest = new HttpTest())
            {
                var qs = new QueryService(_cfg);

                var ver = qs.CreateVersioned()
                          .ForMarketData(new int[] { 100000001 })
                          .InGranularity(Granularity.Day)
                          .InRelativePeriodRange(Period.FromWeeks(2), Period.FromDays(20))
                          .ForMUV()
                          .ExecuteAsync().Result;

                httpTest.ShouldHaveCalled($"{_cfg.BaseAddress}query/v1.0/vts/MUV/Day/P2W/P20D"
                                          .SetQueryParam("id", 100000001))
                .WithVerb(HttpMethod.Get)
                .Times(1);
            }
        }
Exemplo n.º 8
0
        public void VerInRelativeIntervalMUV()
        {
            using (var httpTest = new HttpTest())
            {
                var qs = new QueryService(_cfg);

                var ver = qs.CreateVersioned()
                          .ForMarketData(new int[] { 100000001 })
                          .InGranularity(Granularity.Day)
                          .ForMUV()
                          .InRelativeInterval(RelativeInterval.RollingMonth)
                          .ExecuteAsync().Result;

                httpTest.ShouldHaveCalled($"{_cfg.BaseAddress}query/v1.0/vts/MUV/Day/RollingMonth"
                                          .SetQueryParam("id", 100000001))
                .WithVerb(HttpMethod.Get)
                .Times(1);
            }
        }
Exemplo n.º 9
0
        public void VerInRelativePeriodExtractionWindowVersion()
        {
            using (var httpTest = new HttpTest())
            {
                var qs = new QueryService(_cfg);

                var ver = qs.CreateVersioned()
                          .ForMarketData(new int[] { 100000001 })
                          .InGranularity(Granularity.Day)
                          .ForVersion(new LocalDateTime(2018, 07, 19, 12, 0))
                          .InRelativePeriod(Period.FromDays(5))
                          .ExecuteAsync().Result;

                httpTest.ShouldHaveCalled($"{_cfg.BaseAddress}query/v1.0/vts/Version/2018-07-19T12:00:00/Day/P5D"
                                          .SetQueryParam("id", 100000001))
                .WithVerb(HttpMethod.Get)
                .Times(1);
            }
        }
Exemplo n.º 10
0
        public void VerInDateRangeRelativeIntervalLastOfDays()
        {
            using (var httpTest = new HttpTest())
            {
                var qs = new QueryService(_cfg);

                var ver = qs.CreateVersioned()
                          .ForMarketData(new int[] { 100000001 })
                          .InGranularity(Granularity.Day)
                          .ForLastOfDays(new LocalDate(2018, 5, 22), new LocalDate(2018, 7, 23))
                          .InRelativeInterval(RelativeInterval.RollingMonth)
                          .ExecuteAsync().Result;

                httpTest.ShouldHaveCalled($"{_cfg.BaseAddress}query/v1.0/vts/LastOfDays/2018-05-22/2018-07-23/Day/RollingMonth"
                                          .SetQueryParam("id", 100000001))
                .WithVerb(HttpMethod.Get)
                .Times(1);
            }
        }
Exemplo n.º 11
0
        public void VerWithTimeZoneLastOfDays()
        {
            using (var httpTest = new HttpTest())
            {
                var qs = new QueryService(_cfg);

                var act = qs.CreateVersioned()
                          .ForMarketData(new int[] { 100000001 })
                          .InGranularity(Granularity.Day)
                          .ForLastOfDays(Period.FromMonths(-1), Period.FromDays(20))
                          .InAbsoluteDateRange(new LocalDate(2017, 1, 1), new LocalDate(2018, 1, 10))
                          .InTimezone("UTC")
                          .ExecuteAsync().Result;

                httpTest.ShouldHaveCalled($"{_cfg.BaseAddress}query/v1.0/vts/LastOfDays/P-1M/P20D/Day/2017-01-01/2018-01-10"
                                          .SetQueryParam("id", 100000001)
                                          .SetQueryParam("tz", "UTC"))
                .WithVerb(HttpMethod.Get)
                .Times(1);
            }
        }
Exemplo n.º 12
0
        public void VerWithTimeZoneVersion()
        {
            using (var httpTest = new HttpTest())
            {
                var qs = new QueryService(_cfg);

                var act = qs.CreateVersioned()
                          .ForMarketData(new int[] { 100000001 })
                          .InGranularity(Granularity.Day)
                          .ForVersion(new LocalDateTime(2018, 07, 19, 12, 0))
                          .InAbsoluteDateRange(new LocalDate(2017, 1, 1), new LocalDate(2018, 1, 10))
                          .InTimezone("UTC")
                          .ExecuteAsync().Result;

                httpTest.ShouldHaveCalled($"{_cfg.BaseAddress}query/v1.0/vts/Version/2018-07-19T12:00:00/Day/2017-01-01/2018-01-10"
                                          .SetQueryParam("id", 100000001)
                                          .SetQueryParam("tz", "UTC"))
                .WithVerb(HttpMethod.Get)
                .Times(1);
            }
        }
Exemplo n.º 13
0
        public void VerInPeriodRelativeIntervalLastOfMonthsWithHeaders()
        {
            using (var httpTest = new HttpTest())
            {
                var qs = new QueryService(_cfg);

                var ver = qs.CreateVersioned()
                          .ForMarketData(new int[] { 100000001 })
                          .InGranularity(Granularity.Day)
                          .ForLastOfMonths(Period.FromMonths(-4))
                          .InRelativeInterval(RelativeInterval.RollingMonth)
                          .ExecuteAsync().Result;

                httpTest.ShouldHaveCalled($"{_cfg.BaseAddress}query/v1.0/vts/LastOfMonths/P-4M/Day/RollingMonth"
                                          .SetQueryParam("id", 100000001))
                .WithVerb(HttpMethod.Get)
                .WithHeader("Accept", "application/x.msgpacklz4; q=1.0")
                .WithHeader("Accept", "application/x-msgpack; q=0.75")
                .WithHeader("Accept", "application/json; q=0.5")
                .Times(1);
            }

            using (var httpTest = new HttpTest())
            {
                var qs = new QueryService(_cfg);

                var ver = qs.CreateVersioned()
                          .ForMarketData(new int[] { 100000001 })
                          .InGranularity(Granularity.Day)
                          .ForLastOfMonths(Period.FromMonths(-4))
                          .InRelativeInterval(RelativeInterval.RollingMonth)
                          .ExecuteAsync().Result;

                httpTest.ShouldHaveCalled($"{_cfg.BaseAddress}query/v1.0/vts/LastOfMonths/P-4M/Day/RollingMonth"
                                          .SetQueryParam("id", 100000001))
                .WithVerb(HttpMethod.Get)
                //.WithHeader
                .Times(1);
            }
        }