IndicatorDefinition#
API documentation for tradeexecutor.strategy.pandas_trader.indicator.IndicatorDefinition Python class in Trading Strategy framework.
- class IndicatorDefinition[source]#
Bases:
object
A definition for a single indicator.
Indicator definitions are static - they do not change between the strategy runs
Used as id for the caching the indicator results
Definitions are used to calculate indicators for all trading pairs, or once over the whole trading universe
Indicators are calcualted independently from each other - a calculation cannot access cached values of other calculation
- __init__(name, func, parameters, source=IndicatorSource.close_price)#
- Parameters:
name (str) –
parameters (dict) –
source (IndicatorSource) –
- Return type:
None
Methods
__init__
(name, func, parameters[, source])calculate_by_pair
(input)Calculate the underlying indicator value.
calculate_by_pair_ohlcv
(candles)Calculate the underlying OHCLV indicator value.
calculate_universe
(input)Calculate the underlying indicator value.
is_needed_for_pair
(pair)Currently indicators are calculated for spont pairs only.
is_per_pair
()Attributes
Name of this indicator.
The underlying method we use to
Parameters for building this indicator.
On what trading universe data this indicator is calculated
- name: str#
Name of this indicator.
Later in decide_trades() you use this name to access the indicator data.
- func: Optional[Callable]#
The underlying method we use to
Same function can part of multiple indicators with different parameters (length).
Because function pickling issues, this may be set to
None
in results.
- parameters: dict#
Parameters for building this indicator.
Each key is a function argument name for
func
.Each value is a single value
Grid search multiple parameter ranges are handled outside indicator definition
- source: IndicatorSource#
On what trading universe data this indicator is calculated
- is_needed_for_pair(pair)[source]#
Currently indicators are calculated for spont pairs only.
- Parameters:
pair (TradingPairIdentifier) –
- Return type:
- calculate_by_pair(input)[source]#
Calculate the underlying indicator value.
- Parameters:
input (Series) – Price series used as input.
- Returns:
Single or multi series data.
Multi-value indicators return DataFrame with multiple columns (BB).
Single-value indicators return Series (RSI, SMA).
- Return type:
pandas.core.frame.DataFrame | pandas.core.series.Series
- calculate_by_pair_ohlcv(candles)[source]#
Calculate the underlying OHCLV indicator value.
Assume function can take parameters: open, high, low, close, volume, or any combination of those.
- Parameters:
input – Raw OHCLV candles data.
candles (DataFrame) –
- Returns:
Single or multi series data.
Multi-value indicators return DataFrame with multiple columns (BB).
Single-value indicators return Series (RSI, SMA).
- Return type:
pandas.core.frame.DataFrame | pandas.core.series.Series
- calculate_universe(input)[source]#
Calculate the underlying indicator value.
- Parameters:
input (TradingStrategyUniverse) – Price series used as input.
- Returns:
Single or multi series data.
Multi-value indicators return DataFrame with multiple columns (BB).
Single-value indicators return Series (RSI, SMA).
- Return type:
pandas.core.frame.DataFrame | pandas.core.series.Series