17 using System.Runtime.CompilerServices;
26 public static partial class Messages
33 public static string InvalidBarCount =
"Insight barCount must be greater than zero.";
35 public static string InvalidPeriod =
"Insight period must be greater than or equal to 1 second.";
37 public static string InvalidCloseTimeUtc =
"Insight closeTimeUtc must be greater than generatedTimeUtc.";
39 public static string InvalidCloseTimeLocal =
"Insight closeTimeLocal must not be in the past.";
41 [MethodImpl(MethodImplOptions.AggressiveInlining)]
42 public static string GeneratedTimeUtcNotSet(Algorithm.Framework.Alphas.Insight insight)
44 return Invariant($
@"The insight's '{nameof(insight.GeneratedTimeUtc)}' property must be set before calling {
45 nameof(insight.SetPeriodAndCloseTime)}.");
48 [MethodImpl(MethodImplOptions.AggressiveInlining)]
49 public static string InsightAlreadyAssignedToAGroup(Algorithm.Framework.Alphas.Insight insight)
51 return Invariant($
"Unable to set group id on insight {insight} because it has already been assigned to a group.");
54 [MethodImpl(MethodImplOptions.AggressiveInlining)]
55 public static string ToString(Algorithm.Framework.Alphas.Insight insight)
57 var str = Invariant($
"{insight.Id:N}: {insight.Symbol} {insight.Type} {insight.Direction} within {insight.Period}");
59 if (insight.Magnitude.HasValue)
61 str += Invariant($
" by {insight.Magnitude.Value}%");
63 if (insight.Confidence.HasValue)
65 str += Invariant($
" with {Math.Round(100 * insight.Confidence.Value, 1)}% confidence");
67 if (insight.Weight.HasValue)
69 str += Invariant($
" and {Math.Round(100 * insight.Weight.Value, 1)}% weight");
72 if (!
string.IsNullOrEmpty(insight.Tag))
74 str += Invariant($
": {insight.Tag}");
80 [MethodImpl(MethodImplOptions.AggressiveInlining)]
81 public static string ShortToString(Algorithm.Framework.Alphas.Insight insight)
83 var str = Invariant($
"{insight.Symbol.Value} {insight.Type} {insight.Direction} {insight.Period}");
85 if (insight.Magnitude.HasValue)
87 str += Invariant($
" M:{insight.Magnitude.Value}%");
89 if (insight.Confidence.HasValue)
91 str += Invariant($
" C:{Math.Round(100 * insight.Confidence.Value, 1)}%");
93 if (insight.Weight.HasValue)
95 str += Invariant($
" W:{Math.Round(100 * insight.Weight.Value, 1)}%");
97 if (!
string.IsNullOrEmpty(insight.Tag))
99 str += Invariant($
". {insight.Tag}");
111 [MethodImpl(MethodImplOptions.AggressiveInlining)]
112 public static string ToString(Algorithm.Framework.Alphas.InsightScore insightScore)
114 return Invariant($
@"Direction: {Math.Round(100 * insightScore.Direction, 2)} Magnitude: {
115 Math.Round(100 * insightScore.Magnitude, 2)}");