28 private static string _isReadyName = nameof(
IsReady).ToSnakeCase();
29 private PyObject _instance;
30 private bool _isReady;
31 private bool _pythonIsReadyProperty;
48 : base(GetIndicatorName(args[0]))
57 : base(GetIndicatorName(indicator))
68 _instance = indicator;
70 foreach (var attributeName
in new[] {
"IsReady",
"Update",
"Value" })
72 if (!_indicatorWrapper.
HasAttr(attributeName))
74 var name = GetIndicatorName(indicator);
76 var message = $
"Indicator.{attributeName.ToSnakeCase()} must be implemented. " +
77 $
"Please implement this missing method in {name}";
79 if (attributeName ==
"IsReady")
81 message +=
" or use PythonIndicator as base:" +
82 $
"{Environment.NewLine}class {name}(PythonIndicator):";
85 throw new NotImplementedException(message);
88 if (attributeName ==
"IsReady")
92 _pythonIsReadyProperty = indicator.GetPythonBoolPropertyWithChecks(_isReadyName) !=
null;
112 if (_pythonIsReadyProperty)
117 var
property = _instance.GetPythonBoolPropertyWithChecks(_isReadyName);
138 _isReady = _indicatorWrapper.
InvokeMethod<
bool?>(nameof(Update), input)
140 return _indicatorWrapper.
GetProperty<decimal>(
"Value");
147 private int GetIndicatorWarmUpPeriod()
157 private static string GetIndicatorName(PyObject indicator)
162 if (indicator.HasAttr(
"Name"))
164 name = indicator.GetAttr(
"Name");
166 else if (indicator.HasAttr(
"name"))
168 name = indicator.GetAttr(
"name");
172 name = indicator.GetAttr(
"__class__").GetAttr(
"__name__");
174 return name.GetAndDispose<
string>();