From ed101246241d30906212677cdde534e4cd0b718b Mon Sep 17 00:00:00 2001 From: Martin-Molinero Date: Fri, 13 Sep 2024 16:38:15 -0300 Subject: [PATCH] Catch missing brokerage data config if used as IDQH only (#18) --- .../AlpacaBrokerage.DataQueueHandler.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/QuantConnect.AlpacaBrokerage/AlpacaBrokerage.DataQueueHandler.cs b/QuantConnect.AlpacaBrokerage/AlpacaBrokerage.DataQueueHandler.cs index c45a698..2b5bc9f 100644 --- a/QuantConnect.AlpacaBrokerage/AlpacaBrokerage.DataQueueHandler.cs +++ b/QuantConnect.AlpacaBrokerage/AlpacaBrokerage.DataQueueHandler.cs @@ -65,7 +65,12 @@ public void SetJob(LiveNodePacket job) // required for trading job.BrokerageData.TryGetValue("alpaca-access-token", out var accessToken); - var usePaperTrading = Convert.ToBoolean(job.BrokerageData["alpaca-paper-trading"]); + var usePaperTrading = false; + // might not be there if only used as a data source + if (job.BrokerageData.TryGetValue("alpaca-paper-trading", out var usePaper)) + { + usePaperTrading = Convert.ToBoolean(usePaper); + } Initialize(apiKey, secretKey, accessToken, usePaperTrading, null, null); if (!IsConnected)