Exchange

Exchange information and analysis.

class tradingstrategy.exchange.ExchangeType

What kind of an decentralised exchange, AMM or other the pair is trading on.

Note that each type can have multiple implementations. For example QuickSwap, Sushi and Pancake are all Uniswap v2 types.

uniswap_v2 = 'uni_v2'

Uniswap v2 style exchange

uniswap_v3 = 'uni_v3'

Uniswap v3 style exchange

sushi_v3 = 'uni_v3'

Sushiswap v3 style exchange

class tradingstrategy.exchange.Exchange

A decentralised exchange.

Each chain can have multiple active or abadon decentralised exchanges of different types, like AMM based or order book based.

The dataset server server automatically discovers exchanges and tries to add meaningful label and risk data for them.

Regarding 30d and life time stats like buy_volume_30d: These stats calculated only if exchanged deemed active and we can convert the volume to a supported quote token. Any unsupported token volume does not show up in these stats. Useful mostly for risk assessment, as this data is not accurate, but gives some reference information about the popularity of the token.

chain_id: tradingstrategy.chain.ChainId

The chain id on which chain this pair is trading. 1 for Ethereum.

chain_slug: str

The URL slug derived from the blockchain name. Used as the primary key in URLs and other user facing services.] Example: “ethereum”, “polygon”

exchange_id: tradingstrategy.types.PrimaryKey

The exchange where this token trades

exchange_slug: str

The URL slug derived from the exchange name. Used as the primary key in URLs and other user facing addressers.

address: tradingstrategy.types.NonChecksummedAddress

The factory smart contract address of Uniswap based exchanges

exchange_type: tradingstrategy.exchange.ExchangeType

What kind of exchange is this

pair_count: int

How many pairs we have discovered for this exchange so far

last_trade_at: Optional[tradingstrategy.types.UNIXTimestamp] = None

When someone traded on this exchange last time

name: Optional[str] = None

Exchange name - if known or guessed

buy_count_all_time: Optional[int] = None

Denormalised exchange statistics

sell_count_all_time: Optional[int] = None

Denormalised exchange statistics

buy_volume_all_time: Optional[float] = None

Denormalised exchange statistics

sell_volume_all_time: Optional[float] = None

Denormalised exchange statistics

buy_count_30d: Optional[int] = None

Denormalised exchange statistics

sell_count_30d: Optional[int] = None

Denormalised exchange statistics

buy_volume_30d: Optional[float] = None

Denormalised exchange statistics

sell_volume_30d: Optional[float] = None

Denormalised exchange statistics

__init__(chain_id: tradingstrategy.chain.ChainId, chain_slug: str, exchange_id: tradingstrategy.types.PrimaryKey, exchange_slug: str, address: tradingstrategy.types.NonChecksummedAddress, exchange_type: tradingstrategy.exchange.ExchangeType, pair_count: int, last_trade_at: Optional[tradingstrategy.types.UNIXTimestamp] = None, name: Optional[str] = None, buy_count_all_time: Optional[int] = None, sell_count_all_time: Optional[int] = None, buy_volume_all_time: Optional[float] = None, sell_volume_all_time: Optional[float] = None, buy_count_30d: Optional[int] = None, sell_count_30d: Optional[int] = None, buy_volume_30d: Optional[float] = None, sell_volume_30d: Optional[float] = None) None
class tradingstrategy.exchange.ExchangeUniverse

Exchange manager.

Contains look up for exchanges by their internal primary key ids.

exchanges: Dict[tradingstrategy.types.PrimaryKey, tradingstrategy.exchange.Exchange]

Exchange id -> Exchange data mapping

get_top_exchanges_by_30d_volume() List[tradingstrategy.exchange.Exchange]

Get top exchanges sorted by their 30d volume.

Note that we consider volume only for supported quote tokens. See tradingstrategy.exchange.Exchange for more details.

get_by_name_and_chain(chain_id: tradingstrategy.chain.ChainId, name: str) Optional[tradingstrategy.exchange.Exchange]

Get the exchange implementation on a specific chain.

Parameters
  • chain_id – Blockchain this exchange is on

  • name – Like sushiswap or uniswap v2. Case insensitive.

__init__(exchanges: Dict[tradingstrategy.types.PrimaryKey, tradingstrategy.exchange.Exchange]) None