Skip to content

Commit

Permalink
Merge pull request #9 from QuantConnect/bug-add-websocket-rate-gate-l…
Browse files Browse the repository at this point in the history
…imit

Add missing websocket rate gate limit
  • Loading branch information
Martin-Molinero authored Feb 23, 2023
2 parents 9ad8d7b + 4bde91d commit 12a7bea
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions QuantConnect.GDAXBrokerage/GDAXBrokerage.Messaging.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public partial class GDAXBrokerage
private readonly SymbolPropertiesDatabaseSymbolMapper _symbolMapper = new SymbolPropertiesDatabaseSymbolMapper(Market.GDAX);
private bool _isDataQueueHandler;
private LiveNodePacket _job;
private RateGate _websocketRateLimit = new(7, TimeSpan.FromSeconds(1));

/// <summary>
/// Data Aggregator
Expand Down Expand Up @@ -505,6 +506,8 @@ protected override bool Subscribe(IEnumerable<Symbol> symbols)
signature = token.Signature,
});

_websocketRateLimit.WaitToProceed();

WebSocket.Send(json);

Log.Trace("GDAXBrokerage.Subscribe: Sent subscribe.");
Expand Down Expand Up @@ -581,6 +584,8 @@ public bool Unsubscribe(IEnumerable<Symbol> symbols)
product_ids = products
};

_websocketRateLimit.WaitToProceed();

WebSocket.Send(JsonConvert.SerializeObject(payload));
}
return true;
Expand Down
2 changes: 2 additions & 0 deletions QuantConnect.GDAXBrokerage/GDAXBrokerage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,8 @@ public override void Dispose()

_publicEndpointRateLimiter.Dispose();
_privateEndpointRateLimiter.Dispose();

_websocketRateLimit.DisposeSafely();
}

private class ModulesReadLicenseRead : Api.RestResponse
Expand Down

0 comments on commit 12a7bea

Please sign in to comment.