Hi,
Usually, I need to download Binance data, then change symbol name from ‘USDT’ to ‘USD’ (like change from ‘BTCUSDT’ to ‘BTCUSD’), otherwise the local backtest will fail (the error is ‘USDT’ cannnot be currency etc). Then when I use the same algorithm for live trading, I need to change the ‘USD’ back to ‘USDT’ again.
It is kind of complex for the procedure. Can LEAN CLI now directly support ‘USDT’ for backtest now? So I can directly use same algorithm for both backtest and live trading without any change?
Below was the topic discussed before. I just want to know if we have some progress or we still need to change ‘USDT’ to ‘USD’ for backtest so far.
’
Thanks,
henry
Jasper van Merle
Hi Henry,
You can use QCAlgorithm.SetAccountCurrency to set your backtesting account currency. I think I shared this before, this is the template that I use myself that works with both backtesting and live trading:
Henry111
Thanks, Jasper
I gave it a try, the ‘lean backtest’ works now with ‘USDT (like ‘BTCUSDT’) directly. But when I use ’lean report', it began to give some errors like below. Even I already set buying for ‘BNTUSDT’, but it seems the lean still try to find the ratio between BNT and USD.
20210526 22:52:20.916 TRACE:: QuantConnect.Report.Main(): Parsing source files...backtest-data-source-file.json,
20210526 22:52:22.225 TRACE:: QuantConnect.Report.Main(): Instantiating report...
20210526 22:52:22.286 TRACE:: QuantConnect.Report.Report(): Processing backtesting orders
20210526 22:52:22.305 TRACE:: Config.Get(): Configuration key not found. Key: plugin-directory - Using default value:
20210526 22:52:22.308 TRACE:: Config.Get(): Configuration key not found. Key: composer-dll-directory - Using default value: /Lean/Report/bin/Debug/
20210526 22:52:22.498 TRACE:: Config.Get(): Configuration key not found. Key: data-directory - Using default value: ../../../Data/
20210526 22:52:22.498 TRACE:: Config.Get(): Configuration key not found. Key: version-id - Using default value:
20210526 22:52:22.498 TRACE:: Config.Get(): Configuration key not found. Key: cache-location - Using default value: /Lean/Data
20210526 22:52:22.657 TRACE:: Config.GetValue(): scheduled-event-leaky-bucket-capacity - Using default value: 120
20210526 22:52:22.657 TRACE:: Config.GetValue(): scheduled-event-leaky-bucket-time-interval-minutes - Using default value: 1440
20210526 22:52:22.657 TRACE:: Config.GetValue(): scheduled-event-leaky-bucket-refill-amount - Using default value: 18
20210526 22:52:22.666 TRACE:: Config.Get(): Configuration key not found. Key: results-destination-folder - Using default value: /Lean/Report/bin/Debug
20210526 22:52:22.730 TRACE:: DataManager.AddSubscription(): Unable to add subscription for: QC-UNIVERSE-USERDEFINED-BINANCE-CRYPTO,QC-UNIVERSE-USERDEFINED-BINANCE-CRYPTO,Daily,TradeBar,Trade,Adjusted,Internal
20210526 22:52:22.737 TRACE:: BacktestingResultHandler(): Sample Period Set: 10.44
20210526 22:52:22.739 TRACE:: Time.TradeableDates(): Security Count: 124
20210526 22:52:22.743 TRACE:: Config.GetValue(): forward-console-messages - Using default value: True
Unhandled exception. System.ArgumentException: No conversion path found between source currency BNT and destination currency USD
at QuantConnect.Securities.CurrencyConversion.SecurityCurrencyConversion.LinearSearch(String sourceCurrency, String destinationCurrency, IList`1 existingSecurities, IEnumerable`1 potentialSymbols, Func`2 makeNewSecurity) in
/LeanCloud/CI.Builder/bin/Debug/src/QuantConnect/Lean/Common/Securities/CurrencyConversion/SecurityCurrencyConversion.cs:line 223
at QuantConnect.Securities.Cash.EnsureCurrencyDataFeed(SecurityManager securities, SubscriptionManager subscriptions, IReadOnlyDictionary`2 marketMap, SecurityChanges changes, ISecurityService securityService, String
accountCurrency, Resolution defaultResolution) in /LeanCloud/CI.Builder/bin/Debug/src/QuantConnect/Lean/Common/Securities/Cash.cs:line 285
at QuantConnect.Securities.CashBook.EnsureCurrencyDataFeeds(SecurityManager securities, SubscriptionManager subscriptions, IReadOnlyDictionary`2 marketMap, SecurityChanges changes, ISecurityService securityService, Resolution
defaultResolution) in /LeanCloud/CI.Builder/bin/Debug/src/QuantConnect/Lean/Common/Securities/CashBook.cs:line 119
at QuantConnect.Lean.Engine.DataFeeds.CurrencySubscriptionDataConfigManager.EnsureCurrencySubscriptionDataConfigs(SecurityChanges securityChanges, IBrokerageModel brokerageModel) in
/LeanCloud/CI.Builder/bin/Debug/src/QuantConnect/Lean/Engine/DataFeeds/CurrencySubscriptionDataConfigManager.cs:line 140
at QuantConnect.Lean.Engine.DataFeeds.UniverseSelection.EnsureCurrencyDataFeeds(SecurityChanges securityChanges) in /LeanCloud/CI.Builder/bin/Debug/src/QuantConnect/Lean/Engine/DataFeeds/UniverseSelection.cs:line 447
at QuantConnect.Lean.Engine.Setup.BaseSetupHandler.SetupCurrencyConversions(IAlgorithm algorithm, UniverseSelection universeSelection) in /LeanCloud/CI.Builder/bin/Debug/src/QuantConnect/Lean/Engine/Setup/BaseSetupHandler.cs:line
57
at QuantConnect.Report.PortfolioLooper..ctor(Double startingCash, List`1 orders, Resolution resolution) in /LeanCloud/CI.Builder/bin/Debug/src/QuantConnect/Lean/Report/PortfolioLooper/PortfolioLooper.cs:line 142
at QuantConnect.Report.PortfolioLooper.FromOrders(Series`2 equityCurve, IEnumerable`1 orders, Boolean liveSeries)+MoveNext() in /LeanCloud/CI.Builder/bin/Debug/src/QuantConnect/Lean/Report/PortfolioLooper/PortfolioLooper.cs:line
299
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at QuantConnect.Report.Report..ctor(String name, String description, String version, BacktestResult backtest, LiveResult live, String pointInTimePortfolioDestination) in
/LeanCloud/CI.Builder/bin/Debug/src/QuantConnect/Lean/Report/Report.cs:line 61
at QuantConnect.Report.Program.Main(String[] args) in /LeanCloud/CI.Builder/bin/Debug/src/QuantConnect/Lean/Report/Program.cs:line 70
Error: Something went wrong while running the LEAN Report Creator, see the logs above for more information
Jasper van Merle
Hi Henry,
The error you are seeing comes from the report creator assuming your algorithm uses USD as account currency. I have created an issue for this behavior on GitHub, you can subscribe to that to track our progress on 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!