diff --git a/QuantConnect.AlpacaBrokerage/AlpacaBrokerage.DataQueueHandler.cs b/QuantConnect.AlpacaBrokerage/AlpacaBrokerage.DataQueueHandler.cs index c45a698..ff65749 100644 --- a/QuantConnect.AlpacaBrokerage/AlpacaBrokerage.DataQueueHandler.cs +++ b/QuantConnect.AlpacaBrokerage/AlpacaBrokerage.DataQueueHandler.cs @@ -65,7 +65,8 @@ 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"]); + // might not be there if only used as a data source + var usePaperTrading = job.BrokerageData.TryGetValue("alpaca-paper-trading", out var usePaper) && Convert.ToBoolean(usePaper); Initialize(apiKey, secretKey, accessToken, usePaperTrading, null, null); if (!IsConnected)