UniswapV2ExecutionModelVersion0#
API documentation for tradeexecutor.ethereum.uniswap_v2.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 will be 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:
 - create_default_routing_model(strategy_universe)- Get the default routing model for this executor. - execute_trades(ts, state, trades, ...[, ...])- Execute the trades determined by the algo on a designed Uniswap v2 instance. - Get the address where the strat holds tokens. - Prototype does not know much about routing. - Fix the block number for all checks and actions. - 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 
 
 
 - get_balance_address()[source]#
- Get the address where the strat holds tokens. - Returns:
- None if this executor does not use on-chain addresses. 
 
 - get_safe_latest_block()[source]#
- Fix the block number for all checks and actions. - At the start of each action cycle (strategy decision, position triggers) we fix ourselves to a certain block number we know is “safe” and the data in at this block number is unlike to change 
- We then perform all deposit and redemptions and accounting checks using this block number as end block, to get a 
 - Returns:
- A good safe latest block number. - Return None if the block number is irrelevant for the execution, like backtesting and such. 
- Return type:
 
 - 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: