Build Custom Indicators Using the Base Indicator Class

Base Indicator Class for deriving your own indicators to use within an analysis_engine.indicators.in dicator_processor.IndicatorProcessor

class analysis_engine.indicators.base_indicator.BaseIndicator(config_dict, path_to_module=None, name=None, verbose=False)[source]
build_base_configurables(ind_type='momentum', category='technical', uses_data='minute', version=1)[source]
Parameters:
  • ind_type – string indicator type
  • category – string indicator category
  • uses_data – string indicator usess this type of data
  • version – integer for building configurables for the testing generation version
build_configurable_node(name, conf_type, current_value=None, default_value=None, max_value=None, min_value=None, is_output_only=False, inc_interval=None, notes=None, **kwargs)[source]

Helper for building a single configurable type node for programmatically creating algo configs

Parameters:
  • name – name of the member configurable
  • conf_type – string - configurable type
  • current_value – optional - current value
  • default_value – optional - default value
  • max_value – optional - maximum value
  • min_value – optional - minimum value
  • is_output_only – optional - bool for setting the input parameter as an output-only value (default is False)
  • inc_interval – optional - float value for controlling how the tests should increment while walking between the min_value and the max_value
  • notes – optional - string notes
  • kwargs – optional - derived keyword args dictionary
build_report_key(key, prefix_key, key_type, cur_report_dict)[source]
Parameters:prefix_key
convert_config_keys_to_members()[source]

This converts any key in the config to a member variable that can be used with the your derived indicators like: self.<KEY_IN_CONFIG>

get_config()[source]
get_configurables(**kwargs)[source]

Derive this in your indicators

This is used as a helper for setting up algorithm configs for this indicator and to programmatically set the values based off the domain rules

Parameters:kwargs – optional keyword args
get_dataset_by_name(dataset, dataset_name)[source]

Method for getting just a dataset by the dataset_name`` inside the cached dataset['data'] dictionary of pd.Dataframe(s)

Parameters:
  • dataset – cached dataset value that holds the dictionaries: dataset['data']
  • dataset_name – optional - name of the supported pd.DataFrame that is in the cached dataset['data'] dictionary of dataframes
get_name()[source]
get_path_to_module()[source]
get_report(verbose=False)[source]

Get the indicator’s current output node that is used for the trading performance report generated at the end of the algorithm

Note

the report dict should mostly be numeric types to enable AI predictions after removing non-numeric columns

Parameters:verbose – optional - boolean for toggling to show the report
get_report_prefix()[source]
get_subscribed_dataset(dataset, dataset_name=None)[source]

Method for getting just the subscribed dataset else use the dataset_name argument dataset

Parameters:
  • dataset – cached dataset value that holds the dictionaries: dataset['data']
  • dataset_name – optional - name of the supported pd.DataFrame that is in the cached dataset['data'] dictionary of dataframes
handle_subscribed_dataset(algo_id, ticker, dataset)[source]

Filter the algorithm’s dataset to just the dataset the indicator is set up to use as defined by the member variable:

  • self.name_of_df - string value like daily, minute
Parameters:
  • algo_id – string - algo identifier label for debugging datasets during specific dates
  • ticker – string - ticker
  • dataset – dictionary of pd.DataFrame(s) to process
lg(msg, level=20)[source]

Log only if the indicator has self.verbose set to True or if the level == logging.CRITICAL or level = logging.ERROR otherwise no logs

Parameters:
  • msg – string message to log
  • level – set the logging level (default is logging.INFO)
process(algo_id, ticker, dataset)[source]

Derive custom indicator processing to determine buy and sell conditions before placing orders. Just implement your own process method.

Please refer to the TA Lib guides for details on building indicators:

Parameters:
  • algo_id – string - algo identifier label for debugging datasets during specific dates
  • ticker – string - ticker
  • dataset – dictionary of pd.DataFrame(s) to process
reset_internals(**kwargs)[source]

Support a cleanup action before indicators run between datasets. Derived classes can implement custom cleanup actions that need to run before each IndicatorProcessor.process() call is run on the next cached dataset

Parameters:kwargs – keyword args dictionary
set_configurables(config_dict)[source]
Parameters:config_dict – indicator config dictionary