DummyExecutionModel#
tradeexecutor.strategy.dummy.DummyExecutionModel Python class in Trading Strategy framework.
- class DummyExecutionModel[source]#
Bases:
ExecutionModel
Trade executor that does not connect to anything.
Used in testing.
Methods
__init__
(web3)execute_trades
(ts, state, trades, ...[, ...])Execute the trades determined by the algo on a designed Uniswap v2 instance.
Get needed details to establish a routing state.
Set up the execution model ready to make trades.
Do we support stop-loss/take profit functionality with this execution model?
Check that we can start the trade executor
repair_unconfirmed_trades
(state)Repair unconfirmed trades.
- preflight_check()[source]#
Check that we can start the trade executor
- Raise:
AssertionError if something is a miss
- initialize()[source]#
Set up the execution model ready to make trades.
Read any on-chain, etc., data to get synced.
Read EVM nonce for the hot wallet from the chain
- is_stop_loss_supported()[source]#
Do we support stop-loss/take profit functionality with this execution model?
For backtesting we need to have data stream for candles used to calculate stop loss
For production execution, we need to have special oracle data streams for checking real-time stop loss
- Return type:
- execute_trades(ts, state, trades, routing_model, routing_state, max_slippage=0.005, check_balances=False)[source]#
Execute the trades determined by the algo on a designed Uniswap v2 instance.
- Parameters:
ts (datetime) – Timestamp of the trade cycle.
universe – Current trading universe for this cycle.
state (State) – State of the trade executor.
trades (List[TradeExecution]) – List of trades decided by the strategy. Will be executed and modified in place.
routing_model (RoutingModel) – Routing model how to execute the trades
routing_state (RoutingState) – State of already made on-chain transactions and such on this cycle
max_slippage – Max slippage % allowed on trades before trade execution fails.
check_balances – Check that on-chain accounts have enough balance before creating transaction objects. Useful during unit tests to spot issues in trade routing.