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)