RoutingModel#

tradeexecutor.strategy.routing.RoutingModel class.

class RoutingModel[source]#

Bases: ABC

Trade roouting model base class.

Nothing done here - check the subclasses.

__init__()#

Methods

__init__()

create_routing_state(universe, execution_details)

Create a new routing state for this cycle.

perform_preflight_checks_and_logging(state)

"Checks the integrity of the routing.

setup_trades(state, trades[, check_balances])

Setup the trades decided by a strategy.

abstract create_routing_state(universe, execution_details)[source]#

Create a new routing state for this cycle.

Parameters
Return type

RoutingState

abstract setup_trades(state, trades, check_balances=False)[source]#

Setup the trades decided by a strategy.

  • Decides the best way, or a way, to execute a trade

  • Sets up blockchain transactions needed for trades, like approves

  • Trade instances are mutated in-place

Parameters
  • check_balances – Check that the wallet has enough reserves to perform the trades before executing them. Because we are selling before buying. sometimes we do no know this until the sell tx has been completed.

  • state (RoutingState) –

  • trades (List[TradeExecution]) –

Raises

CannotExecuteTrade – If a trade cannot be executed, e.g. due to an unsupported pair or an exchange,

perform_preflight_checks_and_logging(state)[source]#

“Checks the integrity of the routing.

  • Called from check-wallet to see our routing and balances are good

Parameters

state (RoutingState) –