UniswapV2ExecutionModelVersion0#
tradeexecutor.ethereum.uniswap_v2_execution_v0.UniswapV2ExecutionModelVersion0 Python class in Trading Strategy framework.
- class UniswapV2ExecutionModelVersion0[source]#
Bases:
ExecutionModel
Run order execution on a single Uniswap v2 style exchanges.
TODO: This model was used in the first prototype and later discarded.
- __init__(uniswap, hot_wallet, min_balance_threshold=Decimal('0.5'), confirmation_block_count=6, confirmation_timeout=datetime.timedelta(seconds=300), max_slippage=0.01, stop_on_execution_failure=True)[source]#
- Parameters:
state –
uniswap (UniswapV2Deployment) –
hot_wallet (HotWallet) –
min_balance_threshold – Abort execution if our hot wallet gas fee balance drops below this
confirmation_block_count – How many blocks to wait for the receipt confirmations to mitigate unstable chain tip issues
confirmation_timeout – How long we wait transactions to clear
stop_on_execution_failure – Raise an exception if any of the trades fail top execute
Methods
__init__
(uniswap, hot_wallet[, ...])- param state:
execute_trades
(ts, state, trades, ...[, ...])Execute the trades determined by the algo on a designed Uniswap v2 instance.
Prototype does not know much about routing.
Set up the wallet
is_live_trading
()Do we support stop-loss/take profit functionality with this execution model?
is_v3
()Check that we can connect to the web3 node
repair_unconfirmed_trades
(state)Repair unconfirmed trades.
Attributes
Which chain the live execution is connected to.
- __init__(uniswap, hot_wallet, min_balance_threshold=Decimal('0.5'), confirmation_block_count=6, confirmation_timeout=datetime.timedelta(seconds=300), max_slippage=0.01, stop_on_execution_failure=True)[source]#
- Parameters:
state –
uniswap (UniswapV2Deployment) –
hot_wallet (HotWallet) –
min_balance_threshold – Abort execution if our hot wallet gas fee balance drops below this
confirmation_block_count – How many blocks to wait for the receipt confirmations to mitigate unstable chain tip issues
confirmation_timeout – How long we wait transactions to clear
stop_on_execution_failure – Raise an exception if any of the trades fail top execute
- 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, check_balances=False)[source]#
Execute the trades determined by the algo on a designed Uniswap v2 instance.
- Parameters:
routing_model (Optional[RoutingModel]) – Ignored.
ts (datetime) –
state (State) –
trades (List[TradeExecution]) –
routing_state (Optional[RoutingState]) –
- Returns:
Tuple List of succeeded trades, List of failed trades
- Return type: