find_max_position_size
Documentation for eth_defi.gmx.market_depth.find_max_position_size function.
- find_max_position_size(long_open_interest_usd, short_open_interest_usd, is_long, max_price_impact_bps, params, max_oi_available_usd=0.0, search_precision_usd=100.0)
Find the maximum position size that keeps price impact within a threshold.
Uses binary search over the price impact curve, which is monotonically increasing with position size for balance-worsening trades.
- Parameters
long_open_interest_usd (float) – Current long open interest in USD
short_open_interest_usd (float) – Current short open interest in USD
is_long (bool) –
Truefor a long position,Falsefor shortmax_price_impact_bps (float) – Maximum acceptable price impact expressed in basis points (1 bps = 0.01 %). E.g.
5.0means 5 bps = 0.05 %.params (eth_defi.gmx.market_depth.PriceImpactParams) – Price impact parameters from
fetch_price_impact_params()max_oi_available_usd (float) – Upper bound for the search in USD. If
0(the default), falls back toGMX_DEFAULT_SEARCH_MAX_USD($100 M), which covers typical GMX market sizes. UseMarketDepthInfo.available_long_oi_usdorMarketDepthInfo.available_short_oi_usdhere for accuracy.search_precision_usd (float) – The binary search halts when the range is narrower than this value (USD). Default
100.0(i.e., $100 precision).
- Returns
Maximum position size in USD at which the absolute price impact stays at or below
max_price_impact_bpsbasis points. Returns0.0if even the smallest position exceeds the threshold.- Return type