17 using System.Collections.Generic;
18 using System.Runtime.CompilerServices;
31 public static partial class Messages
38 public static string ReturnOverMaximumDrawdownKey =
"Return Over Maximum Drawdown";
40 public static string PortfolioTurnoverKey =
"Portfolio Turnover";
42 public static string TotalInsightsGeneratedKey =
"Total Insights Generated";
44 public static string TotalInsightsClosedKey =
"Total Insights Closed";
46 public static string TotalInsightsAnalysisCompletedKey =
"Total Insights Analysis Completed";
48 public static string LongInsightCountKey =
"Long Insight Count";
50 public static string ShortInsightCountKey =
"Short Insight Count";
52 public static string LongShortRatioKey =
"Long/Short Ratio";
60 public static string ChartSeriesAlreadyExists =
"Chart series name already exists";
68 [MethodImpl(MethodImplOptions.AggressiveInlining)]
71 return Invariant($
"{instance.Time:o} - {instance.y}");
80 [MethodImpl(MethodImplOptions.AggressiveInlining)]
83 return Invariant($
@"{instance.Time:o} - (O:{instance.Open} H: {instance.High} L: {
84 instance.Low} C: {instance.Close})");
93 [MethodImpl(MethodImplOptions.AggressiveInlining)]
94 public static string FailedConversionToDecimal(
string value)
96 return $
"The value {value} cannot be converted to a decimal number";
105 public static string ClearMethodNotImplemented =
"Types deriving from 'ExtendedDictionary' must implement the 'void Clear() method.";
107 public static string RemoveMethodNotImplemented =
108 "Types deriving from 'ExtendedDictionary' must implement the 'void Remove(Symbol) method.";
110 public static string IndexerBySymbolNotImplemented =
111 "Types deriving from 'ExtendedDictionary' must implement the 'T this[Symbol] method.";
113 [MethodImpl(MethodImplOptions.AggressiveInlining)]
116 return $
"Clear/clear method call is an invalid operation. {instance.GetType().Name} is a read-only collection.";
119 [MethodImpl(MethodImplOptions.AggressiveInlining)]
122 return $
"Remove/pop method call is an invalid operation. {instance.GetType().Name} is a read-only collection.";
125 [MethodImpl(MethodImplOptions.AggressiveInlining)]
126 public static string TickerNotFoundInSymbolCache(
string ticker)
128 return $
"The ticker {ticker} was not found in the SymbolCache. Use the Symbol object as key instead. " +
129 "Accessing the securities collection/slice object by string ticker is only available for securities added with " +
130 "the AddSecurity-family methods. For more details, please check out the documentation.";
133 [MethodImpl(MethodImplOptions.AggressiveInlining)]
136 return $
"popitem method is not supported for {instance.GetType().Name}";
139 [MethodImpl(MethodImplOptions.AggressiveInlining)]
142 return $
"'{symbol}' wasn't found in the {instance.GetType().Name} object, likely because there was no-data at this moment in " +
143 "time and it wasn't possible to fillforward historical data. Please check the data exists before accessing it with " +
144 $
"data.ContainsKey(\"{symbol}\"). The collection is read-only, cannot set default.";
147 [MethodImpl(MethodImplOptions.AggressiveInlining)]
150 return $
"update method call is an invalid operation. {instance.GetType().Name} is a read-only collection.";
159 public static string ErrorAdjustingSymbolByOffset =
160 "Adjusting a symbol by an offset is currently only supported for non canonical futures";
162 public static string NullDataProvider =
163 $
"The provided '{nameof(IDataProvider)}' instance is null. Are you missing some initialization step?";
165 public static string NullOrEmptySourceToConvertToHexString =
"Source cannot be null or empty.";
167 public static string CreateOptionChainRequiresOptionSymbol =
"CreateOptionChain requires an option symbol.";
169 public static string CreateFutureChainRequiresFutureSymbol =
"CreateFutureChain requires a future symbol.";
171 public static string GreatestCommonDivisorEmptyList =
"The list of values cannot be empty";
173 [MethodImpl(MethodImplOptions.AggressiveInlining)]
174 public static string DownloadDataFailed(
string url)
176 return $
"failed for: '{url}'";
179 [MethodImpl(MethodImplOptions.AggressiveInlining)]
182 return $
"{symbol}: The security does not have an accurate price as it has not yet received a bar of data. " +
183 "Before placing a trade (or using SetHoldings) warm up your algorithm with SetWarmup, or use slice.Contains(symbol) " +
184 "to confirm the Slice object has price before using the data. Data does not necessarily all arrive at the same " +
185 "time so your algorithm should confirm the data is ready before using it. In live trading this can mean you do " +
186 "not have an active subscription to the asset class you're trying to trade. If using custom data make sure you've " +
187 "set the 'Value' property.";
190 [MethodImpl(MethodImplOptions.AggressiveInlining)]
191 public static string WaitingForThreadToStopSafely(
string threadName)
193 return $
"Waiting for '{threadName}' thread to stop...";
196 [MethodImpl(MethodImplOptions.AggressiveInlining)]
197 public static string TimeoutWaitingForThreadToStopSafely(
string threadName)
199 return $
"Timeout waiting for '{threadName}' thread to stop";
202 [MethodImpl(MethodImplOptions.AggressiveInlining)]
203 public static string DataTypeMissingParameterlessConstructor(Type type)
205 return $
"Data type '{type.Name}' missing parameterless constructor. E.g. public {type.Name}() {{ }}";
208 [MethodImpl(MethodImplOptions.AggressiveInlining)]
209 public static string FailedToCreateInstanceOfType(Type type)
211 return $
"Failed to create instance of type '{type.Name}'";
214 [MethodImpl(MethodImplOptions.AggressiveInlining)]
215 public static string TypeIsNotBaseData(Type type)
217 return $
"Data type '{type.Name}' does not inherit required {nameof(Data.BaseData)}";
220 [MethodImpl(MethodImplOptions.AggressiveInlining)]
221 public static string CannotCastNonFiniteFloatingPointValueToDecimal(
double input)
223 return Invariant($
@"It is not possible to cast a non-finite floating-point value ({
224 input}) as decimal. Please review math operations and verify the result is valid.");
227 [MethodImpl(MethodImplOptions.AggressiveInlining)]
228 public static string UnableToConvertTimeSpanToResolution(TimeSpan timeSpan)
230 return Invariant($
"Unable to exactly convert time span ('{timeSpan}') to resolution.");
233 [MethodImpl(MethodImplOptions.AggressiveInlining)]
234 public static string UnableToParseUnknownSecurityType(
string value)
236 return $
"Attempted to parse unknown SecurityType: {value}";
239 [MethodImpl(MethodImplOptions.AggressiveInlining)]
240 public static string NoDefaultOptionStyleForSecurityType(
SecurityType securityType)
242 return Invariant($
"The SecurityType {securityType} has no default OptionStyle, because it has no options available for it");
245 [MethodImpl(MethodImplOptions.AggressiveInlining)]
246 public static string UnknownOptionStyle(
string value)
248 return $
"Unexpected OptionStyle: {value}";
251 [MethodImpl(MethodImplOptions.AggressiveInlining)]
252 public static string UnknownOptionStyle(
OptionStyle value)
254 return $
"Unexpected OptionStyle: {value}";
257 [MethodImpl(MethodImplOptions.AggressiveInlining)]
258 public static string UnknownOptionRight(
string value)
260 return $
"Unexpected OptionRight: {value}";
263 [MethodImpl(MethodImplOptions.AggressiveInlining)]
264 public static string UnknownOptionRight(
OptionRight value)
266 return $
"Unexpected OptionRight: {value}";
269 [MethodImpl(MethodImplOptions.AggressiveInlining)]
270 public static string UnknownDataMappingMode(
string value)
272 return $
"Unexpected DataMappingMode: {value}";
275 [MethodImpl(MethodImplOptions.AggressiveInlining)]
276 public static string ConvertToDelegateCannotConverPyObjectToType(
string methodName, Type type)
278 return $
"{methodName} cannot be used to convert a PyObject into {type}.";
281 [MethodImpl(MethodImplOptions.AggressiveInlining)]
282 public static string ConvertToDictionaryFailed(
string sourceType,
string targetType,
string reason)
284 return $
"ConvertToDictionary cannot be used to convert a {sourceType} into {targetType}. Reason: {reason}";
287 [MethodImpl(MethodImplOptions.AggressiveInlining)]
288 public static string ConvertToSymbolEnumerableFailed(PyObject item)
290 return $
"Argument type should be Symbol or a list of Symbol. Object: {item}. Type: {item.GetPythonType()}";
293 [MethodImpl(MethodImplOptions.AggressiveInlining)]
294 public static string ObjectFromPythonIsNotACSharpType(
string objectRepr)
296 return $
"{objectRepr} is not a C# Type.";
299 [MethodImpl(MethodImplOptions.AggressiveInlining)]
300 public static string RuntimeError(
IAlgorithm algorithm,
string context)
302 return Invariant($
"RuntimeError at {algorithm.UtcTime} UTC. Context: {context}");
311 [MethodImpl(MethodImplOptions.AggressiveInlining)]
314 var value = Invariant($
@"{instance.Symbol.Value}: {instance.Quantity} @ {
315 instance.CurrencySymbol}{instance.AveragePrice} - Market: {instance.CurrencySymbol}{instance.MarketPrice}");
317 if (instance.ConversionRate != 1m)
319 value += Invariant($
" - Conversion: {instance.ConversionRate}");
331 public static string ChartSubscription =
"Strategy Equity";
339 [MethodImpl(MethodImplOptions.AggressiveInlining)]
340 public static string MemoryUsageMaxedOut(
string memoryCap,
string lastSample)
342 return $
"Execution Security Error: Memory Usage Maxed Out - {memoryCap}MB max, with last sample of {lastSample}MB.";
345 [MethodImpl(MethodImplOptions.AggressiveInlining)]
346 public static string MemoryUsageOver80Percent(
double lastSample)
348 return Invariant($
"Execution Security Error: Memory usage over 80% capacity. Sampled at {lastSample}");
351 [MethodImpl(MethodImplOptions.AggressiveInlining)]
352 public static string MemoryUsageInfo(
string memoryUsed,
string lastSample,
string memoryUsedByApp, TimeSpan currentTimeStepElapsed,
355 return Invariant($
@"Used: {memoryUsed}, Sample: {lastSample}, App: {memoryUsedByApp}, CurrentTimeStepElapsed: {
356 currentTimeStepElapsed:mm':'ss'.'fff}. CPU: {cpuUsage}%");
359 [MethodImpl(MethodImplOptions.AggressiveInlining)]
360 public static string MemoryUsageMonitorTaskTimedOut(TimeSpan timeout)
362 return $
@"Execution Security Error: Operation timed out - {
363 timeout.TotalMinutes.ToStringInvariant()} minutes max. Check for recursive loops.";
372 [MethodImpl(MethodImplOptions.AggressiveInlining)]
373 public static string InvalidMarketIdentifier(
int maxMarketIdentifier)
375 return $
"The market identifier is limited to positive values less than {maxMarketIdentifier.ToStringInvariant()}.";
378 [MethodImpl(MethodImplOptions.AggressiveInlining)]
379 public static string TriedToAddExistingMarketWithDifferentIdentifier(
string market)
381 return $
"Attempted to add an already added market with a different identifier. Market: {market}";
384 [MethodImpl(MethodImplOptions.AggressiveInlining)]
385 public static string TriedToAddExistingMarketIdentifier(
string market,
string existingMarket)
387 return $
"Attempted to add a market identifier that is already in use. New Market: {market} Existing Market: {existingMarket}";
394 public static class OS
396 public static string CPUUsageKey =
"CPU Usage";
397 public static string UsedRAMKey =
"Used RAM (MB)";
398 public static string TotalRAMKey =
"Total RAM (MB)";
399 public static string HostnameKey =
"Hostname";
400 public static string LEANVersionKey =
"LEAN Version";
408 [MethodImpl(MethodImplOptions.AggressiveInlining)]
409 public static string ValueIsNotParseable(
string input, Type targetType)
411 return $
"The provided value ({input}) was not parseable as {targetType.Name}";
420 public static string NoUnderlyingForIdentifier =
421 "No underlying specified for this identifier. Check that HasUnderlying is true before accessing the Underlying property.";
423 public static string DateNotSupportedBySecurityType =
424 "Date is only defined for SecurityType.Equity, SecurityType.Option, SecurityType.Future, SecurityType.FutureOption, SecurityType.IndexOption, and SecurityType.Base";
426 public static string StrikePriceNotSupportedBySecurityType =
427 "StrikePrice is only defined for SecurityType.Option, SecurityType.FutureOption, and SecurityType.IndexOption";
429 public static string OptionRightNotSupportedBySecurityType =
430 "OptionRight is only defined for SecurityType.Option, SecurityType.FutureOption, and SecurityType.IndexOption";
432 public static string OptionStyleNotSupportedBySecurityType =
433 "OptionStyle is only defined for SecurityType.Option, SecurityType.FutureOption, and SecurityType.IndexOption";
435 public static string NullSymbol =
"SecurityIdentifier requires a non-null string 'symbol'";
437 public static string SymbolWithInvalidCharacters =
"Symbol must not contain the characters '|' or ' '.";
439 public static string PropertiesDoNotMatchAnySecurityType = $
"The provided properties do not match with a valid {nameof(SecurityType)}";
441 public static string StringIsNotSplittable =
"The string must be splittable on space into two parts.";
443 public static string UnexpectedTypeToCompareTo = $
"Object must be of type {nameof(SecurityIdentifier)}";
445 [MethodImpl(MethodImplOptions.AggressiveInlining)]
446 public static string InvalidSecurityType(
string parameterName)
448 return $
"{parameterName} must be between 0 and 99";
451 [MethodImpl(MethodImplOptions.AggressiveInlining)]
452 public static string InvalidOptionRight(
string parameterName)
454 return $
"{parameterName} must be either 0 or 1";
457 [MethodImpl(MethodImplOptions.AggressiveInlining)]
458 public static string InvalidStrikePrice(decimal strikePrice)
460 return Invariant($
"The specified strike price's precision is too high: {strikePrice}");
463 [MethodImpl(MethodImplOptions.AggressiveInlining)]
464 public static string ErrorParsingSecurityIdentifier(
string value, Exception exception)
466 return Invariant($
"Error parsing SecurityIdentifier: '{value}', Exception: {exception}");
469 [MethodImpl(MethodImplOptions.AggressiveInlining)]
470 public static string MarketNotFound(
string market)
472 return $
@"The specified market wasn't found in the markets lookup. Requested: {
473 market}. You can add markets by calling QuantConnect.Market.Add(string,int)";
482 [MethodImpl(MethodImplOptions.AggressiveInlining)]
483 public static string ConvertInvariantCannotConvertTo(TypeCode targetTypeCode)
485 return $
"StringExtensions.ConvertInvariant does not support converting to TypeCode.{targetTypeCode}";
494 public static string InsufficientInformationToCreateFutureOptionSymbol =
495 "Cannot create future option Symbol using this method (insufficient information). Use `CreateOption(Symbol, ...)` instead.";
497 public static string CanonicalNotDefined =
498 "Canonical is only defined for SecurityType.Option, SecurityType.Future, SecurityType.FutureOption";
500 public static string UnexpectedObjectTypeToCompareTo =
"Object must be of type Symbol or string.";
502 [MethodImpl(MethodImplOptions.AggressiveInlining)]
503 public static string SecurityTypeNotImplementedYet(
SecurityType securityType)
505 return Invariant($
"The security type has not been implemented yet: {securityType}");
508 [MethodImpl(MethodImplOptions.AggressiveInlining)]
509 public static string SecurityTypeCannotBeMapped(
SecurityType securityType)
511 return Invariant($
"SecurityType {securityType} can not be mapped.");
514 [MethodImpl(MethodImplOptions.AggressiveInlining)]
515 public static string NoOptionTypeForUnderlying(
SecurityType securityType)
517 return Invariant($
"No option type exists for underlying SecurityType: {securityType}");
520 [MethodImpl(MethodImplOptions.AggressiveInlining)]
521 public static string NoUnderlyingForOption(
SecurityType securityType)
523 return Invariant($
"No underlying type exists for option SecurityType: {securityType}");
532 [MethodImpl(MethodImplOptions.AggressiveInlining)]
533 public static string UnableToLocateTicker(
string ticker)
535 return $
"We were unable to locate the ticker '{ticker}'.";
538 [MethodImpl(MethodImplOptions.AggressiveInlining)]
539 public static string MultipleMatchingTickersLocated(IEnumerable<string> tickers)
541 return "We located multiple potentially matching tickers. " +
542 "For custom data, be sure to append a dot followed by the custom data type name. " +
543 $
"For example: 'BTC.Bitcoin'. Potential Matches: {string.Join(",
", tickers)}";
552 [MethodImpl(MethodImplOptions.AggressiveInlining)]
553 public static string FailedToGetMarketForTickerAndUnderlying(
string ticker,
string underlying)
555 return $
"Failed to get market for future '{ticker}' and underlying '{underlying}'";
558 [MethodImpl(MethodImplOptions.AggressiveInlining)]
559 public static string NoMarketFound(
string ticker)
561 return $
"No market found for '{ticker}'";
564 [MethodImpl(MethodImplOptions.AggressiveInlining)]
565 public static string UnexpectedSecurityTypeForMethod(
string methodName,
SecurityType securityType)
567 return Invariant($
"{methodName} expects symbol to be an option, received {securityType}.");
570 [MethodImpl(MethodImplOptions.AggressiveInlining)]
571 public static string UnexpectedOptionRightFormatForParseOptionTickerOSI(
string ticker)
573 return $
"Expected 12th character to be 'C' or 'P' for OptionRight: {ticker} but was '{ticker[12]}'";
576 [MethodImpl(MethodImplOptions.AggressiveInlining)]
577 public static string SecurityTypeNotImplemented(
SecurityType securityType)
579 return Invariant($
"Security type {securityType} not implemented");
588 public static string ConverterIsWriteOnly =
"The SymbolValueJsonConverter is write-only.";
590 public static string ConverterIsIntendedToBeDirectlyDecoratedInMember =
591 "The SymbolValueJsonConverter is intended to be decorated on the appropriate member directly.";
599 public static string InvalidBarSize =
"barSize must be greater than TimeSpan.Zero";
601 [MethodImpl(MethodImplOptions.AggressiveInlining)]
602 public static string SecurityCount(
int count)
604 return $
"Security Count: {count}";
613 [MethodImpl(MethodImplOptions.AggressiveInlining)]
614 public static string InvalidTotalDays(
int totalDays)
616 return Invariant($
@"Total days is negative ({
618 }), indicating reverse start and end times. Check your usage of TradingCalendar to ensure proper arrangement of variables");