17 using System.Runtime.CompilerServices;
26 public static partial class Messages
36 public static string InvalidBarCount =
"Insight barCount must be greater than zero.";
41 public static string InvalidPeriod =
"Insight period must be greater than or equal to 1 second.";
46 public static string InvalidCloseTimeUtc =
"Insight closeTimeUtc must be greater than generatedTimeUtc.";
56 [MethodImpl(MethodImplOptions.AggressiveInlining)]
59 return Invariant($
@"The insight's '{nameof(insight.GeneratedTimeUtc)}' property must be set before calling {
60 nameof(insight.SetPeriodAndCloseTime)}.");
67 [MethodImpl(MethodImplOptions.AggressiveInlining)]
70 return Invariant($
"Unable to set group id on insight {insight} because it has already been assigned to a group.");
76 [MethodImpl(MethodImplOptions.AggressiveInlining)]
77 public static string ToString(Algorithm.Framework.Alphas.Insight insight)
79 var str = Invariant($
"{insight.Id:N}: {insight.Symbol} {insight.Type} {insight.Direction} within {insight.Period}");
81 if (insight.Magnitude.HasValue)
83 str += Invariant($
" by {insight.Magnitude.Value}%");
85 if (insight.Confidence.HasValue)
87 str += Invariant($
" with {Math.Round(100 * insight.Confidence.Value, 1)}% confidence");
89 if (insight.Weight.HasValue)
91 str += Invariant($
" and {Math.Round(100 * insight.Weight.Value, 1)}% weight");
94 if (!
string.IsNullOrEmpty(insight.Tag))
96 str += Invariant($
": {insight.Tag}");
105 [MethodImpl(MethodImplOptions.AggressiveInlining)]
106 public static string ShortToString(Algorithm.Framework.Alphas.Insight insight)
108 var str = Invariant($
"{insight.Symbol.Value} {insight.Type} {insight.Direction} {insight.Period}");
110 if (insight.Magnitude.HasValue)
112 str += Invariant($
" M:{insight.Magnitude.Value}%");
114 if (insight.Confidence.HasValue)
116 str += Invariant($
" C:{Math.Round(100 * insight.Confidence.Value, 1)}%");
118 if (insight.Weight.HasValue)
120 str += Invariant($
" W:{Math.Round(100 * insight.Weight.Value, 1)}%");
122 if (!
string.IsNullOrEmpty(insight.Tag))
124 str += Invariant($
". {insight.Tag}");
139 [MethodImpl(MethodImplOptions.AggressiveInlining)]
140 public static string ToString(Algorithm.Framework.Alphas.InsightScore insightScore)
142 return Invariant($
@"Direction: {Math.Round(100 * insightScore.Direction, 2)} Magnitude: {
143 Math.Round(100 * insightScore.Magnitude, 2)}");