Exchanges¶
Exchange information and analysis.
Exchanges are presented by
Exchange
classTo download the pairs dataset see
- 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.
Most of the fields are optionally and having values them depends on the oracle data indexinb phase.
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. For JSON, this is serialised as one of the name of enum memmbers of ChainId e.g. “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 TODO: Make optional - not needed in the tester deployments.
- active_pair_count: Optional[int] = None¶
How many supported trading pairs we have See https://tradingstrategy.ai/docs/programming/tracking.html for more information
- first_trade_at: Optional[tradingstrategy.types.UNIXTimestamp] = None¶
When someone traded on this exchange for the first time
- last_trade_at: Optional[tradingstrategy.types.UNIXTimestamp] = None¶
When someone traded on this exchange last time
- __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, active_pair_count: Optional[int] = None, first_trade_at: Optional[tradingstrategy.types.UNIXTimestamp] = None, last_trade_at: Optional[tradingstrategy.types.UNIXTimestamp] = None, name: Optional[str] = None, homepage: 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_chain_and_name(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 sushi or uniswap v2. Case insensitive.
- get_by_chain_and_slug(chain_id: tradingstrategy.chain.ChainId, slug: str) Optional[tradingstrategy.exchange.Exchange] ¶
Get the exchange implementation on a specific chain.
- Parameters
chain_id – Blockchain this exchange is on
slug – Machine readable exchange name. Like uniswap-v2. Case sensitive.
- get_by_chain_and_factory(chain_id: tradingstrategy.chain.ChainId, factory_address: str) Optional[tradingstrategy.exchange.Exchange] ¶
Get the exchange implementation on a specific chain.
- Parameters
chain_id – Blockchain this exchange is on
factory_address – The smart contract address of the exchange factory
- __init__(exchanges: Dict[tradingstrategy.types.PrimaryKey, tradingstrategy.exchange.Exchange]) None ¶