Hi,
I am trying LEAN CLI. I found in 'symbol-properties-database.csv', there are already lots of binance coin already, like below:
binance,AAVEBKRW,crypto,AAVEBKRW,BKRW,1,1.00000000,0.00100000,AAVEBKRW binance,AAVEBNB,crypto,AAVEBNB,BNB,1,0.00010000,0.01000000,AAVEBNB binance,AAVEBTC,crypto,AAVEBTC,BTC,1,0.00000100,0.01000000,AAVEBTC Also in lean.json, I can see below:// binance configuration "binance-api-secret": "", "binance-api-key": "", But when i backtest in main.py as below,self.SetBrokerageModel(BrokerageName.BINANCE, AccountType.Cash)I still got below error:20210407 01:23:55.053 TRACE:: BacktestingResultHandler(): Sample Period Set: 21.96 20210407 01:23:55.056 TRACE:: Config.GetValue(): forward-console-messages - Using default value: True 20210407 01:23:55.971 ERROR:: Engine.Run(): During the algorithm initialization, the following exception has occurred: AttributeError : type object 'BrokerageName' has no attribute 'BINANCE' at Initialize self.SetBrokerageModel(BrokerageName.BINANCE in main.py:line 31 AttributeError : type object 'BrokerageName' has no attribute 'BINANCE' So does it mean LEAN still hardcode bitfinex and coinbase pro and cannot support binance yet. Or there are some work around? Thanks,henry
Jasper van Merle
Hi Henry,
It's not exactly clear to me what you're trying to do, but I think the following may help:
Henry111
Thanks, Jasper
I already changed to BrokerageName.Binance as you suggested. And also downloaded a test coin: BATUSDT (minute trade data) from Binance. And put it in ./data/crypto/binance/minute/batusdt. I only put 4 files for test (minute data) as below:
20210101_trade.zip
20210102_trade.zip
20210103_trade.zip
20210104_trade.zip
my main.py as below:
class CalmRedOrangeCrocodile(QCAlgorithm): def Initialize(self): self.SetStartDate(2021, 1, 1) self.SetEndDate(2021, 1, 3) self.SetBrokerageModel(BrokerageName.Binance, AccountType.Cash) self.AddCrypto('BATUSDT',Resolution.Minute, Market.Binance) def OnData(self, data): pass But when I run 'lean backtest':20210407 16:14:58.264 ERROR:: Engine.Run(): During the algorithm initialization, the following exception has occurred: Symbol can't be found in the Symbol Properties Database: BTCUSD Questions is I only want to backtest BATUSDT, why it need BTCUSD? I checked 'symbol-properties-database.csv', BATUSAT already there within Binance section. The full log output as below:20210407 16:20:43.956 TRACE:: Config.GetValue(): debug-mode - Using default value: False 20210407 16:20:43.958 TRACE:: Config.Get(): Configuration key not found. Key: plugin-directory - Using default value: 20210407 16:20:44.014 TRACE:: Python for .NET Assembly: Python.Runtime, Version=2.0.1.0, Culture=neutral, PublicKeyToken=5000fea6cba702dd 20210407 16:20:44.044 TRACE:: Python for .NET Assembly: nPython, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null 20210407 16:20:44.045 TRACE:: Config.Get(): Configuration key not found. Key: data-directory - Using default value: ../../../Data/ 20210407 16:20:44.046 TRACE:: Config.Get(): Configuration key not found. Key: version-id - Using default value: 20210407 16:20:44.046 TRACE:: Config.Get(): Configuration key not found. Key: cache-location - Using default value: /Lean/Data 20210407 16:20:44.047 TRACE:: Engine.Main(): LEAN ALGORITHMIC TRADING ENGINE v2.5.0.0 Mode: DEBUG (64bit) 20210407 16:20:44.051 TRACE:: Engine.Main(): Started 4:20 PM 20210407 16:20:44.053 TRACE:: Config.GetValue(): job-project-id - Using default value: 0 20210407 16:20:44.057 TRACE:: Config.GetValue(): regression-update-statistics - Using default value: False 20210407 16:20:44.058 TRACE:: Config.Get(): Configuration key not found. Key: lean-manager-type - Using default value: LocalLeanManager 20210407 16:20:44.249 TRACE:: JobQueue.NextJob(): Selected /LeanCLI/main.py 20210407 16:20:44.304 TRACE:: Config.GetValue(): scheduled-event-leaky-bucket-capacity - Using default value: 120 20210407 16:20:44.304 TRACE:: Config.GetValue(): scheduled-event-leaky-bucket-time-interval-minutes - Using default value: 1440 20210407 16:20:44.304 TRACE:: Config.GetValue(): scheduled-event-leaky-bucket-refill-amount - Using default value: 18 20210407 16:20:44.307 TRACE:: Config.Get(): Configuration key not found. Key: algorithm-id - Using default value: main 20210407 16:20:44.312 TRACE:: Config.Get(): Configuration key not found. Key: data-permission-manager - Using default value: DataPermissionManager 20210407 16:20:44.330 TRACE:: Config.Get(): Configuration key not found. Key: object-store-root - Using default value: ./storage 20210407 16:20:44.333 TRACE:: AlgorithmManager.CreateTokenBucket(): Initializing LeakyBucket: Capacity: 120 RefillAmount: 18 TimeInterval: 1440 20210407 16:20:44.335 TRACE:: Config.GetValue(): algorithm-manager-time-loop-maximum - Using default value: 20 20210407 16:20:44.343 TRACE:: TextSubscriptionDataSourceReader.SetCacheSize(): Setting cache size to 71582788 items 20210407 16:20:44.749 TRACE:: Config.GetValue(): algorithm-creation-timeout - Using default value: 90 20210407 16:20:44.755 TRACE:: PythonInitializer.Initialize(): start... PythonEngine.Initialize(): Runtime.Initialize()... Runtime.Initialize(): Py_Initialize... Runtime.Initialize(): PyEval_InitThreads... Runtime.Initialize(): Initialize types... Runtime.Initialize(): Initialize types end. Runtime.Initialize(): AssemblyManager.Initialize()... Runtime.Initialize(): AssemblyManager.UpdatePath()... PythonEngine.Initialize(): GetCLRModule()... PythonEngine.Initialize(): clr GetManifestResourceStream... 20210407 16:20:45.315 TRACE:: PythonInitializer.Initialize(): ended 20210407 16:20:45.318 TRACE:: AlgorithmPythonWrapper(): Python version 3.6.8 |Anaconda, Inc.| (default, Dec 30 2018, 01:25:33) [GCC 7.3.0]: Importing python module main 20210407 16:20:46.301 TRACE:: AlgorithmPythonWrapper(): main successfully imported. 20210407 16:20:46.303 TRACE:: AlgorithmPythonWrapper(): Creating IAlgorithm instance. 20210407 16:20:46.741 TRACE:: Config.GetValue(): mute-python-library-logging - Using default value: True 20210407 16:20:46.765 TRACE:: LocalObjectStore.Initialize(): Storage Root: /Lean/Launcher/bin/Debug/storage/QCAlgorithm 20210407 16:20:46.864 TRACE:: Config.Get(): Configuration key not found. Key: security-data-feeds - Using default value: 20210407 16:20:46.966 ERROR:: ConsoleSetupHandler.Setup(): System.ArgumentException: Symbol can't be found in the Symbol Properties Database: BTCUSD at QuantConnect.Securities.SecurityService.CreateSecurity (QuantConnect.Symbol symbol, System.Collections.Generic.List`1[T] subscriptionDataConfigList, System.Decimal leverage, System.Boolean addToSymbolCache) [0x0009f] in <c30ce690247848b4a0fd72de161d85ef>:0 at QuantConnect.Securities.SecurityManager.CreateSecurity (QuantConnect.Symbol symbol, System.Collections.Generic.List`1[T] subscriptionDataConfigList, System.Decimal leverage, System.Boolean addToSymbolCache) [0x00000] in <c30ce690247848b4a0fd72de161d85ef>:0 at QuantConnect.Benchmarks.SecurityBenchmark.CreateInstance (QuantConnect.Securities.SecurityManager securities, QuantConnect.Symbol symbol) [0x00007] in <c30ce690247848b4a0fd72de161d85ef>:0 at QuantConnect.Brokerages.BinanceBrokerageModel.GetBenchmark (QuantConnect.Securities.SecurityManager securities) [0x00013] in <c30ce690247848b4a0fd72de161d85ef>:0 at QuantConnect.Algorithm.QCAlgorithm.PostInitialize () [0x00127] in <187af351250f4358b298e9cbf0f8eb27>:0 at QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.PostInitialize () [0x00001] in <490dbdee50044494b83dbe4c8c041db0>:0 at QuantConnect.Lean.Engine.Setup.ConsoleSetupHandler.Setup (QuantConnect.Lean.Engine.Setup.SetupHandlerParameters parameters) [0x001ab] in <3191ed8f1a844f898b5adc70af26eaf9>:0 20210407 16:20:46.971 TRACE:: BacktestingResultHandler(): Sample Period Set: 04.00 20210407 16:20:46.975 TRACE:: Time.TradeableDates(): Security Count: 1 20210407 16:20:46.980 TRACE:: Config.GetValue(): forward-console-messages - Using default value: True 20210407 16:20:47.814 ERROR:: Engine.Run(): During the algorithm initialization, the following exception has occurred: Symbol can't be found in the Symbol Properties Database: BTCUSD 20210407 16:20:47.815 TRACE:: JOB HANDLERS: 20210407 16:20:47.816 TRACE:: DataFeed: QuantConnect.Lean.Engine.DataFeeds.FileSystemDataFeed 20210407 16:20:47.816 TRACE:: Setup: QuantConnect.Lean.Engine.Setup.ConsoleSetupHandler 20210407 16:20:47.816 TRACE:: RealTime: QuantConnect.Lean.Engine.RealTime.BacktestingRealTimeHandler 20210407 16:20:47.816 TRACE:: Results: QuantConnect.Lean.Engine.Results.BacktestingResultHandler 20210407 16:20:47.816 TRACE:: Transactions: QuantConnect.Lean.Engine.TransactionHandlers.BacktestingTransactionHandler 20210407 16:20:47.816 TRACE:: Alpha: QuantConnect.Lean.Engine.Alphas.DefaultAlphaHandler 20210407 16:20:47.816 TRACE:: ObjectStore: QuantConnect.Lean.Engine.Storage.LocalObjectStore 20210407 16:20:47.816 TRACE:: History Provider: QuantConnect.Lean.Engine.HistoricalData.SubscriptionDataReaderHistoryProvider 20210407 16:20:47.817 TRACE:: FileSystemDataFeed.Exit(): Start. Setting cancellation token... 20210407 16:20:47.820 TRACE:: FileSystemDataFeed.Exit(): Exit Finished. 20210407 16:20:47.820 TRACE:: DefaultAlphaHandler.Exit(): Exiting... 20210407 16:20:47.828 TRACE:: DefaultAlphaHandler.Exit(): Ended 20210407 16:20:47.831 TRACE:: BacktestingResultHandler.Exit(): starting... 20210407 16:20:47.842 TRACE:: BacktestingResultHandler.Exit(): Saving logs... 20210407 16:20:47.844 ERROR:: During the algorithm initialization, the following exception has occurred: Symbol can't be found in the Symbol Properties Database: BTCUSD 20210407 16:20:47.844 TRACE:: Debug: Your log was successfully created and can be retrieved from: /Results/main-log.txt 20210407 16:20:47.844 TRACE:: BacktestingResultHandler.Run(): Ending Thread... 20210407 16:20:47.844 TRACE:: StopSafely(): waiting for 'Result Thread' thread to stop... 20210407 16:20:48.002 TRACE:: STATISTICS:: OrderListHash d41d8cd98f00b204e9800998ecf8427e 20210407 16:20:48.002 TRACE:: BacktestingResultHandler.SendAnalysisResult(): Processed final packet 20210407 16:20:48.004 TRACE:: Engine.Run(): Disconnecting from brokerage... 20210407 16:20:48.005 TRACE:: Engine.Run(): Disposing of setup handler... 20210407 16:20:48.006 TRACE:: Engine.Main(): Analysis Completed and Results Posted. Engine.Main(): Analysis Complete. 20210407 16:20:48.008 TRACE:: Engine.Main(): Packet removed from queue: main 20210407 16:20:48.008 TRACE:: LeanEngineSystemHandlers.Dispose(): start... 20210407 16:20:48.008 TRACE:: LeanEngineSystemHandlers.Dispose(): Disposed of system handlers. 20210407 16:20:48.008 TRACE:: LeanEngineAlgorithmHandlers.Dispose(): start... 20210407 16:20:48.010 TRACE:: LeanEngineAlgorithmHandlers.Dispose(): Disposed of algorithm handlers. 20210407 16:20:48.011 TRACE:: Program.Main(): Exiting Lean... Error: Something went wrong while running 'test_lean_2' in the 'backtesting' environment, the output is stored in 'test_lean_2/backtests/2021-04-07_12-20-43'Jared Broad
Sorry, we do not yet officially support Binance - it's coming soon though.
You need it to convert the currency back to your account currency, USD.
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.
Henry111
Thanks for the great suggestion! After convert all USDT to USD, like change name from BATUSDT to BATUSD, it works now!
QC is a great team to support, really appreciate it!
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!