Skip to content

Commit

Permalink
fix: use 0Auth for some Alpaca clients (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
Romazes authored Aug 7, 2024
1 parent f42f8a3 commit 10af103
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions QuantConnect.AlpacaBrokerage/AlpacaBrokerage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,27 +158,28 @@ private void Initialize(string apiKey, string apiKeySecret, string accessToken,
_messageHandler = new(HandleTradeUpdate);
_symbolMapper = new AlpacaBrokerageSymbolMapper(_tradingClient);

if (secretKey != null)
{
// historical equity
_equityHistoricalDataClient = EnvironmentExtensions.GetAlpacaDataClient(environment, secretKey);
// historical equity
_equityHistoricalDataClient = EnvironmentExtensions.GetAlpacaDataClient(environment, tradingSecretKey ?? secretKey);

// historical options
_optionsHistoricalDataClient = EnvironmentExtensions.GetAlpacaOptionsDataClient(environment, tradingSecretKey ?? secretKey);

// historical options
_optionsHistoricalDataClient = EnvironmentExtensions.GetAlpacaOptionsDataClient(environment, secretKey);
// historical crypto
_cryptoHistoricalDataClient = EnvironmentExtensions.GetAlpacaCryptoDataClient(environment, tradingSecretKey ?? secretKey);

if (secretKey != null)
{
// equity streaming client
_equityStreamingClient = EnvironmentExtensions.GetAlpacaDataStreamingClient(environment, secretKey);

// historical crypto
_cryptoHistoricalDataClient = EnvironmentExtensions.GetAlpacaCryptoDataClient(environment, secretKey);
// streaming crypto
_cryptoStreamingClient = EnvironmentExtensions.GetAlpacaCryptoStreamingClient(environment, secretKey);

foreach (var streamingClient in new IStreamingClient[] { _cryptoStreamingClient, _equityStreamingClient, _orderStreamingClient })
{
streamingClient.Connected += (obj) => StreamingClient_Connected(streamingClient, obj);
streamingClient.OnWarning += (obj) => StreamingClient_OnWarning(streamingClient, obj);
streamingClient.SocketOpened += () => StreamingClient_SocketOpened(streamingClient); ;
streamingClient.SocketOpened += () => StreamingClient_SocketOpened(streamingClient);
streamingClient.SocketClosed += () => StreamingClient_SocketClosed(streamingClient);
streamingClient.OnError += (obj) => StreamingClient_OnError(streamingClient, obj);
}
Expand Down

0 comments on commit 10af103

Please sign in to comment.