BacktestData#

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

class BacktestData[source]#

Bases: object

Miscellaneous data needed to store only for the backtest state.

__init__(start_at, end_at, decision_cycle_duration, ready_at=None)#
Parameters:
Return type:

None

Methods

__init__(start_at, end_at, ...[, ready_at])

from_dict(kvs, *[, infer_missing])

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

mark_ready(timestamp)

Mark that the strategy has enough data to decide its first trade.

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

to_dict([encode_json])

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

Attributes

start_at

The start of backtest period

end_at

The end of backtest period

decision_cycle_duration

What has the decision cycle duration

ready_at

When the strategy was ready to make its first trade decision.

start_at: datetime#

The start of backtest period

end_at: datetime#

The end of backtest period

decision_cycle_duration: CycleDuration#

What has the decision cycle duration

ready_at: Optional[datetime]#

When the strategy was ready to make its first trade decision.

This timestamp marks there was enough trade history to correctly complete decide_trades(). Must be manually set with mark_ready in decide trades.. If available then benchmark curves and strategy equity curves can be correctly aligned, otherwise there might be misaligment (strategy sits on cash until enough history is available).

mark_ready(timestamp)[source]#

Mark that the strategy has enough data to decide its first trade.

  • See ready_at for more information

  • Can be called multiple times, only the first time counts

  • Interest positions may be ignored for mark_ready() (decide_trades() can do interest positions before ready state has been reached)

Parameters:

timestamp (datetime.datetime | pandas._libs.tslibs.timestamps.Timestamp) –

__init__(start_at, end_at, decision_cycle_duration, ready_at=None)#
Parameters:
Return type:

None