Open nlordell opened 4 years ago
Instead of discarding transitive orders, should we reduce all direct orders that would not be matchable due to that constraint in a pre-processing step? I'm worried that if we ignored transitive orders, we might fill parts of larger orders which in their entirety could lead to better prices.
E.g. consider the transitive order A->C via A->B->C. If B->C doesn't have enough volume to be economically viable we should only ignore this part and not the complete transitive order A->B->C as the other part (A->B) could still be used in a transitive order (e.g. A->B->D->C).
I'm worried that if we ignored transitive orders, we might fill parts of larger orders which in their entirety could lead to better prices.
My hope is that this won't be too much of an issue, since we are failing to satisfy the economic viability constraint then the amounts should be small. So the larger part of the order will still be available. If it isn't, then this transitive order would have only been able to fulfill a small amount of the full buy amount and is unlikely to affect the final price estimate (unless it is the proverbial last drop in the bucket)...
E.g. consider the transitive order [...]
...But this is a great suggestion! I think this can be done fairly easily with the current model.
I thought about this a bunch, and I think the best way to implement this would be the same way we implemented the rounding buffer, so outside the pricegraph
and in the price estimator. This would require computing price estimates for all tokens on every orderbook update and create the Pricegraph
with orders that are filtered to be economically viable.
The implementation would be fairly straight forward:
m
(using the existing EconomicViability
component).p
for a token (using the exisitng Pricegraph::estimate_token_price
API).2000 * p * m / 1e18
(I think)Pricegraph
instance filtering out all orders with effective_remaining_sell_amount < min_trade_amount
.Pricegraph
created in the previous step to compute the price estimate with an added check that the sell_amount
used for the price estimate is > min_trade_amount
(returning None
if it isn't).
We can approximate the economic viability constraint by checking the traded amounts in the transitive orders against connected OWL limit prices. We would then discard any transitive orders that do not satisfy these constraints.