EthereumTrader#
API documentation for tradeexecutor.ethereum.ethereumtrader.EthereumTrader Python class in Trading Strategy framework.
- class EthereumTrader[source]#
Bases:
ABC
Base class for Uniswap v2 and v3 test traders.
- __init__(tx_builder, state, pair_universe)[source]#
- Parameters:
tx_builder (TransactionBuilder) –
state (State) –
pair_universe (PandasPairUniverse) –
Methods
__init__
(tx_builder, state, pair_universe)buy
(pair, amount_in_usd[, execute])Buy token (trading pair) for a certain value.
execute_trades_simple
(routing_model, trades)Execute trades on web3 instance.
sell
(pair, quantity[, execute])Sell token token (trading pair) for a certain quantity.
Attributes
web3
- __init__(tx_builder, state, pair_universe)[source]#
- Parameters:
tx_builder (TransactionBuilder) –
state (State) –
pair_universe (PandasPairUniverse) –
- abstract buy(pair, amount_in_usd, execute=True)[source]#
Buy token (trading pair) for a certain value.
- Parameters:
pair (TradingPairIdentifier) –
amount_in_usd (Decimal) –
- Return type:
tuple[tradeexecutor.state.position.TradingPosition, tradeexecutor.state.trade.TradeExecution]
- abstract sell(pair, quantity, execute=True)[source]#
Sell token token (trading pair) for a certain quantity.
- Parameters:
pair (TradingPairIdentifier) –
quantity (Decimal) –
- Return type:
tuple[tradeexecutor.state.position.TradingPosition, tradeexecutor.state.trade.TradeExecution]
- abstract execute_trades_simple(routing_model, trades, 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:
routing_model (RoutingModel) –
trades (list[tradeexecutor.state.trade.TradeExecution]) –