public async Task DFII10_Test()
    {
        //
        // FAILS - runs out of threads
        //
        string             symbol       = "DFII10";
        DateTime           endDate      = new DateTime(2020, 12, 31);
        List <Vintage>     vintageDates = (await FredClient.GetVintageDates(symbol, null)).Where(x => x.VintageDate <= endDate).ToList();
        List <Observation> sparse       = (await FredClient.GetObservations(symbol, vintageDates.Select(x => x.VintageDate).ToList()))
                                          .Where(x => x.ObsDate <= endDate).ToList();

        Assert.AreEqual(1662, vintageDates.Count);
        Assert.AreEqual(4503, sparse.Count);

        // Group sparse observations into vintages
        var vintages = sparse.GroupBy(x => x.VintageDate).ToList();

        Assert.AreEqual(1662, vintages.Count);

        // Make sure we did not wind up with more vintage dates than was in our original list of vintage dates.
        var missingInVintageDates = vintages.Where(v => !vintageDates.Any(vd => vd.VintageDate == v.Key)).ToList();

        Assert.AreEqual(0, missingInVintageDates.Count);

        // Make sure every date in the original list is included in the output
        var missingInVintages = vintageDates.Where(vd => !vintages.Any(v => v.Key == vd.VintageDate)).ToList();

        Assert.AreEqual(0, missingInVintages.Count);
    }
    public async Task ReleaseDateTest()
    {
        ReleaseDate data = (await FredClient.GetReleaseDates("82", 0)).FirstOrDefault();

        Assert.IsNotNull(data);
        Assert.IsFalse(IsZeroString(data.ReleaseID));
        Assert.AreNotEqual(DateTime.MinValue, data.DateReleased);
    }
    public async Task RelatedCategoryTest()
    {
        RelatedCategory data = (await FredClient.GetRelatedCategories("32073")).FirstOrDefault();

        Assert.IsNotNull(data);
        Assert.IsFalse(IsZeroString(data.CategoryID));
        Assert.IsFalse(IsZeroString(data.RelatedCategoryID));
    }
    public async Task VintageTest()
    {
        Vintage data = (await FredClient.GetVintageDates("GNPCA", new DateTime(2020, 1, 1))).FirstOrDefault();

        Assert.IsNotNull(data);
        Assert.IsFalse(String.IsNullOrEmpty(data.Symbol));
        Assert.AreNotEqual(DateTime.MinValue, data.VintageDate);
    }
    public async Task SeriesCategoryTest()
    {
        SeriesCategory data = (await FredClient.GetSeriesForCategory("125", false)).FirstOrDefault();

        Assert.IsNotNull(data);
        Assert.IsFalse(String.IsNullOrEmpty(data.Symbol));
        Assert.IsFalse(IsZeroString(data.CategoryID));
    }
    public async Task ReleaseTest()
    {
        Release data = (await FredClient.GetReleasesForSource("1")).FirstOrDefault();

        Assert.IsNotNull(data);
        Assert.IsFalse(IsZeroString(data.NativeID));
        Assert.IsFalse(String.IsNullOrEmpty(data.Name));
        Assert.AreNotEqual(DateTime.MinValue, data.RTStart);
    }
    public async Task CategoryTest()
    {
        Category data = await FredClient.GetCategory("125");

        Assert.IsNotNull(data);
        Assert.IsFalse(IsZeroString(data.NativeID));
        Assert.IsFalse(String.IsNullOrEmpty(data.Name));
        Assert.IsFalse(IsZeroString(data.ParentID));
    }
    public async Task SourceTest()
    {
        Source data = (await FredClient.GetSources()).FirstOrDefault();

        Assert.IsNotNull(data);
        Assert.IsFalse(String.IsNullOrEmpty(data.NativeID));
        Assert.IsFalse(String.IsNullOrEmpty(data.Name));
        Assert.IsFalse(String.IsNullOrEmpty(data.Link));
    }
    public async Task ObservationTest()
    {
        Observation data = (await FredClient.GetObservations("GNPCA")).FirstOrDefault();

        Assert.IsNotNull(data);
        Assert.IsFalse(String.IsNullOrEmpty(data.Symbol));
        Assert.IsFalse(String.IsNullOrEmpty(data.Value));
        Assert.AreNotEqual(DateTime.MinValue, data.ObsDate);
        Assert.AreNotEqual(DateTime.MinValue, data.VintageDate);
    }
Example #10
0
    public async Task GetRelatedCategoriesTest()
    {
        List <RelatedCategory> data = await FredClient.GetRelatedCategories("32073");

        Assert.IsNotNull(data);

        data = await FredClient.GetRelatedCategories(DOES_NOT_EXIST);

        Assert.IsNull(data);
    }
