Skip to content

Commit

Permalink
Add underscores to non-interface functions
Browse files Browse the repository at this point in the history
  • Loading branch information
nagakingg committed Oct 30, 2023
1 parent efb159a commit 389b58c
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions curvesim/pipelines/vol_limited_arb/trader.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,14 @@ def multipair_optimal_arbitrage( # noqa: C901 pylint: disable=too-many-locals
Results object from the numerical optimizer.
"""
all_trades = get_arb_trades(pool, prices)
input_trades, skipped_trades = apply_volume_limits(all_trades, limits, pool)
input_trades, skipped_trades = _apply_volume_limits(all_trades, limits, pool)

if not input_trades:
price_errors = make_price_errors(skipped_trades=skipped_trades, pool=pool)
price_errors = _make_price_errors(skipped_trades=skipped_trades, pool=pool)
return [], price_errors, None

input_trades = sort_trades_by_size(input_trades)
least_squares_inputs = make_least_squares_inputs(input_trades, limits)
input_trades = _sort_trades_by_size(input_trades)
least_squares_inputs = _make_least_squares_inputs(input_trades, limits)

def post_trade_price_error_multi(amounts_in, price_targets, coin_pairs):
with pool.use_snapshot_context():
Expand Down Expand Up @@ -123,17 +123,17 @@ def post_trade_price_error_multi(amounts_in, price_targets, coin_pairs):
if amount_in > min_size:
trades.append(Trade(trade.coin_in, trade.coin_out, amount_in))

price_errors = make_price_errors(input_trades, res.fun, skipped_trades, pool)
price_errors = _make_price_errors(input_trades, res.fun, skipped_trades, pool)

except Exception:
logger.error("Opt Arbs:\n %s", pformat(least_squares_inputs), exc_info=True)
price_errors = make_price_errors(skipped_trades=all_trades, pool=pool)
price_errors = _make_price_errors(skipped_trades=all_trades, pool=pool)
res = None

return trades, price_errors, res


def apply_volume_limits(arb_trades, limits, pool):
def _apply_volume_limits(arb_trades, limits, pool):
"""
Returns list of ArbTrades with amount_in set to min(limit, amount_in). Any trades
limited to less than the pool's minimum trade size are excluded.
Expand All @@ -154,13 +154,13 @@ def apply_volume_limits(arb_trades, limits, pool):
return limited_arb_trades, excluded_trades


def sort_trades_by_size(trades):
def _sort_trades_by_size(trades):
"""Sorts trades by amount_in."""
sorted_trades = sorted(trades, reverse=True, key=lambda t: t.amount_in)
return sorted_trades


def make_least_squares_inputs(trades, limits):
def _make_least_squares_inputs(trades, limits):
"""
Returns a dict of trades, bounds, and targets formatted as kwargs for least_squares.
"""
Expand All @@ -178,7 +178,7 @@ def make_least_squares_inputs(trades, limits):
}


def make_price_errors(trades=None, trade_errors=None, skipped_trades=None, pool=None):
def _make_price_errors(trades=None, trade_errors=None, skipped_trades=None, pool=None):
"""
Returns a dict mapping coin pairs to price errors.
Expand Down

0 comments on commit 389b58c

Please sign in to comment.