-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exclude too-small trades from optimizer #279
Conversation
Coverage reportThe coverage rate went from
Diff Coverage details (click to unfold)curvesim/metrics/metrics.py
curvesim/pipelines/common/init.py
curvesim/pipelines/simple/trader.py
curvesim/pipelines/vol_limited_arb/strategy.py
curvesim/pipelines/vol_limited_arb/trader.py
curvesim/templates/trader.py
|
5895bb2
to
2ac26b1
Compare
The simple pipeline CI is unaffected by these changes, except for the price_error values, which differ slightly due to the new computation. For the volume limited pipeline, the results change slightly. Qualitatively, they look pretty similar but perhaps slightly denoised. 3pool on current main branch:3pool on this branch: |
The comparison is simlar for TriCRV, except that the price errors come out quite noisy. Since the price errors are reduced using the new computation, this may reflect a noise floor. But I wonder if its better to record price errors as percect deviation from each target price. Currently they are absolute, which probably makes less sense for v2 pools. TriCRV on current main branch:TriCRV on this branch: |
- Exclude trades smaller than pool's minimum trade size from optimization in get_arb_trades and multipair_optimal arbitrage - Scale price errors by target price - Return price errors as dicts with trading pair as key - Add ArbTrade class to templates.trader
25ed29a
to
6c9e2e3
Compare
Description
Fixes #223 -- trades are excluded from optimization in multipair_optimal_arbitrage if their volume limit is <=
pool.get_min_trade_size()
.Additionally, trades are excluded from optimization in get_arb_trades if the optimal trade size is less than
pool.get_min_trade_size()
(i.e., the minimum trade size would cause the pool price to become less than the target market price). In this case, a trade in the right direction, but with size 0 is returned. This prevents similar errors as those discussed in #223, and prevents trades that are smaller than a pool's min trade size, but within the single-trade optimization inget_arb_trades
.Important change with downstream effects:
Previously, if no profitable arb was available for a particular pair,
get_arb_trades
would return a trade with size 0 in whatever direction the coin symbols were listed in. E.g., if market prices were indexed as (ETH, BTC), it would return a 0 trade with ETH as coin in and BTC as coin out. This had downstream effects for multipair_optimal_arbitrage (because only trades in that direction were allowed in the multi-trade optimization) and subsequent price error calculations (because price error was always computed in that arbitrary direction).With these changes, if no profitable arb is available (give the minimum trade size), a trade with size 0 in the more profitable direction is returned. This allows 'multipair_optimal_arbitrage' to make trades in that direction if they become available after previous trades in each optimizer iteration, and causes price error to always be computed in the direction of the best possible trade.
Additional changes:
Hygiene checklist
(modules, public functions, classes, and public methods)
and descriptive commit messages following Tim Pope's style
Cute Animal Picture