From d3877c8ea92667e91bd19e6ac2039973f7877d75 Mon Sep 17 00:00:00 2001 From: Roman Yavnikov <45608740+Romazes@users.noreply.github.com> Date: Mon, 5 Feb 2024 20:13:38 +0200 Subject: [PATCH] remove: AlphaVantage from ToolBox (#7751) --- .../AlphaVantageDataDownloaderTests.cs | 278 ------------------ .../AlphaVantageAuthenticator.cs | 52 ---- .../AlphaVantageDataDownloader.cs | 262 ----------------- .../AlphaVantageDownloaderProgram.cs | 67 ----- ToolBox/AlphaVantageDownloader/TimeSeries.cs | 44 --- ToolBox/Program.cs | 12 - 6 files changed, 715 deletions(-) delete mode 100644 Tests/ToolBox/AlphaVantageDownloader/AlphaVantageDataDownloaderTests.cs delete mode 100644 ToolBox/AlphaVantageDownloader/AlphaVantageAuthenticator.cs delete mode 100644 ToolBox/AlphaVantageDownloader/AlphaVantageDataDownloader.cs delete mode 100644 ToolBox/AlphaVantageDownloader/AlphaVantageDownloaderProgram.cs delete mode 100644 ToolBox/AlphaVantageDownloader/TimeSeries.cs diff --git a/Tests/ToolBox/AlphaVantageDownloader/AlphaVantageDataDownloaderTests.cs b/Tests/ToolBox/AlphaVantageDownloader/AlphaVantageDataDownloaderTests.cs deleted file mode 100644 index 963c8db166fb..000000000000 --- a/Tests/ToolBox/AlphaVantageDownloader/AlphaVantageDataDownloaderTests.cs +++ /dev/null @@ -1,278 +0,0 @@ -/* - * QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals. - * Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -*/ - -using Moq; -using NUnit.Framework; -using QuantConnect.Data.Market; -using QuantConnect.ToolBox.AlphaVantageDownloader; -using RestSharp; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net; - -namespace QuantConnect.Tests.ToolBox.AlphaVantageDownloader -{ - [TestFixture] - public class AlphaVantageDataDownloaderTests - { - private const string API_KEY = "TESTKEY"; - private const string BASE_URL = "https://www.alphavantage.co/"; - - private Mock _avClient; - private AlphaVantageDataDownloader _downloader; - private readonly TradeBarComparer _tradeBarComparer = new TradeBarComparer(); - - [SetUp] - public void SetUp() - { - _avClient = new Mock(); - _avClient.SetupAllProperties(); - - _downloader = new AlphaVantageDataDownloader(_avClient.Object, API_KEY); - } - - [TearDown] - public void TearDown() - { - _downloader.Dispose(); - } - - [Test] - public void GetDailyLessThan100DaysGetsCompactDailyData() - { - var ticker = "AAPL"; - var symbol = Symbol.Create(ticker, SecurityType.Equity, Market.USA); - var resolution = Resolution.Daily; - var start = DateTime.UtcNow.AddDays(-100); - var end = DateTime.UtcNow; - - var expectedBars = new[] - { - new TradeBar(DateTime.Parse("2021-04-05"), symbol, 133.64m, 136.69m, 133.40m, 135.93m, 5471616), - new TradeBar(DateTime.Parse("2021-04-06"), symbol, 135.58m, 135.64m, 134.09m, 134.22m, 3620964), - }; - - IRestRequest request = null; - _avClient.Setup(m => m.Execute(It.IsAny(), It.IsAny())) - .Callback((IRestRequest r, Method m) => request = r) - .Returns(new RestResponse - { - StatusCode = HttpStatusCode.OK, - ContentType = "application/x-download", - Content = "timestamp,open,high,low,close,volume\n" + - "2021-04-06,135.5800,135.6400,134.0900,134.2200,3620964\n" + - "2021-04-05,133.6400,136.6900,133.4000,135.9300,5471616\n" - }) - .Verifiable(); - - var result = _downloader.Get(new DataDownloaderGetParameters(symbol, resolution, start, end)); - - _avClient.Verify(); - var requestUrl = BuildUrl(request); - Assert.AreEqual(Method.GET, request.Method); - Assert.AreEqual($"{BASE_URL}query?symbol=AAPL&datatype=csv&function=TIME_SERIES_DAILY", requestUrl); - - Assert.IsInstanceOf>(result); - var bars = ((IEnumerable)result).ToList(); - Assert.AreEqual(2, bars.Count); - Assert.That(bars[0], Is.EqualTo(expectedBars[0]).Using(_tradeBarComparer)); - Assert.That(bars[1], Is.EqualTo(expectedBars[1]).Using(_tradeBarComparer)); - } - - [Test] - public void GetDailyGreaterThan100DaysGetsFullDailyData() - { - var ticker = "AAPL"; - var symbol = Symbol.Create(ticker, SecurityType.Equity, Market.USA); - var resolution = Resolution.Daily; - var start = DateTime.UtcNow.AddYears(-2); - var end = DateTime.UtcNow; - - var expectedBars = new[] - { - new TradeBar(DateTime.Parse("2021-04-05"), symbol, 133.64m, 136.69m, 133.40m, 135.93m, 5471616), - new TradeBar(DateTime.Parse("2021-04-06"), symbol, 135.58m, 135.64m, 134.09m, 134.22m, 3620964), - }; - - IRestRequest request = null; - _avClient.Setup(m => m.Execute(It.IsAny(), It.IsAny())) - .Callback((IRestRequest r, Method m) => request = r) - .Returns(new RestResponse - { - StatusCode = HttpStatusCode.OK, - ContentType = "application/x-download", - Content = "timestamp,open,high,low,close,volume\n" + - "2021-04-06,135.5800,135.6400,134.0900,134.2200,3620964\n" + - "2021-04-05,133.6400,136.6900,133.4000,135.9300,5471616\n" - }) - .Verifiable(); - - var result = _downloader.Get(new DataDownloaderGetParameters(symbol, resolution, start, end)); - - _avClient.Verify(); - var requestUrl = BuildUrl(request); - Assert.AreEqual(Method.GET, request.Method); - Assert.AreEqual($"{BASE_URL}query?symbol=AAPL&datatype=csv&function=TIME_SERIES_DAILY&outputsize=full", requestUrl); - - Assert.IsInstanceOf>(result); - var bars = ((IEnumerable)result).ToList(); - Assert.AreEqual(2, bars.Count); - Assert.That(bars[0], Is.EqualTo(expectedBars[0]).Using(_tradeBarComparer)); - Assert.That(bars[1], Is.EqualTo(expectedBars[1]).Using(_tradeBarComparer)); - } - - [TestCase(Resolution.Minute, "1min")] - [TestCase(Resolution.Hour, "60min")] - public void GetMinuteHourGetsIntradayData(Resolution resolution, string interval) - { - var ticker = "IBM"; - var symbol = Symbol.Create(ticker, SecurityType.Equity, Market.USA); - var year = DateTime.UtcNow.Year - 1; - var start = new DateTime(year, 04, 05); - var end = new DateTime(year, 05, 06); - - var expectedBars = new[] - { - new TradeBar(start.AddHours(9.5), symbol, 133.71m, 133.72m, 133.62m, 133.62m, 1977), - new TradeBar(start.AddHours(10.5), symbol, 134.30m, 134.56m, 134.245m, 134.34m, 154723), - new TradeBar(end.AddHours(9.5), symbol, 135.54m, 135.56m, 135.26m, 135.28m, 2315), - new TradeBar(end.AddHours(10.5), symbol, 134.905m,134.949m, 134.65m, 134.65m, 101997), - }; - - var responses = new[] - { - "time,open,high,low,close,volume\n" + - $"{year}-04-05 10:30:00,134.3,134.56,134.245,134.34,154723\n" + - $"{year}-04-05 09:30:00,133.71,133.72,133.62,133.62,1977\n", - "time,open,high,low,close,volume\n" + - $"{year}-05-06 10:30:00,134.905,134.949,134.65,134.65,101997\n" + - $"{year}-05-06 09:30:00,135.54,135.56,135.26,135.28,2315\n", - }; - - var requestCount = 0; - var requestUrls = new List(); - _avClient.Setup(m => m.Execute(It.IsAny(), It.IsAny())) - .Callback((IRestRequest r, Method m) => requestUrls.Add(BuildUrl(r))) - .Returns(() => new RestResponse - { - StatusCode = HttpStatusCode.OK, - ContentType = "application/x-download", - Content = responses[requestCount++] - }) - .Verifiable(); - - var result = _downloader.Get(new DataDownloaderGetParameters(symbol, resolution, start, end)).ToList(); - - _avClient.Verify(); - Assert.AreEqual(2, requestUrls.Count); - Assert.AreEqual($"{BASE_URL}query?symbol=IBM&datatype=csv&function=TIME_SERIES_INTRADAY_EXTENDED&adjusted=false&interval={interval}&slice=year1month2", requestUrls[0]); - Assert.AreEqual($"{BASE_URL}query?symbol=IBM&datatype=csv&function=TIME_SERIES_INTRADAY_EXTENDED&adjusted=false&interval={interval}&slice=year1month1", requestUrls[1]); - - var bars = result.Cast().ToList(); - Assert.AreEqual(4, bars.Count); - Assert.That(bars[0], Is.EqualTo(expectedBars[0]).Using(_tradeBarComparer)); - Assert.That(bars[1], Is.EqualTo(expectedBars[1]).Using(_tradeBarComparer)); - Assert.That(bars[2], Is.EqualTo(expectedBars[2]).Using(_tradeBarComparer)); - Assert.That(bars[3], Is.EqualTo(expectedBars[3]).Using(_tradeBarComparer)); - } - - [TestCase(Resolution.Tick)] - [TestCase(Resolution.Second)] - public void GetUnsupportedResolutionThrowsException(Resolution resolution) - { - var ticker = "IBM"; - var symbol = Symbol.Create(ticker, SecurityType.Equity, Market.USA); - var start = DateTime.UtcNow.AddMonths(-2); - var end = DateTime.UtcNow; - - Assert.Throws(() => _downloader.Get(new DataDownloaderGetParameters(symbol, resolution, start, end)).ToList()); - } - - [TestCase(Resolution.Minute)] - [TestCase(Resolution.Hour)] - [TestCase(Resolution.Daily)] - public void UnexpectedResponseContentTypeThrowsException(Resolution resolution) - { - var ticker = "IBM"; - var symbol = Symbol.Create(ticker, SecurityType.Equity, Market.USA); - var start = DateTime.UtcNow.AddMonths(-2); - var end = DateTime.UtcNow; - - _avClient.Setup(m => m.Execute(It.IsAny(), It.IsAny())) - .Returns(() => new RestResponse - { - StatusCode = HttpStatusCode.OK, - ContentType = "application/json" - }) - .Verifiable(); - - Assert.Throws(() => _downloader.Get(new DataDownloaderGetParameters(symbol, resolution, start, end)).ToList()); - } - - [Test] - public void GetIntradayDataGreaterThanTwoYearsThrowsException() - { - var ticker = "IBM"; - var symbol = Symbol.Create(ticker, SecurityType.Equity, Market.USA); - var resolution = Resolution.Minute; - var start = DateTime.UtcNow.AddYears(-2).AddDays(-1); - var end = DateTime.UtcNow; - - Assert.Throws(() => _downloader.Get(new DataDownloaderGetParameters(symbol, resolution, start, end)).ToList()); - } - - [Test] - public void AuthenticatorAddsApiKeyToRequest() - { - var request = new Mock(); - var authenticator = _avClient.Object.Authenticator; - - Assert.NotNull(authenticator); - authenticator.Authenticate(_avClient.Object, request.Object); - request.Verify(m => m.AddOrUpdateParameter("apikey", API_KEY)); - } - - private string BuildUrl(IRestRequest request) - { - if (request == null) - throw new ArgumentNullException(nameof(request)); - - var client = new RestClient(BASE_URL); - var uri = client.BuildUri(request); - - return uri.ToString(); - } - - private class TradeBarComparer : IEqualityComparer - { - public bool Equals(TradeBar x, TradeBar y) - { - if (x == null || y == null) - return false; - - return x.Symbol == y.Symbol && - x.Time == y.Time && - x.Open == y.Open && - x.High == y.High && - x.Low == y.Low && - x.Close == y.Close && - x.Volume == y.Volume; - } - - public int GetHashCode(TradeBar obj) => obj.GetHashCode(); - } - } -} diff --git a/ToolBox/AlphaVantageDownloader/AlphaVantageAuthenticator.cs b/ToolBox/AlphaVantageDownloader/AlphaVantageAuthenticator.cs deleted file mode 100644 index f4d317d11f90..000000000000 --- a/ToolBox/AlphaVantageDownloader/AlphaVantageAuthenticator.cs +++ /dev/null @@ -1,52 +0,0 @@ -/* - * QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals. - * Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -*/ - -using RestSharp; -using RestSharp.Authenticators; -using System; - -namespace QuantConnect.ToolBox.AlphaVantageDownloader -{ - /// - /// Implements authentication for Alpha Vantage API - /// - internal class AlphaVantageAuthenticator : IAuthenticator - { - private readonly string _apiKey; - - /// - /// Construct authenticator - /// - /// API key - /// See https://www.alphavantage.co/support/#api-key to get a free key. - public AlphaVantageAuthenticator(string apiKey) - { - if (string.IsNullOrEmpty(apiKey)) - { - throw new ArgumentNullException(nameof(apiKey)); - } - - _apiKey = apiKey; - } - - /// - /// Authenticate request - /// - /// The - /// The - public void Authenticate(IRestClient client, IRestRequest request) - => request.AddOrUpdateParameter("apikey", _apiKey); - } -} diff --git a/ToolBox/AlphaVantageDownloader/AlphaVantageDataDownloader.cs b/ToolBox/AlphaVantageDownloader/AlphaVantageDataDownloader.cs deleted file mode 100644 index 046e20ad7479..000000000000 --- a/ToolBox/AlphaVantageDownloader/AlphaVantageDataDownloader.cs +++ /dev/null @@ -1,262 +0,0 @@ -/* - * QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals. - * Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -*/ - -using CsvHelper; -using QuantConnect.Data; -using QuantConnect.Data.Market; -using QuantConnect.Logging; -using QuantConnect.Util; -using RestSharp; -using System; -using System.Collections.Generic; -using System.Globalization; -using System.IO; -using System.Linq; -using QuantConnect.Securities; - -namespace QuantConnect.ToolBox.AlphaVantageDownloader -{ - /// - /// Alpha Vantage data downloader - /// - public class AlphaVantageDataDownloader : IDataDownloader, IDisposable - { - private readonly MarketHoursDatabase _marketHoursDatabase; - private readonly IRestClient _avClient; - private readonly RateGate _rateGate; - private bool _disposed; - - /// - /// Construct AlphaVantageDataDownloader with default RestClient - /// - /// API key - public AlphaVantageDataDownloader(string apiKey) : this(new RestClient(), apiKey) - { - } - - /// - /// Dependency injection constructor - /// - /// The to use - /// API key - public AlphaVantageDataDownloader(IRestClient restClient, string apiKey) - { - _avClient = restClient; - _marketHoursDatabase = MarketHoursDatabase.FromDataFolder(); - _avClient.BaseUrl = new Uri("https://www.alphavantage.co/"); - _avClient.Authenticator = new AlphaVantageAuthenticator(apiKey); - - _rateGate = new RateGate(5, TimeSpan.FromMinutes(1)); // Free API is limited to 5 requests/minute - } - - /// - /// Get historical data enumerable for a single symbol, type and resolution given this start and end time (in UTC). - /// - /// model class for passing in parameters for historical data - /// Enumerable of base data for this symbol - public IEnumerable Get(DataDownloaderGetParameters dataDownloaderGetParameters) - { - var symbol = dataDownloaderGetParameters.Symbol; - var resolution = dataDownloaderGetParameters.Resolution; - var startUtc = dataDownloaderGetParameters.StartUtc; - var endUtc = dataDownloaderGetParameters.EndUtc; - var tickType = dataDownloaderGetParameters.TickType; - - if (tickType != TickType.Trade) - { - return Enumerable.Empty(); - } - - var request = new RestRequest("query", DataFormat.Json); - request.AddParameter("symbol", symbol.Value); - request.AddParameter("datatype", "csv"); - - IEnumerable data = null; - switch (resolution) - { - case Resolution.Minute: - case Resolution.Hour: - data = GetIntradayData(request, startUtc, endUtc, resolution); - break; - case Resolution.Daily: - data = GetDailyData(request, startUtc, endUtc, symbol); - break; - default: - throw new ArgumentOutOfRangeException(nameof(resolution), $"{resolution} resolution not supported by API."); - } - - var period = resolution.ToTimeSpan(); - return data.Select(d => new TradeBar(d.Time, symbol, d.Open, d.High, d.Low, d.Close, d.Volume, period)); - } - - /// - /// Get data from daily API - /// - /// Base request - /// Start time - /// End time - /// Symbol to download - /// - private IEnumerable GetDailyData(RestRequest request, DateTime startUtc, DateTime endUtc, Symbol symbol) - { - request.AddParameter("function", "TIME_SERIES_DAILY"); - - // The default output only includes 100 trading days of data. If we want need more, specify full output - if (GetBusinessDays(startUtc, endUtc, symbol) > 100) - { - request.AddParameter("outputsize", "full"); - } - - return GetTimeSeries(request); - } - - /// - /// Get data from intraday API - /// - /// Base request - /// Start time - /// End time - /// Data resolution to request - /// - private IEnumerable GetIntradayData(RestRequest request, DateTime startUtc, DateTime endUtc, Resolution resolution) - { - request.AddParameter("function", "TIME_SERIES_INTRADAY_EXTENDED"); - request.AddParameter("adjusted", "false"); - switch (resolution) - { - case Resolution.Minute: - request.AddParameter("interval", "1min"); - break; - case Resolution.Hour: - request.AddParameter("interval", "60min"); - break; - default: - throw new ArgumentOutOfRangeException($"{resolution} resolution not supported by intraday API."); - } - - var slices = GetSlices(startUtc, endUtc); - foreach (var slice in slices) - { - request.AddOrUpdateParameter("slice", slice); - var data = GetTimeSeries(request); - foreach (var record in data) - { - yield return record; - } - } - } - - /// - /// Execute request and parse response. - /// - /// The request - /// data - private IEnumerable GetTimeSeries(RestRequest request) - { - if (_rateGate.IsRateLimited) - { - Log.Trace("Requests are limited to 5 per minute. Reduce the time between start and end times or simply wait, and this process will continue automatically."); - } - - _rateGate.WaitToProceed(); - //var url = _avClient.BuildUri(request); - Log.Trace("Downloading /{0}?{1}", request.Resource, string.Join("&", request.Parameters)); - var response = _avClient.Get(request); - - if (response.ContentType != "application/x-download") - { - throw new FormatException($"Unexpected content received from API.\n{response.Content}"); - } - - using (var reader = new StringReader(response.Content)) - { - using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture)) - { - return csv.GetRecords() - .OrderBy(t => t.Time) - .ToList(); // Execute query before readers are disposed. - } - } - } - - /// - /// Get slice names for date range. - /// See https://www.alphavantage.co/documentation/#intraday-extended - /// - /// Start date - /// End date - /// Slice names - private static IEnumerable GetSlices(DateTime startUtc, DateTime endUtc) - { - if ((DateTime.UtcNow - startUtc).TotalDays > 365 * 2) - { - throw new ArgumentOutOfRangeException(nameof(startUtc), "Intraday data is only available for the last 2 years."); - } - - var timeSpan = endUtc - startUtc; - var months = (int)Math.Floor(timeSpan.TotalDays / 30); - - for (var i = months; i >= 0; i--) - { - var year = i / 12 + 1; - var month = i % 12 + 1; - yield return $"year{year}month{month}"; - } - } - - /// - /// From https://stackoverflow.com/questions/1617049/calculate-the-number-of-business-days-between-two-dates - /// - private int GetBusinessDays(DateTime start, DateTime end, Symbol symbol) - { - var exchangeHours = _marketHoursDatabase.GetExchangeHours(symbol.ID.Market, symbol, symbol.SecurityType); - - var current = start.Date; - var days = 0; - while (current < end) - { - if (exchangeHours.IsDateOpen(current)) - { - days++; - } - current = current.AddDays(1); - } - - return days; - } - - protected virtual void Dispose(bool disposing) - { - if (!_disposed) - { - if (disposing) - { - // dispose managed state (managed objects) - _rateGate.Dispose(); - } - - // free unmanaged resources (unmanaged objects) and override finalizer - _disposed = true; - } - } - - public void Dispose() - { - // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method - Dispose(disposing: true); - GC.SuppressFinalize(this); - } - } -} diff --git a/ToolBox/AlphaVantageDownloader/AlphaVantageDownloaderProgram.cs b/ToolBox/AlphaVantageDownloader/AlphaVantageDownloaderProgram.cs deleted file mode 100644 index b13a45932d44..000000000000 --- a/ToolBox/AlphaVantageDownloader/AlphaVantageDownloaderProgram.cs +++ /dev/null @@ -1,67 +0,0 @@ -/* - * QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals. - * Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -*/ - -using System; -using QuantConnect.Util; -using QuantConnect.Data; -using QuantConnect.Logging; -using System.Collections.Generic; - -namespace QuantConnect.ToolBox.AlphaVantageDownloader -{ - public static class AlphaVantageDownloaderProgram - { - /// - /// Primary entry point to the program. - /// - public static void AlphaVantageDownloader(List tickers, string resolution, DateTime fromDate, DateTime toDate, string apiKey) - { - if (resolution.IsNullOrEmpty() || tickers.IsNullOrEmpty()) - { - Console.WriteLine("AlphaVantageDownloader ERROR: '--tickers=' or '--resolution=' parameter is missing"); - Console.WriteLine("--tickers=eg SPY,AAPL"); - Console.WriteLine("--resolution=Minute/Hour/Daily"); - Environment.Exit(1); - } - try - { - var castResolution = (Resolution)Enum.Parse(typeof(Resolution), resolution); - var startDate = fromDate.ConvertToUtc(TimeZones.NewYork); - var endDate = toDate.ConvertToUtc(TimeZones.NewYork); - - // fix end date - endDate = new DateTime(Math.Min(endDate.Ticks, DateTime.Now.AddDays(-1).Ticks)); - - using (var downloader = new AlphaVantageDataDownloader(apiKey)) - { - foreach (var ticker in tickers) - { - // Download the data - var symbol = Symbol.Create(ticker, SecurityType.Equity, Market.USA); - var data = downloader.Get(new DataDownloaderGetParameters(symbol, castResolution, startDate, endDate)); - - // Save the data - var writer = new LeanDataWriter(castResolution, symbol, Globals.DataFolder); - writer.Write(data); - } - } - } - catch (Exception err) - { - Log.Error(err); - } - } - } -} diff --git a/ToolBox/AlphaVantageDownloader/TimeSeries.cs b/ToolBox/AlphaVantageDownloader/TimeSeries.cs deleted file mode 100644 index a1ff533dae5b..000000000000 --- a/ToolBox/AlphaVantageDownloader/TimeSeries.cs +++ /dev/null @@ -1,44 +0,0 @@ -/* - * QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals. - * Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -*/ - -using CsvHelper.Configuration.Attributes; -using System; - -namespace QuantConnect.ToolBox.AlphaVantageDownloader -{ - /// - /// Alpha Vantage time series model - /// - internal class TimeSeries - { - [Name("time", "timestamp")] - public DateTime Time { get; set; } - - [Name("open")] - public decimal Open { get; set; } - - [Name("high")] - public decimal High { get; set; } - - [Name("low")] - public decimal Low { get; set; } - - [Name("close")] - public decimal Close { get; set; } - - [Name("volume")] - public decimal Volume { get; set; } - } -} diff --git a/ToolBox/Program.cs b/ToolBox/Program.cs index ad0bef0c7065..e3083b68d81c 100644 --- a/ToolBox/Program.cs +++ b/ToolBox/Program.cs @@ -16,7 +16,6 @@ using QuantConnect.Interfaces; using QuantConnect.Logging; using QuantConnect.ToolBox.AlgoSeekFuturesConverter; -using QuantConnect.ToolBox.AlphaVantageDownloader; using QuantConnect.ToolBox.CoarseUniverseGenerator; using QuantConnect.ToolBox.CoinApiDataConverter; using QuantConnect.ToolBox.CryptoiqDownloader; @@ -95,17 +94,6 @@ var factorFileProvider YahooDownloaderProgram.YahooDownloader(tickers, resolution, fromDate, toDate); break; - case "avdl": - case "alphavantagedownloader": - AlphaVantageDownloaderProgram.AlphaVantageDownloader( - tickers, - resolution, - fromDate, - toDate, - GetParameterOrExit(optionsObject, "api-key") - ); - break; - default: PrintMessageAndExit(1, "ERROR: Unrecognized --app value"); break;