TopPairData#
API documentation for tradingstrategy.top.TopPairData Python class in Trading Strategy framework.
- class TopPairData[source]#
Bases:
object
Entry for one trading pair data in top picks.
Contains - Latest cached volue
volume_24h_usd
- Latest cached liquidity/TVLtvl_latest_usd
(may not be yet available for all tokens) - TokenSniffer risk scorerisk_score
- TokenSniffer token tax dataget_buy_tax()
/get_sekk_tax()
Example:
comp_weth = top_reply.included[0] assert comp_weth.base_token == "COMP" assert comp_weth.quote_token == "WETH" assert comp_weth.get_buy_tax() == 0 assert comp_weth.get_sell_tax() == 0 assert comp_weth.volume_24h_usd > 100.0 assert comp_weth.tvl_latest_usd > 100.0
- __init__(queried_at, chain_id, pair_id, exchange_id, exchange_slug, pool_address, base_token, quote_token, fee, volume_24h_usd, tvl_latest_usd, tvl_updated_at, volume_updated_at, exclude_reason, token_sniffer_data)#
- Parameters:
queried_at (datetime) –
chain_id (int) –
pair_id (int) –
exchange_id (int) –
exchange_slug (str) –
pool_address (str) –
base_token (str) –
quote_token (str) –
fee (float) –
volume_24h_usd (float | None) –
tvl_latest_usd (float | None) –
tvl_updated_at (datetime.datetime | None) –
volume_updated_at (datetime.datetime | None) –
exclude_reason (str | None) –
token_sniffer_data (dict | None) –
- Return type:
None
Methods
__init__
(queried_at, chain_id, pair_id, ...)from_dict
(kvs, *[, infer_missing])from_json
(s, *[, parse_float, parse_int, ...])get_buy_tax
([epsilon])What was the TokenSniffer buy tax for the base token.
Human readable id for the DEX this pair trades on.
Stable id over long period of time and across different systems.
get_sell_tax
([epsilon])What was the TokenSniffer sell tax for the base token.
Simple marker ticker identifier for this pair.
Do we have tax data for this pair.
schema
(*[, infer_missing, only, exclude, ...])to_dict
([encode_json])to_json
(*[, skipkeys, ensure_ascii, ...])Attributes
When this entry was queried
Blockchain this pair is on
Internal pair primary key (may change)
Internal pair exchange id (may change)
Human readable exchange URL slug (may change)
Smart contract address of pool smart contract.
Human readable base token
Human readable quote token
Pair fee in 0...1, 0.0030 is 30 BPS
Volume over the last 24h
Last USD TVL (Uniswap v3) or XY Liquidity (Uniswap v2)
When TVL measurement was updated.
When volume measurement was updated
If this pair was excluded from the top pairs, what was the human-readable heuristics reason we did this.
TokenSniffer data for this token.
What was the TokenSniffer score for the base token.
- queried_at: datetime#
When this entry was queried
Wall clock UTC time.
Because the server serialises as ISO, we need special decoder
https://github.com/lidatong/dataclasses-json?tab=readme-ov-file#Overriding
- pool_address: str#
Smart contract address of pool smart contract.
Uniswap v2 pair contract address, Uniswap v3 pool contract address.
- volume_24h_usd: float | None#
Volume over the last 24h
May not be available due to latency/denormalisation/etc. issues
- tvl_latest_usd: float | None#
Last USD TVL (Uniswap v3) or XY Liquidity (Uniswap v2)
May not be available due to latency/denormalisation/etc. issues
- tvl_updated_at: datetime.datetime | None#
When TVL measurement was updated.
How old data are we using.
- volume_updated_at: datetime.datetime | None#
When volume measurement was updated
How old data are we using.
- exclude_reason: str | None#
If this pair was excluded from the top pairs, what was the human-readable heuristics reason we did this.
This allows you to diagnose better why some trading pairs might not end up in the trading universe.
- token_sniffer_data: dict | None#
TokenSniffer data for this token.
Used in the filtering of scam tokens.
Not available for all tokens that are filtered out for other reasons. This is the last check.
- get_persistent_string_id()[source]#
Stable id over long period of time and across different systems.
- Return type:
- has_tax_data()[source]#
Do we have tax data for this pair.
The token tax data availability comes from TokenSniffer. No insight what tells whether it should be available or not.
- Returns:
True/False is TokenSniffer data is available, otherwise None.
- Return type:
bool | None
- get_buy_tax(epsilon=0.0001)[source]#
What was the TokenSniffer buy tax for the base token.
See also
has_tax_data()
.- Parameters:
epsilon – Deal with rounding errors.
- Returns:
Buy tax 0….1 or None if not available
- Return type:
float | None
- get_sell_tax(epsilon=0.0001)[source]#
What was the TokenSniffer sell tax for the base token.
See also
has_tax_data()
.- Parameters:
epsilon – Deal with rounding errors.
- Returns:
Sell tax 0….1 or None if not available
- Return type:
float | None
- __init__(queried_at, chain_id, pair_id, exchange_id, exchange_slug, pool_address, base_token, quote_token, fee, volume_24h_usd, tvl_latest_usd, tvl_updated_at, volume_updated_at, exclude_reason, token_sniffer_data)#
- Parameters:
queried_at (datetime) –
chain_id (int) –
pair_id (int) –
exchange_id (int) –
exchange_slug (str) –
pool_address (str) –
base_token (str) –
quote_token (str) –
fee (float) –
volume_24h_usd (float | None) –
tvl_latest_usd (float | None) –
tvl_updated_at (datetime.datetime | None) –
volume_updated_at (datetime.datetime | None) –
exclude_reason (str | None) –
token_sniffer_data (dict | None) –
- Return type:
None