backtrader.bokeh.utils.helpers module

Helper utility functions.

backtrader.bokeh.utils.helpers.get_datanames(strategy)[source]

Get names of all data sources in strategy.

Parameters:

strategy – Strategy instance

Returns:

List of data source names

Return type:

list

backtrader.bokeh.utils.helpers.get_strategy_label(strategy)[source]

Get strategy label.

Parameters:

strategy – Strategy instance

Returns:

Strategy label

Return type:

str

backtrader.bokeh.utils.helpers.sanitize_source_name(name)[source]

Sanitize data source name, remove illegal characters.

Parameters:

name – Original name

Returns:

Sanitized name

Return type:

str

backtrader.bokeh.utils.helpers.get_indicator_label(indicator)[source]

Get indicator label.

Parameters:

indicator – Indicator instance

Returns:

Indicator label

Return type:

str

backtrader.bokeh.utils.helpers.format_datetime(dt, fmt='%Y-%m-%d %H:%M')[source]

Format datetime.

Parameters:
  • dt – datetime object

  • fmt – Format string

Returns:

Formatted string

Return type:

str

backtrader.bokeh.utils.helpers.format_number(value, precision=2)[source]

Format number.

Parameters:
  • value – Numeric value

  • precision – Decimal precision

Returns:

Formatted string

Return type:

str

backtrader.bokeh.utils.helpers.get_color_from_value(value, up_color='#26a69a', down_color='#ef5350', neutral_color='#666666')[source]

Get color based on value.

Parameters:
  • value – Numeric value

  • up_color – Color for positive values

  • down_color – Color for negative values

  • neutral_color – Color for zero values

Returns:

Color value

Return type:

str