Hi,
I tried to add over 20 cryptos in the algorithm, but always has error or cannot get the data in minute, Is there any limitation for how many data I can subscribe same time when using LEAN CLI?
class Live1(QCAlgorithm): def Initialize(self): # The default currency is USD, which Binance doesn't offer self.SetBrokerageModel(BrokerageName.Binance, AccountType.Cash) self.UniverseSettings.Resolution = Resolution.Minute self.SetAccountCurrency("USDT") # Use BTCUSDT from Binance as benchmark self.SetBenchmark(Symbol.Create("BTCUSDT", SecurityType.Crypto, Market.Binance)) symbols=['AAVEUSDT', 'ADAUSDT', 'AIONUSDT', 'ALGOUSDT', 'ALPHAUSDT', 'ANKRUSDT', 'ANTUSDT', 'ARDRUSDT', 'ARPAUSDT', 'ATOMUSDT', 'AUDIOUSDT', 'AUDUSDT', 'AVAXUSDT', 'BALUSDT', 'BANDUSDT', 'BATUSDT', 'BCCUSDT', 'BCHABCUSDT', 'BCHSVUSDT', 'BCHUSDT'] for symbol in symbols: try: self.AddCrypto(symbol, Resolution.Minute, Market.Binance) except: self.Debug('%s symbol has error' %symbol) self.count = 0 def OnData(self, data): self.count+=1 self.Debug(data.Time) for symbol in data.keys(): self.Debug(symbol.Value) 20210421 03:46:52.666 TRACE:: Cash.EnsureCurrencyDataFeed(): Adding IOSTUSDT for cash IOST currency feed 20210421 03:46:52.732 ERROR:: LiveTradingResultHandler.Update(): Algorithm not yet initialized. 20210421 03:46:56.372 ERROR:: Engine.Run(): During the algorithm initialization, the following exception has occurred: System.InvalidOperationException: Sequence contains no elements at System.Linq.Enumerable.Last[TSource] (System.Collections.Generic.IEnumerable`1[T] source) [0x00010] in <92922d9bda2f4e1cba9242d052be6d43>:0 at QuantConnect.Brokerages.Binance.BinanceRestApiClient+<GetHistory>d__29.MoveNext () [0x001ac] in <07a9093c75f148e2bbec3f5667d02a9a>:0 at QuantConnect.Brokerages.Binance.BinanceBrokerage+<GetHistory>d__19.MoveNext () [0x001b8] in <07a9093c75f148e2bbec3f5667d02a9a>:0 at QuantConnect.Lean.Engine.DataFeeds.Enumerators.FillForwardEnumerator.MoveNext () [0x00088] in <41d49fab4cfb4dc7a517dc0e8743c717>:0 at QuantConnect.Lean.Engine.DataFeeds.Enumerators.SubscriptionDataEnumerator.MoveNext () [0x00001] in <41d49fab4cfb4dc7a517dc0e8743c717>:0 at QuantConnect.Lean.Engine.DataFeeds.Subscription.MoveNext () [0x00010] in <41d49fab4cfb4dc7a517dc0e8743c717>:0 at QuantConnect.Lean.Engine.HistoricalData.SynchronizingHistoryProvider+<CreateSliceEnumerableFromSubscriptions>d__3.MoveNext () [0x000b9] in <41d49fab4cfb4dc7a517dc0e8743c717>:0 at QuantConnect.Data.SliceExtensions.PushThrough (System.Collections.Generic.IEnumerable`1[T] slices, System.Action`1[T] handler) [0x000b5] in <3f25e994a47f486daae31b960e968fc5>:0 at QuantConnect.Lean.Engine.Setup.BaseSetupHandler.SetupCurrencyConversions (QuantConnect.Interfaces.IAlgorithm algorithm, QuantConnect.Lean.Engine.DataFeeds.UniverseSelection universeSelection) [0x00169] in <41d49fab4cfb4dc7a517dc0e8743c717>:0 at QuantConnect.Lean.Engine.Setup.BrokerageSetupHandler.Setup (QuantConnect.Lean.Engine.Setup.SetupHandlerParameters parameters) [0x0030b] in <41d49fab4cfb4dc7a517dc0e8743c717>:0 Sequence contains no elements 20210421 03:46:56.373 TRACE:: JOB HANDLERS: 20210421 03:46:56.373 TRACE:: DataFeed: QuantConnect.Lean.Engine.DataFeeds.LiveTradingDataFeed 20210421 03:46:56.374 TRACE:: Setup: QuantConnect.Lean.Engine.Setup.BrokerageSetupHandler 20210421 03:46:56.374 TRACE:: RealTime: QuantConnect.Lean.Engine.RealTime.LiveTradingRealTimeHandler 20210421 03:46:56.374 TRACE:: Results: QuantConnect.Lean.Engine.Results.LiveTradingResultHandler 20210421 03:46:56.374 TRACE:: Transactions: QuantConnect.Lean.Engine.TransactionHandlers.BrokerageTransactionHandler 20210421 03:46:56.374 TRACE:: Alpha: QuantConnect.Lean.Engine.Alphas.DefaultAlphaHandler 20210421 03:46:56.374 TRACE:: ObjectStore: QuantConnect.Lean.Engine.Storage.LocalObjectStore 20210421 03:46:56.374 TRACE:: History Provider: QuantConnect.Lean.Engine.HistoricalData.BrokerageHistoryProvider 20210421 03:46:56.374 TRACE:: Brokerage: QuantConnect.Brokerages.Binance.BinanceBrokerage 20210421 03:46:56.374 TRACE:: LiveTradingDataFeed.Exit(): Start. Setting cancellation token... 20210421 03:46:56.374 TRACE:: BaseDataExchange(CustomDataExchange) Stopping... 20210421 03:46:56.374 TRACE:: LiveTradingDataFeed.Exit(): Exit Finished. 20210421 03:46:56.374 TRACE:: DefaultAlphaHandler.Exit(): Exiting... 20210421 03:46:56.375 TRACE:: BaseDataExchange(CustomDataExchange).ConsumeQueue(): Cancellation requested. Exiting... 20210421 03:46:56.381 TRACE:: DefaultAlphaHandler.Exit(): Ended 20210421 03:46:56.390 ERROR:: During the algorithm initialization, the following exception has occurred: System.InvalidOperationException: Sequence contains no elements at System.Linq.Enumerable.Last[TSource] (System.Collections.Generic.IEnumerable`1[T] source) [0x00010] in <92922d9bda2f4e1cba9242d052be6d43>:0 at QuantConnect.Brokerages.Binance.BinanceRestApiClient+<GetHistory>d__29.MoveNext () [0x001ac] in <07a9093c75f148e2bbec3f5667d02a9a>:0 at QuantConnect.Brokerages.Binance.BinanceBrokerage+<GetHistory>d__19.MoveNext () [0x001b8] in <07a9093c75f148e2bbec3f5667d02a9a>:0 at QuantConnect.Lean.Engine.DataFeeds.Enumerators.FillForwardEnumerator.MoveNext () [0x00088] in <41d49fab4cfb4dc7a517dc0e8743c717>:0 at QuantConnect.Lean.Engine.DataFeeds.Enumerators.SubscriptionDataEnumerator.MoveNext () [0x00001] in <41d49fab4cfb4dc7a517dc0e8743c717>:0 at QuantConnect.Lean.Engine.DataFeeds.Subscription.MoveNext () [0x00010] in <41d49fab4cfb4dc7a517dc0e8743c717>:0 at QuantConnect.Lean.Engine.HistoricalData.SynchronizingHistoryProvider+<CreateSliceEnumerableFromSubscriptions>d__3.MoveNext () [0x000b9] in <41d49fab4cfb4dc7a517dc0e8743c717>:0 at QuantConnect.Data.SliceExtensions.PushThrough (System.Collections.Generic.IEnumerable`1[T] slices, System.Action`1[T] handler) [0x000b5] in <3f25e994a47f486daae31b960e968fc5>:0 at QuantConnect.Lean.Engine.Setup.BaseSetupHandler.SetupCurrencyConversions (QuantConnect.Interfaces.IAlgorithm algorithm, QuantConnect.Lean.Engine.DataFeeds.UniverseSelection universeSelection) [0x00169] in <41d49fab4cfb4dc7a517dc0e8743c717>:0 at QuantConnect.Lean.Engine.Setup.BrokerageSetupHandler.Setup (QuantConnect.Lean.Engine.Setup.SetupHandlerParameters parameters) [0x0030b] in <41d49fab4cfb4dc7a517dc0e8743c717>:0 Sequence contains no elements 20210421 03:46:56.390 ERROR:: LiveTradingResultHandler.Update(): Algorithm not yet initialized. 20210421 03:46:56.390 TRACE:: Debug: Binance account base currency: USD Changing account currency from USD to USDT... 20210421 03:46:56.390 TRACE:: LiveTradingResultHandler.Run(): Ending Thread... 20210421 03:46:56.392 TRACE:: StopSafely(): waiting for 'Result Thread' thread to stop... 20210421 03:46:56.393 TRACE:: LiveTradingResultHandler.SendFinalResult(): Starting... 20210421 03:46:56.464 TRACE:: LiveTradingResultHandler.SendFinalResult(): Finished storing results. Start sending... 20210421 03:46:56.464 TRACE:: LiveTradingResultHandler.SendFinalResult(): Ended 20210421 03:46:56.464 TRACE:: Engine.Run(): Disconnecting from brokerage... 20210421 03:46:56.479 TRACE:: WebSocketClientWrapper connection task ended: wss://stream.binance.com:9443/ws/SMSA5BitsEGj3joaK7bU5NItfe02dlJsyFTJGcqfdu6CRHNEUkYPQX6ChPIj 20210421 03:46:56.479 TRACE:: WebSocketClientWrapper.OnClose(): Connection closed (IsOpen:False, State:Aborted): wss://stream.binance.com:9443/ws/SMSA5BitsEGj3joaK7bU5NItfe02dlJsyFTJGcqfdu6CRHNEUkYPQX6ChPIj 20210421 03:46:56.638 TRACE:: Engine.Run(): Disposing of setup handler... 20210421 03:46:56.639 TRACE:: BrokerageSetupHandler.Setup(): Found data queue handler to dispose: QuantConnect.Brokerages.Binance.BinanceBrokerage 20210421 03:46:56.639 TRACE:: Engine.Main(): Analysis Completed and Results Posted. Engine.Main(): Analysis Complete. 20210421 03:46:56.640 TRACE:: Engine.Main(): Packet removed from queue: main 20210421 03:46:56.641 TRACE:: LeanEngineSystemHandlers.Dispose(): start... 20210421 03:46:56.641 TRACE:: LeanEngineSystemHandlers.Dispose(): Disposed of system handlers. 20210421 03:46:56.641 TRACE:: LeanEngineAlgorithmHandlers.Dispose(): start... 20210421 03:46:56.641 TRACE:: BrokerageSetupHandler.Setup(): Found data queue handler to dispose: QuantConnect.Brokerages.Binance.BinanceBrokerage 20210421 03:46:56.642 TRACE:: LeanEngineAlgorithmHandlers.Dispose(): Disposed of algorithm handlers. 20210421 03:46:56.643 TRACE:: Program.Main(): Exiting Lean... Error: Something went wrong while running 'live-1' in the 'live-binance' environment, the output is stored in 'live-1/live/2021-04-20_23-46-41' Thanks,henry
Henry111
One update, above same script, when I run live live-paper (paper trading), it seems work. Bur when live live-binance, it reports error. Not sure why?
Thanks,
henry
Jasper van Merle
Hi Henry,
It seems our symbol properties database is a bit outdated, Binance has previously renamed BCHABCUSDT to BCHUSDT and they delisted BCHSVUSDT. If you remove those two symbols from the list of symbols it should work.
We have a GitHub issue open for the feature of automatic updates to Binance symbols in the symbol properties database, you can subscribe to that to track our progress.
Henry111
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!