Closed miohtama closed 1 year ago
@miohtama So I would change this method to accept exchange_slug
or equivalent instead oflp_fees
parameter, and then get the fee from the routing_data for the relevant exchange?
exchage-slug
it needs to know about fees.web3-ethereum-defi
package when it estimates the amount of token it receives from buy/see. This is called here https://github.com/tradingstrategy-ai/trade-executor/blob/a85bedde1284bc0e553b70824bb655d8b733ddff/tradeexecutor/ethereum/uniswap_v2_live_pricing.py#L108UniswapV2LivePricing
is created, it should receive a parameter that it thinks is fee % in __init__
UniswapV2LivePricing
is created too early - without know of the universe or routing create_trade_execution_model
- https://github.com/tradingstrategy-ai/trade-executor/blob/master/tradeexecutor/cli/init.py#L74This is the factory
def uniswap_v2_live_pricing_factory(
execution_model: ExecutionModel,
universe: TradingStrategyUniverse,
routing_model: UniswapV2SimpleRoutingModel) -> UniswapV2LivePricing:
assert isinstance(universe, TradingStrategyUniverse)
assert isinstance(execution_model, (UniswapV2ExecutionModelVersion0, UniswapV2ExecutionModel)), f"Execution model not compatible with this execution model. Received {execution_model}"
assert isinstance(routing_model, UniswapV2SimpleRoutingModel), f"This pricing method only works with Uniswap routing model, we received {routing_model}"
web3 = execution_model.web3
return UniswapV2LivePricing(
web3,
universe.universe.pairs,
routing_model)
To fix this properly
UniswapV2SimpleRoutingModel
as it is created in routing_data.py
where we can hardcode it per supporter routeruniswap_v2_live_pricing_factory
and passed to UniswapV2LivePricing
How does this sound like?
@miohtama See PR #136. One question, if routing_model
is passed as a parameter to UniswapV2LivePricing
, do we need to pass the fee as a parameter as well? Because we can get the fee from the routing_model
Both entry and exit estimates are off by 0.05%. Because this is constant across all trades, it is unlikely to be natural slippage.