Example #11
0
    public async Task GetCategoryTagsTest()
    {
        List <CategoryTag> data = await FredClient.GetCategoryTags("125");

        Assert.IsNotNull(data);

        data = await FredClient.GetCategoryTags(DOES_NOT_EXIST);

        Assert.IsNull(data);
    }
Example #12
0
    public async Task GetCategoryChildrenTest()
    {
        List <Category> data = await FredClient.GetCategoryChildren("13");

        Assert.IsNotNull(data);

        data = await FredClient.GetCategoryChildren(DOES_NOT_EXIST);

        Assert.IsNull(data);
    }
Example #13
0
    public async Task GetReleaseDatesTest()
    {
        List <ReleaseDate> data = await FredClient.GetReleaseDates("82", 0);

        Assert.IsNotNull(data);

        data = await FredClient.GetReleaseDates(DOES_NOT_EXIST, 0);

        Assert.IsNull(data);
    }
Example #14
0
    public async Task GetVintgeDatesTest()
    {
        List <Vintage> data = await FredClient.GetVintageDates("GNPCA", new DateTime(2020, 1, 1));

        Assert.IsNotNull(data);

        data = await FredClient.GetVintageDates(DOES_NOT_EXIST, new DateTime(2020, 1, 1));

        Assert.IsNull(data);
    }
Example #15
0
    public async Task GetCategoryTest()
    {
        Category data = await FredClient.GetCategory("125");

        Assert.IsNotNull(data);

        data = await FredClient.GetCategory(DOES_NOT_EXIST);

        Assert.IsNull(data);
    }
Example #16
0
    public async Task GetSeriesForReleaseTest()
    {
        List <Series> data = await FredClient.GetSeriesForRelease("51");

        Assert.IsNotNull(data);

        data = await FredClient.GetSeriesForRelease(DOES_NOT_EXIST);

        Assert.IsNull(data);
    }
Example #17
0
    public async Task GetSeriesTagsTest()
    {
        List <SeriesTag> data = await FredClient.GetSeriesTags("STLFSI");

        Assert.IsNotNull(data);

        data = await FredClient.GetSeriesTags(DOES_NOT_EXIST);

        Assert.IsNull(data);
    }
Example #18
0
    public async Task GetSeriesTest()
    {
        Series data = await FredClient.GetSeries("GNPCA");

        Assert.IsNotNull(data);

        data = await FredClient.GetSeries(DOES_NOT_EXIST);

        Assert.IsNull(data);
    }
Example #19
0
    public async Task GetSeriesForCategoryTest()
    {
        List <SeriesCategory> data = await FredClient.GetSeriesForCategory("125", false);

        Assert.IsNotNull(data);

        data = await FredClient.GetSeriesForCategory(DOES_NOT_EXIST, false);

        Assert.IsNull(data);
    }
Example #20
0
    public async Task GetReleasesForSourceTest()
    {
        List <Release> data = await FredClient.GetReleasesForSource("1");

        Assert.IsNotNull(data);

        data = await FredClient.GetReleasesForSource(DOES_NOT_EXIST);

        Assert.IsNull(data);
    }
Example #21
0
    public async Task GetReleasesForSourceTest2()
    {
        List <Release> data = await FredClient.GetReleasesForSource("1", new DateTime(2020, 1, 1), new DateTime(2020, 12, 31));

        Assert.IsNotNull(data);

        data = await FredClient.GetReleasesForSource(DOES_NOT_EXIST, new DateTime(2020, 1, 1), new DateTime(2020, 12, 31));

        Assert.IsNull(data);
    }
Example #22
0
    public async Task GetObservationsTest2()
    {
        List <Observation> data = await FredClient.GetObservations("GNPCA", new DateTime(2020, 1, 1), new DateTime(2020, 12, 31));

        Assert.IsNotNull(data);

        data = await FredClient.GetObservations(DOES_NOT_EXIST, new DateTime(2020, 1, 1), new DateTime(2020, 12, 31));

        Assert.IsNull(data);
    }
Example #23
0
    public async Task GetCategoriesForSeriesTest()
    {
        List <Category> data = await FredClient.GetCategoriesForSeries("EXJPUS");

        Assert.IsNotNull(data);

        data = await FredClient.GetCategoriesForSeries(DOES_NOT_EXIST);

        Assert.IsNull(data);
    }
