ExecutionModel#

tradeexecutor.strategy.execution_model.ExecutionModel class.

class ExecutionModel[source]#

Bases: ABC

Define how trades are executed.

See also tradeexecutor.strategy.mode.ExecutionMode.

__init__()#

Methods

__init__()

execute_trades(ts, state, trades, ...[, ...])

Execute the trades determined by the algo on a designed Uniswap v2 instance.

get_routing_state_details()

Get needed details to establish a routing state.

initialize()

Read any on-chain, etc., data to get synced.

preflight_check()

Check that we can start the trade executor

abstract preflight_check()[source]#

Check that we can start the trade executor

Raise

AssertionError if something is a miss

abstract initialize()[source]#

Read any on-chain, etc., data to get synced.

abstract get_routing_state_details()[source]#

Get needed details to establish a routing state.

TODO: API Unfinished

Return type

object

abstract 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.