Indicator ValueType can possibly used by Investfly to validate expression and optimize experience for users
For e.g, all Indicators of same valueType can be plotted in the same y-axis
PRICE =
PRICE
PERCENT =
PERCENT
RATIO =
RATIO
BOOLEAN =
BOOLEAN
NUMBER =
NUMBER
classIndicatorId(builtins.str, enum.Enum):
Technical indicators supported by Investfly.
This enum lists all standard technical indicators that can be used in trading
strategies for technical analysis. The enum values are string identifiers that
must be used when calling computeIndicatorSeries() in DataService.
Note: The enum values are strings (not the enum names) to support both standard
and custom indicators. When using standard indicators, use the .value property
or the string directly (e.g., "SMA" or StandardIndicatorId.SMA.value).
Parameter Type (INTEGER, FLOAT, BOOLEAN, STRING, BARINTERVAL)
required: bool =
True
Whether this parameter is required or optional
defaultValue: typing.Any | None =
None
The default value for the parameter to auto-populate mainly in UI
options: Optional[List[Any]] =
None
Valid value options (if any). If specified, then in the UI, this parameter renders as a dropdown select list.
If left as None, parameter renders and freeform input text field.
Validate that required fields are provided and have correct types
classIndicator(abc.ABC):
The primary class to implement a custom Indicator. A Custom Indicator is like standard indicator (e.g SMA, RSI)
and can be used in any place that standard indicator can be used (e.g screener, charts, strategy etc)
Investfly comes with a set of standard indicators. If you find that the indicator you want is not supported
or you can a small variation (e.g SMA but with using Heikin Ashi Candles), then you can use this function
Compute indicator series based on provided input timed data series and parameter values.
This function must return List of indicator values instead of only the most recent single value because indicator
series is required to plot in the price chart and also to use in backtest.
The timestamps in the DatedValue must correspond to timestamps in input data.
The length of input data depends on context (e.g., is this indicator being evaluated for backtest or screener?)
and dataCountToComputeCurrentValue function below.
Determine how many input data points are needed to compute the current indicator value.
When this indicator is used in screener and trading strategy when evaluated in real-time, only
the "current" value of the indicator is required. The historical values are NOT required. Therefore,
when the system calls computeSeries above with all available data (e.g., 10 years of historical bars),
then it is unnecessarily slow and wasteful. This function is used to control the size of input data
that will be passed to computeSeries method above.
The default implementation tries to make the best guess, but override as needed.
Args:
params: User supplied input parameter values.
Returns:
Integer representing how many input data points are required to compute the 'current' indicator value.
For example, if this was SMA indicator with period=5, then you should return 5.