Lean  $LEAN_TAG$
Messages.Indicators.cs
1 /*
2  * QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
3  * Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14 */
15 
16 using System;
17 using System.Runtime.CompilerServices;
18 
19 using static QuantConnect.StringExtensions;
20 
21 namespace QuantConnect
22 {
23  /// <summary>
24  /// Provides user-facing message construction methods and static messages for the <see cref="Indicators"/> namespace
25  /// </summary>
26  public static partial class Messages
27  {
28  /// <summary>
29  /// Provides user-facing messages for the <see cref="Indicators.IndicatorDataPoint"/> class and its consumers or related classes
30  /// </summary>
31  public static class IndicatorDataPoint
32  {
33  /// <summary>
34  /// Returns a string message saying the given type is invalid for certain object
35  /// </summary>
36  [MethodImpl(MethodImplOptions.AggressiveInlining)]
37  public static string InvalidObjectTypeToCompareTo(Type type)
38  {
39  return $"Object must be of type {type.GetBetterTypeName()}";
40  }
41 
42  /// <summary>
43  /// Parses a IndicatorDataPoint instance into a string message containing basic information about it
44  /// </summary>
45  [MethodImpl(MethodImplOptions.AggressiveInlining)]
46  public static string ToString(Indicators.IndicatorDataPoint instance)
47  {
48  return Invariant($"{instance.Time.ToStringInvariant("s")} - {instance.Value}");
49  }
50 
51  /// <summary>
52  /// Returns a string message saying the given method cannot be called on this type
53  /// </summary>
54  [MethodImpl(MethodImplOptions.AggressiveInlining)]
55  public static string UnsupportedMethod(string methodName)
56  {
57  return $"IndicatorDataPoint does not support the {methodName} function. This function should never be called on this type.";
58  }
59  }
60 
61  /// <summary>
62  /// Provides user-facing messages for the <see cref="Indicators.RollingWindow{T}"/> class and its consumers or related classes
63  /// </summary>
64  public static class RollingWindow
65  {
66  /// <summary>
67  /// String message saying the rolling windows must have size of at least 1
68  /// </summary>
69  public static string InvalidSize = "RollingWindow must have size of at least 1.";
70 
71  /// <summary>
72  /// String message saying no items have been removed yet from the rolling window
73  /// </summary>
74  public static string NoItemsRemovedYet = "No items have been removed yet!";
75 
76  /// <summary>
77  /// String message saying the index must be a non-negative integer
78  /// </summary>
79  public static string IndexOutOfSizeRange = "Index must be a non-negative integer";
80  }
81  }
82 }