Plot#

API documentation for tradeexecutor.state.visualisation.Plot Python class in Trading Strategy framework.

class Plot[source]#

Bases: object

Descibe singe plot on a strategy.

Plot is usually displayed as an overlay line over the price chart. E.g. simple moving average over price candles.

__init__(name, kind, colour=None, points=<factory>, plot_shape=PlotShape.linear, detached_overlay_name=None, indicator_size=None, recording_time=RecordingTime.decision_making_time, pair=None, label=None, height=None)#
Parameters:
Return type:

None

Methods

__init__(name, kind[, colour, points, ...])

add_point(timestamp, value)

from_dict(kvs, *[, infer_missing])

from_json(s, *[, parse_float, parse_int, ...])

get_entries()

Get entries as a sorted list."

get_first_entry()

Get the first entry in this plot.

get_last_entry()

Get the last entry in this plot.

get_last_value()

Assume points is an ordered dict.

schema(*[, infer_missing, only, exclude, ...])

to_dict([encode_json])

to_json(*[, skipkeys, ensure_ascii, ...])

Attributes

name

Name of this plot

kind

What kind of a plot we are drawing

colour

One of Plotly colour names https://community.plotly.com/t/plotly-colours-list/11730/2

points

Points of this plot.

plot_shape

Standard is linear.

detached_overlay_name

If this plot is overlayed on top of a detached technical indicator, this is the name of the overlay it should be attached to.

indicator_size

Optional indicator to determine the size of the indicator.

recording_time

What is the recording time for this plot.

pair

The trading pair this plot is for.

label

How do we render label for this plot

height

Height hint for the rendering.

name: str#

Name of this plot

kind: PlotKind#

What kind of a plot we are drawing

colour: Optional[str]#

One of Plotly colour names https://community.plotly.com/t/plotly-colours-list/11730/2

points: Dict[int, float]#

Points of this plot.

TODO: Because we cannot use datetime.datetime directly as a key in JSON, we use UNIX timestamp here to keep our state easily serialisable.

Also note that entries may not be in order - you might need to sort the output yourself.

plot_shape: Optional[PlotShape]#

Standard is linear. Alternative is horizontal-vertical which can be used for stop loss line. See https://plotly.com/python/line-charts/?_ga=2.83222870.1162358725.1672302619-1029023258.1667666588#interpolation-with-line-plots

detached_overlay_name: Optional[str]#

If this plot is overlayed on top of a detached technical indicator, this is the name of the overlay it should be attached to.

indicator_size: Optional[float]#

Optional indicator to determine the size of the indicator.

For a line, this is the width of the line.

For a marker, this is the size of the marker.

recording_time: RecordingTime#

What is the recording time for this plot.

Are we adjusted for look ahead bias or not.

pair: Optional[TradingPairIdentifier]#

The trading pair this plot is for.

Plots are not necessarily restricted to a single trading pair, so this is optional.

label: Optional[PlotLabel]#

How do we render label for this plot

height: Optional[int]#

Height hint for the rendering.

Currently not supported. See Visualisation.plot_indicator() for comments.

get_last_value()[source]#

Assume points is an ordered dict.

Return type:

float

get_last_entry()[source]#

Get the last entry in this plot.

Returns:

timestamp, value tuple

Return type:

Tuple[datetime, float]

get_first_entry()[source]#

Get the first entry in this plot.

Returns:

timestamp, value tuple

Return type:

Tuple[datetime, float]

get_entries()[source]#

Get entries as a sorted list.”

Returns:

List[timestamp, value], oldest timestamp first

Return type:

List[Tuple[datetime, float]]

__init__(name, kind, colour=None, points=<factory>, plot_shape=PlotShape.linear, detached_overlay_name=None, indicator_size=None, recording_time=RecordingTime.decision_making_time, pair=None, label=None, height=None)#
Parameters:
Return type:

None