backtrader.bokeh.utils.helpers module

Helper utility functions.

backtrader.bokeh.utils.helpers.get_datanames(strategy)[源代码]

Get names of all data sources in strategy.

参数:

strategy -- Strategy instance

返回:

List of data source names

返回类型:

list

backtrader.bokeh.utils.helpers.get_strategy_label(strategy)[源代码]

Get strategy label.

参数:

strategy -- Strategy instance

返回:

Strategy label

返回类型:

str

backtrader.bokeh.utils.helpers.sanitize_source_name(name)[源代码]

Sanitize data source name, remove illegal characters.

参数:

name -- Original name

返回:

Sanitized name

返回类型:

str

backtrader.bokeh.utils.helpers.get_indicator_label(indicator)[源代码]

Get indicator label.

参数:

indicator -- Indicator instance

返回:

Indicator label

返回类型:

str

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

Format datetime.

参数:
  • dt -- datetime object

  • fmt -- Format string

返回:

Formatted string

返回类型:

str

backtrader.bokeh.utils.helpers.format_number(value, precision=2)[源代码]

Format number.

参数:
  • value -- Numeric value

  • precision -- Decimal precision

返回:

Formatted string

返回类型:

str

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

Get color based on value.

参数:
  • value -- Numeric value

  • up_color -- Color for positive values

  • down_color -- Color for negative values

  • neutral_color -- Color for zero values

返回:

Color value

返回类型:

str