VaultPricing#
API documentation for tradeexecutor.ethereum.vault.vault_live_pricing.VaultPricing Python class in Trading Strategy framework.
- class VaultPricing[source]#
Bases:
PricingModel
Always pull the latest live share price of a vault.
Note
Only supports stablecoin-nominated vaults
Methods
__init__
(web3)calculate_trade_adjusted_slippage_tolerance
(...)Get slippage for a given trading pair, for a given trade.
get_buy_price
(ts, pair, reserve)Get live price on vault for dumping our shares.
get_mid_price
(ts, pair)Get the mid-price for an asset.
get_pair_fee
(ts, pair)Estimate the trading/LP fees for a trading pair.
get_quote_token_tvl
(timestamp, pair)Get the raw TVL of a trading pair.
get_sell_price
(ts, pair, quantity)Get live price on vault for dumping our shares.
get_usd_tvl
(timestamp, pair)Get the TVL of a trading pair.
get_vault
(target_pair)Helper function to speed up vault deployment resolution.
quantize_base_quantity
(pair, quantity[, ...])Convert any base token quantity to the native token units by its ERC-20 decimals.
set_trading_fee_override
(trading_fee_override)Set the trading fee override.
- get_vault(target_pair)[source]#
Helper function to speed up vault deployment resolution.
- Parameters:
target_pair (TradingPairIdentifier) –
- Return type:
- get_sell_price(ts, pair, quantity)[source]#
Get live price on vault for dumping our shares.
- Parameters:
ts (datetime) –
pair (TradingPairIdentifier) –
- Return type:
- get_buy_price(ts, pair, reserve)[source]#
Get live price on vault for dumping our shares.
- Parameters:
ts (datetime) –
pair (TradingPairIdentifier) –
- Return type:
- get_mid_price(ts, pair)[source]#
Get the mid-price for an asset.
Mid price is an non-trddeable price between the best ask and the best pid.
- Parameters:
ts (datetime) – Timestamp. Ignored for live pricing models.
pair (TradingPairIdentifier) – Which trading pair price we query.
- Returns:
The mid price for the pair at a timestamp.
- Return type:
- get_pair_fee(ts, pair)[source]#
Estimate the trading/LP fees for a trading pair.
This information can come either from the exchange itself (Uni v2 compatibles), or from the trading pair (Uni v3).
The return value is used to fill the fee values for any newly opened trades.
- Parameters:
ts (datetime) – Timestamp of the trade. Note that currently fees do not vary over time, but might do so in the future.
pair (TradingPairIdentifier) –
Trading pair for which we want to have the fee.
Can be left empty if the underlying exchange is always offering the same fee.
- Returns:
The estimated trading fee, expressed as %.
Returns None if the fee information is not available. This can be different from zero fees.
- Return type: