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:
- start_ts (datetime) – 
- state (State) – 
- universe (TradingStrategyUniverse) – 
- execution_model (BacktestExecution) – 
- routing_model (BacktestRoutingModel) – 
- pricing_model (BacktestPricing) – 
 
 
 - 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:
- start_ts (datetime) – 
- state (State) – 
- universe (TradingStrategyUniverse) – 
- execution_model (BacktestExecution) – 
- routing_model (BacktestRoutingModel) – 
- pricing_model (BacktestPricing) – 
 
 
 - 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:
- pair (TradingPairIdentifier) – 
- reserve (Decimal) – 
 
- Return type:
 
 - get_sell_price(pair, quantity)[source]#
- Get the historical price for our current backtest time. - Parameters:
- pair (TradingPairIdentifier) – 
- quantity (Decimal) – 
 
- Return type: