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/TVL tvl_latest_usd (may not be yet available for all tokens) - TokenSniffer risk score risk_score - TokenSniffer token tax data get_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:
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.

get_exchange_slug()

Human readable id for the DEX this pair trades on.

get_persistent_string_id()

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.

get_ticker()

Simple marker ticker identifier for this pair.

has_tax_data()

Do we have tax data for this pair.

schema(*[, infer_missing, only, exclude, ...])

to_dict([encode_json])

to_json(*[, skipkeys, ensure_ascii, ...])

Attributes

queried_at

When this entry was queried

chain_id

Blockchain this pair is on

pair_id

Internal pair primary key (may change)

exchange_id

Internal pair exchange id (may change)

exchange_slug

Human readable exchange URL slug (may change)

pool_address

Smart contract address of pool smart contract.

base_token

Human readable base token

quote_token

Human readable quote token

fee

Pair fee in 0...1, 0.0030 is 30 BPS

volume_24h_usd

Volume over the last 24h

tvl_latest_usd

Last USD TVL (Uniswap v3) or XY Liquidity (Uniswap v2)

tvl_updated_at

When TVL measurement was updated.

volume_updated_at

When volume measurement was updated

exclude_reason

If this pair was excluded from the top pairs, what was the human-readable heuristics reason we did this.

token_sniffer_data

TokenSniffer data for this token.

token_sniffer_score

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

chain_id: int#

Blockchain this pair is on

pair_id: int#

Internal pair primary key (may change)

exchange_id: int#

Internal pair exchange id (may change)

exchange_slug: str#

Human readable exchange URL slug (may change)

pool_address: str#

Smart contract address of pool smart contract.

Uniswap v2 pair contract address, Uniswap v3 pool contract address.

base_token: str#

Human readable base token

quote_token: str#

Human readable quote token

fee: float#

Pair fee in 0…1, 0.0030 is 30 BPS

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.

See more information here.

get_ticker()[source]#

Simple marker ticker identifier for this pair.

Return type:

str

get_exchange_slug()[source]#

Human readable id for the DEX this pair trades on.

Return type:

str

get_persistent_string_id()[source]#

Stable id over long period of time and across different systems.

Return type:

str

property token_sniffer_score: int | None#

What was the TokenSniffer score for the base token.

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:
Return type:

None