diff --git a/Common/Messages/Messages.Orders.cs b/Common/Messages/Messages.Orders.cs index 1562593b46ce..4eb9e2ea24d5 100644 --- a/Common/Messages/Messages.Orders.cs +++ b/Common/Messages/Messages.Orders.cs @@ -29,6 +29,8 @@ namespace QuantConnect /// public static partial class Messages { + private readonly static bool _languageIsCSharp = Configuration.Config.GetValue("algorithm-language") == Language.CSharp; + /// /// Provides user-facing messages for the class and its consumers or related classes /// @@ -354,7 +356,14 @@ public static string ZeroQuantity(Orders.OrderRequest request) [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string MissingSecurity(Orders.SubmitOrderRequest request) { - return Invariant($"You haven't requested {request.Symbol} data. Add this with AddSecurity() in the Initialize() Method."); + if (_languageIsCSharp) + { + return Invariant($"You haven't requested {request.Symbol} data. Add this with AddSecurity() in the Initialize() Method."); + } + else + { + return Invariant($"You haven't requested {request.Symbol} data. Add this with add_security() in the initialize() Method."); + } } /// @@ -365,8 +374,14 @@ public static string MissingSecurity(Orders.SubmitOrderRequest request) [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string WarmingUp(Orders.OrderRequest request) { - return Invariant($@"This operation is not allowed in Initialize or during warm up: OrderRequest.{ - request.OrderRequestType}. Please move this code to the OnWarmupFinished() method."); + if (_languageIsCSharp) + { + return Invariant($@"This operation is not allowed in Initialize or during warm up: OrderRequest.{request.OrderRequestType}. Please move this code to the OnWarmupFinished() method."); + } + else + { + return Invariant($@"This operation is not allowed in initialize or during warm up: OrderRequest.{request.OrderRequestType}. Please move this code to the on_warmup_finished() method."); + } } } diff --git a/Common/Messages/Messages.Securities.cs b/Common/Messages/Messages.Securities.cs index e2fe35e287a9..f9bc031a81a0 100644 --- a/Common/Messages/Messages.Securities.cs +++ b/Common/Messages/Messages.Securities.cs @@ -109,8 +109,9 @@ public static string TargetOrderMarginNotAboveMinimum(decimal absDifferenceOfMar [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string TargetOrderMarginNotAboveMinimum() { + var settingsMinimumOrderMarginPortfolioPercentage = _languageIsCSharp ? "Settings.MinimumOrderMarginPortfolioPercentage" : "settings.minimum_order_margin_portfolio_percentage"; return "Warning: Portfolio rebalance result ignored as it resulted in a single share trade recommendation which can generate high fees." + - " To disable minimum order size checks please set Settings.MinimumOrderMarginPortfolioPercentage = 0."; + $" To disable minimum order size checks please set {settingsMinimumOrderMarginPortfolioPercentage} = 0."; } /// @@ -132,7 +133,8 @@ public static string OrderQuantityLessThanLotSize(Securities.Security security, public static string FailedToConvergeOnTheTargetMargin(GetMaximumOrderQuantityForTargetBuyingPowerParameters parameters, decimal signedTargetFinalMarginValue, decimal orderFees) { - return Invariant($@"GetMaximumOrderQuantityForTargetBuyingPower failed to converge on the target margin: { + var getMaximumOrderQuantityForTargetBuyingPower = _languageIsCSharp ? "GetMaximumOrderQuantityForTargetBuyingPower" : "get_maximum_order_quantity_for_target_buying_power"; + return Invariant($@"{getMaximumOrderQuantityForTargetBuyingPower} failed to converge on the target margin: { signedTargetFinalMarginValue}; the following information can be used to reproduce the issue. Total Portfolio Cash: { parameters.Portfolio.Cash}; Security : {parameters.Security.Symbol.ID}; Price : {parameters.Security.Close}; Leverage: { parameters.Security.Leverage}; Order Fee: {orderFees}; Lot Size: { @@ -440,7 +442,8 @@ public static string OrderQuantityLessThanLotSizeOrderDetails(decimal targetOrde public static string FailedToConvergeOnTargetOrderValue(decimal targetOrderValue, decimal currentOrderValue, decimal orderQuantity, decimal orderFees, Securities.Security security) { - return Invariant($@"GetMaximumOrderQuantityForTargetBuyingPower failed to converge to target order value { + var getMaximumOrderQuantityForTargetBuyingPower = _languageIsCSharp ? "GetMaximumOrderQuantityForTargetBuyingPower" : "get_maximum_order_quantity_for_target_buying_power"; + return Invariant($@"{getMaximumOrderQuantityForTargetBuyingPower} failed to converge to target order value { targetOrderValue}. Current order value is {currentOrderValue}. Order quantity {orderQuantity}. Lot size is { security.SymbolProperties.LotSize}. Order fees {orderFees}. Security symbol {security.Symbol}"); } @@ -708,12 +711,12 @@ public static class Security /// /// String message saying: Security requires a valid SymbolProperties instance /// - public static string ValidSymbolPropertiesInstanceRequired = "Security requires a valid SymbolProperties instance."; + public static string ValidSymbolPropertiesInstanceRequired = _languageIsCSharp ? "Security requires a valid SymbolProperties instance." : "Security requires a valid symbol_properties instance."; /// /// String message saying: symbolProperties.QuoteCurrency must match the quoteCurrency.Symbol /// - public static string UnmatchingQuoteCurrencies = "symbolProperties.QuoteCurrency must match the quoteCurrency.Symbol"; + public static string UnmatchingQuoteCurrencies = _languageIsCSharp ? "symbolProperties.QuoteCurrency must match the quoteCurrency.Symbol" : "symbol_properties.quote_currency must match the quote_currency.symbol"; /// /// String message saying: Security.SetLocalTimeKeeper(LocalTimeKeeper) must be called in order to use the LocalTime property @@ -823,9 +826,8 @@ public static class SecurityManager [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string SymbolNotFoundInSecurities(QuantConnect.Symbol symbol) { - return Invariant($@"This asset symbol ({ - symbol}) was not found in your security list. Please add this security or check it exists before using it with 'Securities.ContainsKey(""{ - QuantConnect.SymbolCache.GetTicker(symbol)}"")'"); + var securitiesContainsKey = _languageIsCSharp ? "Securities.ContainsKey" : "securities.contains_key"; + return Invariant($@"This asset symbol ({symbol}) was not found in your security list. Please add this security or check it exists before using it with '{securitiesContainsKey}(""{QuantConnect.SymbolCache.GetTicker(symbol)}"")'"); } /// @@ -864,15 +866,17 @@ public static class SecurityPortfolioManager /// Returns a string message saying the AccountCurrency cannot be changed after adding a Security and that the method /// SetAccountCurrency() should be moved before AddSecurity() /// - public static string CannotChangeAccountCurrencyAfterAddingSecurity = - "Cannot change AccountCurrency after adding a Security. Please move SetAccountCurrency() before AddSecurity()."; + public static string CannotChangeAccountCurrencyAfterAddingSecurity = _languageIsCSharp ? + "Cannot change AccountCurrency after adding a Security. Please move SetAccountCurrency() before AddSecurity()." : + "Cannot change AccountCurrency after adding a Security. Please move set_account_currency() before add_security()."; /// /// Returns a string message saying the AccountCurrency cannot be changed after setting cash and that the method /// SetAccountCurrency() should be moved before SetCash() /// - public static string CannotChangeAccountCurrencyAfterSettingCash = - "Cannot change AccountCurrency after setting cash. Please move SetAccountCurrency() before SetCash()."; + public static string CannotChangeAccountCurrencyAfterSettingCash = _languageIsCSharp ? + "Cannot change AccountCurrency after setting cash. Please move SetAccountCurrency() before SetCash()." : + "Cannot change AccountCurrency after setting cash. Please move set_account_currency() before set_cash()."; /// /// Returns a string message saying the AccountCurrency has already been set and that the new value for this property @@ -936,8 +940,9 @@ public static class SecurityTransactionManager /// /// Returns a string message saying CancelOpenOrders operation is not allowed in Initialize or during warm up /// - public static string CancelOpenOrdersNotAllowedOnInitializeOrWarmUp = - "This operation is not allowed in Initialize or during warm up: CancelOpenOrders. Please move this code to the OnWarmupFinished() method."; + public static string CancelOpenOrdersNotAllowedOnInitializeOrWarmUp = _languageIsCSharp ? + "This operation is not allowed in Initialize or during warm up: CancelOpenOrders. Please move this code to the OnWarmupFinished() method." : + "This operation is not allowed in initialize or during warm up: cancel_open_orders. Please move this code to the on_warmup_finished() method."; /// /// Returns a string message saying the order was canceled by the CancelOpenOrders() at the given time @@ -945,7 +950,8 @@ public static class SecurityTransactionManager [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string OrderCanceledByCancelOpenOrders(DateTime time) { - return Invariant($"Canceled by CancelOpenOrders() at {time:o}"); + var cancelOpenOrders = _languageIsCSharp ? "CancelOpenOrders" : "cancel_open_orders"; + return Invariant($"Canceled by {cancelOpenOrders}() at {time:o}"); } /// @@ -975,17 +981,17 @@ public static class SymbolProperties /// /// String message saying the SymbolProperties LotSize can not be less than or equal to 0 /// - public static string InvalidLotSize = "SymbolProperties LotSize can not be less than or equal to 0"; + public static string InvalidLotSize = _languageIsCSharp ? "SymbolProperties LotSize can not be less than or equal to 0" : "symbol_properties LOT_SIZE can not be less than or equal to 0"; /// /// String message saying the SymbolProperties PriceMagnifier can not be less than or equal to 0 /// - public static string InvalidPriceMagnifier = "SymbolProprties PriceMagnifier can not be less than or equal to 0"; + public static string InvalidPriceMagnifier = _languageIsCSharp ? "SymbolProprties PriceMagnifier can not be less than or equal to 0" : "symbol_properties PRICE_MAGNIFIER can not be less than or equal to 0"; /// /// String message saying the SymbolProperties StrikeMultiplier can not be less than or equal to 0 /// - public static string InvalidStrikeMultiplier = "SymbolProperties StrikeMultiplier can not be less than or equal to 0"; + public static string InvalidStrikeMultiplier = _languageIsCSharp ? "SymbolProperties StrikeMultiplier can not be less than or equal to 0" : "symbol_properties STRIKE_MULTIPLIER can not be less than or equal to 0"; /// /// Parses a given SymbolProperties object into a string message