Visualisation#
tradeexecutor.state.visualisation.Visualisation Python class in Trading Strategy framework.
- class Visualisation[source]#
Bases:
object
This object is returned from the strategy execution cycle. It allows you to plot values, add debug messages, etc. It is not used in any trading, but can help and visualize trade backtesting and execution.
- __init__(messages=<factory>, calculations=<factory>, plots=<factory>)#
Methods
__init__
([messages, calculations, plots])add_calculations
(timestamp, cycle_calculations)Update strategy cycle calculations diagnostics.
add_message
(timestamp, content)Write a debug message.
from_dict
(kvs, *[, infer_missing])from_json
(s, *[, parse_float, parse_int, ...])get_timestamp_range
([plot_name])Get the time range for which we have data.
Get number of data points stored in all plots.
plot_indicator
(timestamp, name, kind, value)Add a value to the output data and diagram.
schema
(*[, infer_missing, only, exclude, ...])to_dict
([encode_json])to_json
(*[, skipkeys, ensure_ascii, ...])Attributes
Messages for each strategy cycle.
Extra calculation diagnostics for each strategy cycle.
Name -> Plot value mappings
- messages: Dict[int, List[str]]#
Messages for each strategy cycle.
Because we cannot use datetime.datetime directly as a key in JSON, we use UNIX timestamp here to keep our state easily serialisable.
- calculations: Dict[int, dict]#
Extra calculation diagnostics for each strategy cycle.
Cycle -> dict of values mappings.
Currently used to record the alpha model state when doing doing portfolio construction modelling.
Because we cannot use datetime.datetime directly as a key in JSON, we use UNIX timestamp here to keep our state easily serialisable.
- add_message(timestamp, content)[source]#
Write a debug message.
Each message is associated to a different timepoint.
- add_calculations(timestamp, cycle_calculations)[source]#
Update strategy cycle calculations diagnostics.
Each strategy cycle can dump whatever intermediate calculations state on the visualisation record keeping, so that it can be later pulled up in the analysis.
Currently this is used to store the alpha model calculations for portfolio construction model.
- plot_indicator(timestamp, name, kind, value, colour=None, plot_shape=PlotShape.linear)[source]#
Add a value to the output data and diagram.
Plots are stored by their name.
- Parameters: