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)#
Parameters:
Return type:

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

active_pair_count

How many supported trading pairs we have See https://tradingstrategy.ai/docs/programming/tracking.html for more information

buy_count_30d

Denormalised exchange statistics

buy_count_all_time

Denormalised exchange statistics

buy_volume_30d

Denormalised exchange statistics

buy_volume_all_time

Denormalised exchange statistics

default_router_address

The default router address

first_trade_at

When someone traded on this exchange for the first time

homepage

Exchange homepage if available as https:// link

init_code_hash

Uniswap v2 implementation specific init cod ehash.

last_trade_at

When someone traded on this exchange last time

name

Exchange name - if known or guessed

sell_count_30d

Denormalised exchange statistics

sell_count_all_time

Denormalised exchange statistics

sell_volume_30d

Denormalised exchange statistics

sell_volume_all_time

Denormalised exchange statistics

vol_30d

chain_id

The chain id on which chain this pair is trading.

chain_slug

The URL slug derived from the blockchain name.

exchange_id

The exchange where this token trades

exchange_slug

The URL slug derived from the exchange name.

address

The factory smart contract address of Uniswap based exchanges.

exchange_type

What kind of exchange is this

pair_count

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_id: int#

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: str#

The factory smart contract address of Uniswap based exchanges.

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

first_trade_at: Optional[int] = None#

When someone traded on this exchange for the first time

last_trade_at: Optional[int] = None#

When someone traded on this exchange last time

name: Optional[str] = None#

Exchange name - if known or guessed

homepage: Optional[str] = None#

Exchange homepage if available as https:// link

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

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)#
Parameters:
Return type:

None