UniswapV3TestTrader#

tradeexecutor.testing.ethereumtrader_uniswap_v3.UniswapV3TestTrader Python class in Trading Strategy framework.

class UniswapV3TestTrader[source]#

Bases: EthereumTrader

Helper class to trade against EthereumTester unit testing network.

__init__(uniswap, state, pair_universe, tx_builder=None)[source]#
Parameters:

Methods

__init__(uniswap, state, pair_universe[, ...])

buy(pair, amount_in_usd[, execute])

Buy token (trading pair) for a certain value.

execute_trades_simple(trades[, ...])

Execute trades on web3 instance.

sell(pair, quantity[, execute])

Sell token token (trading pair) for a certain quantity.

Attributes

web3

__init__(uniswap, state, pair_universe, tx_builder=None)[source]#
Parameters:
buy(pair, amount_in_usd, execute=True)[source]#

Buy token (trading pair) for a certain value.

Parameters:
Return type:

Tuple[TradingPosition, TradeExecution]

sell(pair, quantity, execute=True)[source]#

Sell token token (trading pair) for a certain quantity.

Parameters:
Return type:

Tuple[TradingPosition, TradeExecution]

execute_trades_simple(trades, max_slippage=0.01, stop_on_execution_failure=True)[source]#

Execute trades on web3 instance.

A testing shortcut

  • Create BlockchainTransaction instances

  • Execute them on Web3 test connection (EthereumTester / Ganache)

  • Works with single Uniswap test deployment

Parameters:

trades (List[TradeExecution]) –

Return type:

Tuple[List[TradeExecution], List[TradeExecution]]