Lean icon indicating copy to clipboard operation
Lean copied to clipboard

No conversion path found error for ILS currency

Open superichmann opened this issue 2 years ago • 4 comments

Expected Behavior

The strategy should execute without any errors My strat is for US stocks.

Actual Behavior

Receiving the following error:

_20220607 15:28:12.808 ERROR:: FitnessScore.Initialize(): fitness score will not be calculated because the algorithms starting portfolio value is 0.
20220607 15:28:12.915 ERROR:: Engine.Run(): During the algorithm initialization, the following exception has occurred: System.ArgumentException: No conversion path found between source currency USD and destination currency ILS
   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 294
   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.Setup.BaseSetupHandler.SetupCurrencyConversions(IAlgorithm algorithm, UniverseSelection universeSelection) in /LeanCloud/CI.Builder/bin/Debug/src/QuantConnect/Lean/Engine/Setup/BaseSetupHandler.cs:line 57
   at QuantConnect.Lean.Engine.Setup.BrokerageSetupHandler.Setup(SetupHandlerParameters parameters) in /LeanCloud/CI.Builder/bin/Debug/src/QuantConnect/Lean/Engine/Setup/BrokerageSetupHandler.cs:line 324No conversion path found between source currency USD and destination currency
ILS in SecurityCurrencyConversion.cs:line 223 No conversion path found between source currency USD and destination currency ILS_
_20220607 15:28:12.943 ERROR:: During the algorithm initialization, the following exception has occurred: System.ArgumentException: No conversion path found between source currency USD and destination currency ILS
   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 294
   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.Setup.BaseSetupHandler.SetupCurrencyConversions(IAlgorithm algorithm, UniverseSelection universeSelection) in /LeanCloud/CI.Builder/bin/Debug/src/QuantConnect/Lean/Engine/Setup/BaseSetupHandler.cs:line 57
   at QuantConnect.Lean.Engine.Setup.BrokerageSetupHandler.Setup(SetupHandlerParameters parameters) in /LeanCloud/CI.Builder/bin/Debug/src/QuantConnect/Lean/Engine/Setup/BrokerageSetupHandler.cs:line 324No conversion path found between source currency USD and destination currency
ILS in SecurityCurrencyConversion.cs:line 223 No conversion path found between source currency USD and destination currency ILS_

Potential Solution

Reproducing the Problem

Create IBKR account with NIS as main currency (I cannot change that) Add paper money account

Create the following strat:

using QuantConnect.Data.Market;

namespace QuantConnect.Algorithm.CSharp
{
    public class Test002 : QCAlgorithm
    {
        public override void Initialize()
        {
            AddEquity("SPY", Resolution.Minute);
            SetBrokerageModel(Brokerages.BrokerageName.InteractiveBrokersBrokerage,AccountType.Margin);
        }
        public override void OnData(Slice data)
        {
            foreach (var item in data)
            {
                TradeBar tbCurr = item.Value as TradeBar;
                float fMid = (float)((tbCurr.Open + tbCurr.Close + tbCurr.High + tbCurr.Low) / 4);
                Debug("OnData:\t" + tbCurr.Time.ToString() + "\tMid:\t" + fMid.ToString());
            }
        }
    }
}

execute with lean live cli on IBKR with IBKR data stream (I have subscription)

System Information

Docker Desktop 4.8.2 (79419) lean, version 1.0.92 OS Name: Microsoft Windows 10 Pro OS Version: 10.0.19044 N/A Build 19044

superichmann avatar Jun 08 '22 10:06 superichmann

Hey @superichmann! Seems the account holds some ILS currency which has no valid pair in the SPDB. Adding the trading pairs for ILS should solve this issue

Martin-Molinero avatar Jun 08 '22 12:06 Martin-Molinero

Hi Martin! Thanks for the quick reply :)

Since I am using lean cli do I need to access the docker image while its running and alter the symbol-properties-database.csv file?

Could you please instruct me on how to do it? like what is the line I need to add?

or maybe just to add the data folder to config.json ?

Thanks :)

superichmann avatar Jun 08 '22 13:06 superichmann

Hi Martin! Thanks for the quick reply :)

Since I am using lean cli do I need to access the docker image while its running and alter the symbol-properties-database.csv file?

Could you please instruct me on how to do it? like what is the line I need to add?

or maybe just to add the data folder to config.json ?

Thanks :)

Hey! You need to update the symbol-properties-database.csv file in the CLIs {base installation}/data/symbol-properties folder & the market-hours-database.json at {base installation}/data/market-hours. If your down to it, we would welcome the PR for Lean too

Martin-Molinero avatar Jun 08 '22 23:06 Martin-Molinero

Hi again :) I have changed my main currency in ibkr account to USD (I managed to change it somehow:) and now lean seems to be working.

superichmann avatar Jun 11 '22 06:06 superichmann

Awaiting new currency addition to data folder.

jaredbroad avatar Feb 16 '23 15:02 jaredbroad