Exchange#
API documentation for tradingstrategy.exchange.Exchange Python class in Trading Strategy framework.
- class Exchange[source]#
Bases:
object
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.
- __init__(chain_id, chain_slug, exchange_id, exchange_slug, address, exchange_type, pair_count, active_pair_count=None, first_trade_at=None, last_trade_at=None, name=None, homepage=None, buy_count_all_time=None, sell_count_all_time=None, buy_volume_all_time=None, sell_volume_all_time=None, buy_count_30d=None, sell_count_30d=None, buy_volume_30d=None, sell_volume_30d=None, default_router_address=None, init_code_hash=None)#
Methods
__init__
(chain_id, chain_slug, exchange_id, ...)from_dict
(kvs, *[, infer_missing])from_json
(s, *[, parse_float, parse_int, ...])schema
(*[, infer_missing, only, exclude, ...])to_dict
([encode_json])to_json
(*[, skipkeys, ensure_ascii, ...])Attributes
How many supported trading pairs we have See https://tradingstrategy.ai/docs/programming/tracking.html for more information
Denormalised exchange statistics
Denormalised exchange statistics
Denormalised exchange statistics
Denormalised exchange statistics
The default router address
When someone traded on this exchange for the first time
Exchange homepage if available as https:// link
Uniswap v2 implementation specific init cod ehash.
When someone traded on this exchange last time
Exchange name - if known or guessed
Denormalised exchange statistics
Denormalised exchange statistics
Denormalised exchange statistics
Denormalised exchange statistics
vol_30d
The chain id on which chain this pair is trading.
The URL slug derived from the blockchain name.
The exchange where this token trades
The URL slug derived from the exchange name.
The factory smart contract address of Uniswap based exchanges.
What kind of exchange is this
How many pairs we have discovered for this exchange so far TODO: Make optional - not needed in the tester deployments.
- chain_id: 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_slug: str#
The URL slug derived from the exchange name. Used as the primary key in URLs and other user facing addressers.
- exchange_type: 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
- default_router_address: Optional[str] = None#
The default router address
If there is a well-known default router implementation like UniswapV2Router or UniswapV3Router then have its address here. This cannot be automatically resolved, but the information must be manually managed for every DEX.
Might not be set.
- init_code_hash: Optional[str] = None#
Uniswap v2 implementation specific init cod ehash.
This might be needed in order to route trades. 0x prefixed hex string of keccak hash.
#: Might not be set.
- __init__(chain_id, chain_slug, exchange_id, exchange_slug, address, exchange_type, pair_count, active_pair_count=None, first_trade_at=None, last_trade_at=None, name=None, homepage=None, buy_count_all_time=None, sell_count_all_time=None, buy_volume_all_time=None, sell_volume_all_time=None, buy_count_30d=None, sell_count_30d=None, buy_volume_30d=None, sell_volume_30d=None, default_router_address=None, init_code_hash=None)#