BaseTVLSizeRiskModel#
API documentation for tradeexecutor.strategy.tvl_size_risk.BaseTVLSizeRiskModel Python class in Trading Strategy framework.
- class BaseTVLSizeRiskModel[source]#
Bases:
SizeRiskModel
A trade sizer that uses % of TVL of the target pool as the cap.
Reads TVL estimation and uses that to set the maximum size for a trade
Used in backtesting - fast to test as we do not need to query the historical liquidity from the archive node to get the accurate price impact
- __init__(pricing_model, per_trade_cap=1.0, per_position_cap=1.0)[source]#
- Parameters:
per_trade_cap (float) – Maximum US dollar value of a single trade, or unlimited.
pricing_model (PricingModel) –
per_position_cap (float) –
Methods
__init__
(pricing_model[, per_trade_cap, ...])- param per_trade_cap:
get_acceptable_size_for_buy
(timestamp, pair, ...)get_acceptable_size_for_position
(timestamp, ...)Calculate maximum position size we can take on the pool.
get_acceptable_size_for_sell
(timestamp, ...)get_pair_cap
(pair, sizing_type)Get cap for an individual trade for a pair.
get_tvl
(timestamp, pair)Read the TVL from the underlying pricing model.
- __init__(pricing_model, per_trade_cap=1.0, per_position_cap=1.0)[source]#
- Parameters:
per_trade_cap (float) – Maximum US dollar value of a single trade, or unlimited.
pricing_model (PricingModel) –
per_position_cap (float) –
- get_pair_cap(pair, sizing_type)[source]#
Get cap for an individual trade for a pair.
Different pool types can have different caps because of CLMM has better capital efficiency
- Parameters:
pair (TradingPairIdentifier) –
sizing_type (SizingType) –
- Return type:
- get_acceptable_size_for_position(timestamp, pair, asked_value, check_price=False)[source]#
Calculate maximum position size we can take on the pool.
- Parameters:
check_price –
Backtest workaround.
Sometimes we have TVL, but not price yet, becauase TVL timeframe is different from the candle timeframe.
Check for the existing of the price as well, to make sure backtest can execute as otherwise it will crash when it tries to open a position without price data available.
pair (TradingPairIdentifier) –
asked_value (float) –
- Return type: