Skip to content

Commit

Permalink
feat: add stop spamming flags
Browse files Browse the repository at this point in the history
feat: null sign
refactor: remove extra else block
  • Loading branch information
Romazes committed Feb 23, 2024
1 parent ff7e0f4 commit 4c2f7fa
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 9 deletions.
27 changes: 23 additions & 4 deletions QuantConnect.CoinAPI/CoinApiDataHistoryProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,23 @@ public partial class CoinApiDataProvider
/// </summary>
private bool _invalidHistoryDataTypeWarningFired;

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

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


public override void Initialize(HistoryProviderInitializeParameters parameters)
{
// NOP
}

public override IEnumerable<Slice> GetHistory(IEnumerable<HistoryRequest> requests, DateTimeZone sliceTimeZone)
public override IEnumerable<Slice>? GetHistory(IEnumerable<HistoryRequest> requests, DateTimeZone sliceTimeZone)
{
var subscriptions = new List<Subscription>();
foreach (var request in requests)
Expand All @@ -65,17 +76,25 @@ public override IEnumerable<Slice> GetHistory(IEnumerable<HistoryRequest> reques
return CreateSliceEnumerableFromSubscriptions(subscriptions, sliceTimeZone);
}

public IEnumerable<BaseData> GetHistory(HistoryRequest historyRequest)
public IEnumerable<BaseData>? GetHistory(HistoryRequest historyRequest)
{
if (!CanSubscribe(historyRequest.Symbol))
{
Log.Error($"CoinApiDataProvider.GetHistory(): Invalid security type {historyRequest.Symbol.SecurityType}");
if (!_invalidSecurityTypeWarningFired)
{
Log.Error($"CoinApiDataProvider.GetHistory(): Invalid security type {historyRequest.Symbol.SecurityType}");
_invalidSecurityTypeWarningFired = true;
}
return null;
}

if (historyRequest.Resolution == Resolution.Tick)
{
Log.Error($"CoinApiDataProvider.GetHistory(): No historical ticks, only OHLCV timeseries");
if (!_invalidResolutionTypeWarningFired)
{
Log.Error($"CoinApiDataProvider.GetHistory(): No historical ticks, only OHLCV timeseries");
_invalidResolutionTypeWarningFired = true;
}
return null;
}

Expand Down
8 changes: 3 additions & 5 deletions QuantConnect.CoinAPI/CoinApiDataProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public void SetJob(LiveNodePacket job)
/// <exception cref="ArgumentException"></exception>
private void Initialize(string apiKey, string product)
{
// ValidateSubscription();
ValidateSubscription();

_apiKey = apiKey;

Expand Down Expand Up @@ -365,10 +365,8 @@ private void SendHelloMessage(IEnumerable<string> subscribeFilter)
{
throw new Exception("Not connected...");
}
else
{
IsConnected = true;
}

IsConnected = true;

_nextHelloMessageUtcTime = DateTime.UtcNow.Add(_minimumTimeBetweenHelloMessages);
}
Expand Down

0 comments on commit 4c2f7fa

Please sign in to comment.