Example #24
0
    public async Task GetObservationsTest()
    {
        List <Observation> data = await FredClient.GetObservations("GNPCA");

        Assert.IsNotNull(data);

        data = await FredClient.GetObservations(DOES_NOT_EXIST);

        Assert.IsNull(data);
    }
    public async Task SeriesTagTest()
    {
        SeriesTag data = (await FredClient.GetSeriesTags("STLFSI")).FirstOrDefault();

        Assert.IsNotNull(data);
        Assert.IsFalse(String.IsNullOrEmpty(data.Symbol));
        Assert.IsFalse(String.IsNullOrEmpty(data.Name));
        Assert.IsFalse(String.IsNullOrEmpty(data.GroupID));
        Assert.IsFalse(String.IsNullOrEmpty(data.Notes));
        Assert.Greater(data.Popularity, 0);
    }
    public async Task SeriesTest()
    {
        Series data = (await FredClient.GetSeries("GNPCA"));

        Assert.IsNotNull(data);
        Assert.IsFalse(String.IsNullOrEmpty(data.Symbol));
        Assert.IsFalse(String.IsNullOrEmpty(data.Title));
        Assert.IsFalse(String.IsNullOrEmpty(data.Frequency));
        Assert.IsFalse(String.IsNullOrEmpty(data.Units));
        Assert.IsFalse(String.IsNullOrEmpty(data.SeasonalAdj));
    }
    public async Task NROU_Test()
    {
        string             symbol   = "NROU";
        DateTime           endDate  = new DateTime(2021, 3, 6);
        List <Vintage>     vintages = (await FredClient.GetVintageDates(symbol, null)).Where(x => x.VintageDate <= endDate).ToList();
        List <Observation> obs      = (await FredClient.GetObservations(symbol, vintages.Select(x => x.VintageDate).ToList()))
                                      .Where(x => x.ObsDate <= endDate).ToList();

        Assert.AreEqual(18, vintages.Count);
        Assert.AreEqual(2205, obs.Count);
    }
    public async Task CPIAUCSL_Test()
    {
        string             symbol       = "CPIAUCSL";
        DateTime           endDate      = new DateTime(2021, 3, 6);
        List <Vintage>     vintageDates = (await FredClient.GetVintageDates(symbol, null)).Where(x => x.VintageDate <= endDate).ToList();
        List <Observation> sparse       = (await FredClient.GetObservations(symbol, vintageDates.Select(x => x.VintageDate).ToList()))
                                          .Where(x => x.ObsDate <= endDate).ToList();

        Assert.AreEqual(600, vintageDates.Count);
        Assert.AreEqual(2737, sparse.Count);

        // Group sparse observations into vintages
        var vintages = sparse.GroupBy(x => x.VintageDate).ToList();

        // Make sure we did not wind up with more vintage dates than was in our original list of vintage dates.
        var missingInVintageDates = vintages.Where(v => !vintageDates.Any(vd => vd.VintageDate == v.Key)).ToList();

        // Make sure every date in the original list is included in the output
        var missingInVintages = vintageDates.Where(vd => !vintages.Any(v => v.Key == vd.VintageDate)).ToList();
    }
Example #29
0
    public async Task Download_five_symbols()
    {
        string[] symbols   = new string[] { "LEU0252881600Q", "CPIAUCSL", "GDP", "M2V", "BAA10Y" };
        DateTime startDate = new DateTime(2000, 1, 1);
        DateTime endDate   = new DateTime(2000, 12, 31);
        ConcurrentBag <Observation> observations = new ConcurrentBag <Observation>();

        Task[] tasks = new Task[symbols.Length];

        for (int i = 0; i < symbols.Length; i++)
        {
            tasks[i] = FredClient.GetObservationUpdates(symbols[i], startDate, endDate)
                       .ContinueWith(x => x.Result.ForEach(o => observations.Add(o)));
        }

        Task  result = Task.WhenAll(tasks);
        await result;

        Assert.IsFalse(result.IsFaulted);
        Assert.AreEqual(5, observations.GroupBy(x => x.Symbol).Count());
    }
Example #30
0
    public async Task GetObservationsTest3()
    {
        List <DateTime> vintateDates = new List <DateTime>(10)
        {
            new DateTime(2020, 1, 1),
            new DateTime(2020, 1, 1),
            new DateTime(2020, 1, 1),
            new DateTime(2020, 1, 1),
            new DateTime(2020, 1, 1),
            new DateTime(2020, 1, 1),
            new DateTime(2020, 1, 1),
            new DateTime(2020, 1, 1),
            new DateTime(2020, 1, 1),
            new DateTime(2020, 1, 1)
        };
        List <Observation> data = await FredClient.GetObservations("GNPCA", vintateDates);

        Assert.IsNotNull(data);

        data = await FredClient.GetObservations(DOES_NOT_EXIST, vintateDates);

        Assert.IsNull(data);
    }