Skip to content

Commit

Permalink
feat: missed resolution warning flag
Browse files Browse the repository at this point in the history
rename: make more sense of variables
  • Loading branch information
Romazes committed Feb 26, 2024
1 parent 6288c2f commit 05e4e10
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions QuantConnect.AlphaVantage/AlphaVantageDataDownloader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,23 @@ public class AlphaVantageDataDownloader : IDataDownloader, IDisposable
/// <summary>
/// Indicates whether the warning for invalid history <see cref="TickType"/> has been fired.
/// </summary>
private bool _invalidHistoryDataTypeWarningFired;
private bool _invalidHistoryDataTypeErrorFired;

/// <summary>
/// Indicates whether the warning for invalid <see cref="SecurityType"/> has been fired.
/// </summary>
private bool _invalidSecurityTypeWarningFired;

/// <summary>
/// Indicates whether a warning for an invalid <see cref="Resolution"/> has been fired, where the resolution is neither daily nor minute-based.
/// </summary>
private bool _invalidResolutionWarningFired;

/// <summary>
/// Indicates whether a warning for an invalid start time has been fired, where the start time is greater than or equal to the end time in UTC.
/// </summary>
private bool _invalidStartTimeErrorFired;

/// <summary>
/// Represents a mapping of symbols to their corresponding time zones for exchange information.
/// </summary>
Expand Down Expand Up @@ -124,17 +134,21 @@ public AlphaVantageDataDownloader(IRestClient restClient, string apiKey)

if (endUtc < startUtc)
{
Log.Error($"{nameof(AlphaVantageDataDownloader)}.{nameof(Get)}:InvalidDateRange. The history request start date must precede the end date, no history returned");
if (!_invalidStartTimeErrorFired)
{
Log.Error($"{nameof(AlphaVantageDataDownloader)}.{nameof(Get)}:InvalidDateRange. The history request start date must precede the end date, no history returned");
_invalidStartTimeErrorFired = true;
}
return null;
}

if (tickType != TickType.Trade)
{
if (!_invalidHistoryDataTypeWarningFired)
if (!_invalidHistoryDataTypeErrorFired)
{
Log.Error($"{nameof(AlphaVantageDataDownloader)}.{nameof(Get)}: Not supported data type - {tickType}. " +
$"Currently available support only for historical of type - TradeBar");
_invalidHistoryDataTypeWarningFired = true;
_invalidHistoryDataTypeErrorFired = true;
}
return null;
}
Expand Down Expand Up @@ -164,7 +178,11 @@ public AlphaVantageDataDownloader(IRestClient restClient, string apiKey)
data = GetDailyData(request, startUtc, endUtc, symbol);
break;
default:
Log.Trace($"{nameof(AlphaVantageDataDownloader)}.{resolution} resolution not supported by API.");
if (!_invalidResolutionWarningFired)
{
Log.Trace($"{nameof(AlphaVantageDataDownloader)}.{resolution} resolution not supported by API.");
_invalidResolutionWarningFired = true;
}
return null;
}

Expand Down

0 comments on commit 05e4e10

Please sign in to comment.