BacktestTrader#

API documentation for tradeexecutor.testing.backtest_trader.BacktestTrader Python class in Trading Strategy framework.

class BacktestTrader[source]#

Bases: object

Helper class to generate trades for backtesting.

Directly generate trades without going through a strategy. Any trade is executed against given pair, price universe and execution model.

__init__(start_ts, state, universe, execution_model, routing_model, pricing_model)[source]#
Parameters:

Methods

__init__(start_ts, state, universe, ...)

buy(pair, reserve)

create(pair, quantity, reserve, price[, ...])

Open a new trade.

create_and_execute(pair, quantity, reserve, ...)

get_buy_price(pair, reserve)

Get the historical price for our current backtest time.

get_sell_price(pair, quantity)

Get the historical price for our current backtest time.

sell(pair, quantity)

time_travel(timestamp)

Set the timestamp for the next executions.

__init__(start_ts, state, universe, execution_model, routing_model, pricing_model)[source]#
Parameters:
time_travel(timestamp)[source]#

Set the timestamp for the next executions.

Parameters:

timestamp (datetime) –

get_buy_price(pair, reserve)[source]#

Get the historical price for our current backtest time.

Parameters:
Return type:

TradePricing

get_sell_price(pair, quantity)[source]#

Get the historical price for our current backtest time.

Parameters:
Return type:

TradePricing

create(pair, quantity, reserve, price, planned_mid_price=None)[source]#

Open a new trade.

Parameters:
Return type:

Tuple[TradingPosition, TradeExecution]