Skip to content

Commit

Permalink
feat: init globals providers
Browse files Browse the repository at this point in the history
  • Loading branch information
Romazes committed Feb 22, 2024
1 parent 9e679fd commit 19e88c5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
27 changes: 13 additions & 14 deletions QuantConnect.AlphaVantage.Tests/AlphaVantageDataDownloaderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -57,13 +60,11 @@ public static IEnumerable<TestCaseData> 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);
}
}

Expand Down Expand Up @@ -94,20 +95,18 @@ public static IEnumerable<TestCaseData> 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");
Expand Down
3 changes: 3 additions & 0 deletions QuantConnect.AlphaVantage.Tests/TestSetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using System.IO;
using NUnit.Framework;
using System.Collections;
using QuantConnect.Tests;
using QuantConnect.Logging;
using QuantConnect.Configuration;

Expand Down Expand Up @@ -61,6 +62,8 @@ private static void ReloadConfiguration()

// resets the version among other things
Globals.Reset();
// Initialize providers dependency
TestGlobals.Initialize();
}
}
}

0 comments on commit 19e88c5

Please sign in to comment.