UniswapV2TestTrader#
API documentation for tradeexecutor.testing.ethereumtrader_uniswap_v2.UniswapV2TestTrader Python class in Trading Strategy framework.
- class UniswapV2TestTrader[source]#
Bases:
EthereumTrader
Helper class to trade against a locally deployed Uniswap v2 contract.
Allows to execute individual trades without need to go through decide_trades()
May be used with or without
pricing_model
.- __init__(uniswap, state, pair_universe, tx_builder, pricing_model=None)[source]#
- Parameters:
web3 –
uniswap (UniswapV2Deployment) –
hot_wallet –
state (State) –
pair_universe (PandasPairUniverse) –
tx_builder (TransactionBuilder) –
pricing_model (Optional[UniswapV2LivePricing]) – Give if you want to get the lp fees estimated
Methods
__init__
(uniswap, state, pair_universe, ...)- param web3:
broadcast_trades
(routing_model, trades[, ...])Broadcast prepared trades.
buy
(pair, amount_in_usd[, execute, ...])Buy token (trading pair) for a certain value.
create_routing_model
()execute_trades_simple
(routing_model, trades)Execute trades on web3 instance.
sell
(pair, quantity[, execute, ...])Sell tokens on an open position for a certain quantity.
Attributes
web3
- __init__(uniswap, state, pair_universe, tx_builder, pricing_model=None)[source]#
- Parameters:
web3 –
uniswap (UniswapV2Deployment) –
hot_wallet –
state (State) –
pair_universe (PandasPairUniverse) –
tx_builder (TransactionBuilder) –
pricing_model (Optional[UniswapV2LivePricing]) – Give if you want to get the lp fees estimated
- buy(pair, amount_in_usd, execute=True, slippage_tolerance=None)[source]#
Buy token (trading pair) for a certain value.
- Parameters:
pair (TradingPairIdentifier) –
amount_in_usd (Decimal) –
- Return type:
- sell(pair, quantity, execute=True, slippage_tolerance=None)[source]#
Sell tokens on an open position for a certain quantity.
- Parameters:
pair (TradingPairIdentifier) –
quantity (Decimal) –
- Return type:
- execute_trades_simple(routing_model, trades, stop_on_execution_failure=True, broadcast=True)[source]#
Execute trades on web3 instance.
A testing shortcut
Create BlockchainTransaction instances of each gives TradeExecution
Execute them on Web3 test connection (EthereumTester / Ganache)
Works with single Uniswap test deployment
- Parameters:
trades (List[TradeExecution]) – Trades to be converted to blockchain transactions
stop_on_execution_failure – Raise exception on an error
broadcast – Broadcast trades over web3 connection
routing_model (RoutingModel) –
- Return type:
- broadcast_trades(routing_model, trades, stop_on_execution_failure=True)[source]#
Broadcast prepared trades.
- Parameters:
trades (List[TradeExecution]) –