From 19e88c5465ebc048a6619e1d1fe6e7767d42549b Mon Sep 17 00:00:00 2001 From: Romazes Date: Thu, 22 Feb 2024 17:18:27 +0200 Subject: [PATCH] feat: init globals providers --- .../AlphaVantageDataDownloaderTests.cs | 27 +++++++++---------- QuantConnect.AlphaVantage.Tests/TestSetup.cs | 3 +++ 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/QuantConnect.AlphaVantage.Tests/AlphaVantageDataDownloaderTests.cs b/QuantConnect.AlphaVantage.Tests/AlphaVantageDataDownloaderTests.cs index 92c5bb8..719c00f 100644 --- a/QuantConnect.AlphaVantage.Tests/AlphaVantageDataDownloaderTests.cs +++ b/QuantConnect.AlphaVantage.Tests/AlphaVantageDataDownloaderTests.cs @@ -29,11 +29,14 @@ public class AlphaVantageDataDownloaderTests private AlphaVantageDataDownloader _downloader; private MarketHoursDatabase _marketHoursDatabase; + public static Symbol AAPL { get; private set; } + [SetUp] public void SetUp() { _downloader = new(); _marketHoursDatabase = MarketHoursDatabase.FromDataFolder(); + AAPL = Symbol.Create("AAPL", SecurityType.Equity, Market.USA); } [TearDown] @@ -57,13 +60,11 @@ public static IEnumerable DownloaderValidCaseData { get { - var symbol = Symbol.Create("AAPL", SecurityType.Equity, Market.USA); - - yield return new TestCaseData(symbol, Resolution.Minute, new DateTime(2024, 1, 1, 5, 30, 0), new DateTime(2024, 2, 1, 20, 0, 0), TickType.Trade); - yield return new TestCaseData(symbol, Resolution.Minute, new DateTime(2024, 1, 8, 9, 30, 0), new DateTime(2024, 1, 12, 16, 0, 0), TickType.Trade); - yield return new TestCaseData(symbol, Resolution.Minute, new DateTime(2015, 2, 2, 9, 30, 0), new DateTime(2015, 3, 1, 16, 0, 0), TickType.Trade); - yield return new TestCaseData(symbol, Resolution.Hour, new DateTime(2023, 11, 8, 9, 30, 0), new DateTime(2024, 2, 2, 16, 0, 0), TickType.Trade); - yield return new TestCaseData(symbol, Resolution.Daily, new DateTime(2023, 1, 8, 9, 30, 0), new DateTime(2024, 2, 2, 16, 0, 0), TickType.Trade); + yield return new TestCaseData(AAPL, Resolution.Minute, new DateTime(2024, 1, 1, 5, 30, 0), new DateTime(2024, 2, 1, 20, 0, 0), TickType.Trade); + yield return new TestCaseData(AAPL, Resolution.Minute, new DateTime(2024, 1, 8, 9, 30, 0), new DateTime(2024, 1, 12, 16, 0, 0), TickType.Trade); + yield return new TestCaseData(AAPL, Resolution.Minute, new DateTime(2015, 2, 2, 9, 30, 0), new DateTime(2015, 3, 1, 16, 0, 0), TickType.Trade); + yield return new TestCaseData(AAPL, Resolution.Hour, new DateTime(2023, 11, 8, 9, 30, 0), new DateTime(2024, 2, 2, 16, 0, 0), TickType.Trade); + yield return new TestCaseData(AAPL, Resolution.Daily, new DateTime(2023, 1, 8, 9, 30, 0), new DateTime(2024, 2, 2, 16, 0, 0), TickType.Trade); } } @@ -94,20 +95,18 @@ public static IEnumerable DownloaderInvalidCaseData { get { - var symbol = Symbol.Create("AAPL", SecurityType.Equity, Market.USA); - var startUtc = new DateTime(2024, 1, 1); var endUtc = new DateTime(2024, 2, 1); - yield return new TestCaseData(symbol, Resolution.Minute, startUtc, endUtc, TickType.Quote, false) + yield return new TestCaseData(AAPL, Resolution.Minute, startUtc, endUtc, TickType.Quote, false) .SetDescription($"Not supported {nameof(TickType.Quote)} -> empty result"); - yield return new TestCaseData(symbol, Resolution.Minute, startUtc, endUtc, TickType.OpenInterest, false) + yield return new TestCaseData(AAPL, Resolution.Minute, startUtc, endUtc, TickType.OpenInterest, false) .SetDescription($"Not supported {nameof(TickType.OpenInterest)} -> empty result"); - yield return new TestCaseData(symbol, Resolution.Tick, startUtc, endUtc, TickType.Trade, true) + yield return new TestCaseData(AAPL, Resolution.Tick, startUtc, endUtc, TickType.Trade, true) .SetDescription($"Not supported {nameof(Resolution.Tick)} -> throw Exception"); - yield return new TestCaseData(symbol, Resolution.Second, startUtc, endUtc, TickType.Trade, true) + yield return new TestCaseData(AAPL, Resolution.Second, startUtc, endUtc, TickType.Trade, true) .SetDescription($"Not supported {nameof(Resolution.Second)} -> throw Exception"); - yield return new TestCaseData(symbol, Resolution.Minute, endUtc, startUtc, TickType.Trade, false) + yield return new TestCaseData(AAPL, Resolution.Minute, endUtc, startUtc, TickType.Trade, false) .SetDescription("startDateTime > endDateTime -> empty result"); yield return new TestCaseData(Symbol.Create("USDJPY", SecurityType.Forex, Market.Oanda), Resolution.Minute, startUtc, endUtc, TickType.Trade, false) .SetDescription($"Not supported {nameof(SecurityType.Forex)} -> empty result"); diff --git a/QuantConnect.AlphaVantage.Tests/TestSetup.cs b/QuantConnect.AlphaVantage.Tests/TestSetup.cs index a1b6331..ea4e6ba 100644 --- a/QuantConnect.AlphaVantage.Tests/TestSetup.cs +++ b/QuantConnect.AlphaVantage.Tests/TestSetup.cs @@ -18,6 +18,7 @@ using System.IO; using NUnit.Framework; using System.Collections; +using QuantConnect.Tests; using QuantConnect.Logging; using QuantConnect.Configuration; @@ -61,6 +62,8 @@ private static void ReloadConfiguration() // resets the version among other things Globals.Reset(); + // Initialize providers dependency + TestGlobals.Initialize(); } } }