ExchangeUniverse#

tradingstrategy.exchange.ExchangeUniverse class.

class ExchangeUniverse[source]#

Bases: object

Exchange manager.

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

__init__(exchanges)#
Parameters

exchanges (Dict[PrimaryKey, Exchange]) –

Return type

None

Methods

__init__(exchanges)

from_dict(kvs, *[, infer_missing])

from_json(s, *[, parse_float, parse_int, ...])

get_by_chain_and_factory(chain_id, ...)

Get the exchange implementation on a specific chain.

get_by_chain_and_name(chain_id, name)

Get the exchange implementation on a specific chain.

get_by_chain_and_slug(chain_id, slug)

Get the exchange implementation on a specific chain.

get_by_id(id)

get_top_exchanges_by_30d_volume()

Get top exchanges sorted by their 30d volume.

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

to_dict([encode_json])

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

Attributes

exchanges

Exchange id -> Exchange data mapping

exchanges: Dict[PrimaryKey, Exchange]#

Exchange id -> Exchange data mapping

get_top_exchanges_by_30d_volume()[source]#

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.

Return type

List[Exchange]

get_by_chain_and_name(chain_id, name)[source]#

Get the exchange implementation on a specific chain.

Parameters
  • chain_id (ChainId) – Blockchain this exchange is on

  • name (str) – Like sushi or uniswap v2. Case insensitive.

Return type

Optional[Exchange]

get_by_chain_and_slug(chain_id, slug)[source]#

Get the exchange implementation on a specific chain.

Parameters
  • chain_id (ChainId) – Blockchain this exchange is on

  • slug (str) – Machine readable exchange name. Like uniswap-v2. Case sensitive.

Return type

Optional[Exchange]

get_by_chain_and_factory(chain_id, factory_address)[source]#

Get the exchange implementation on a specific chain.

Parameters
  • chain_id (ChainId) – Blockchain this exchange is on

  • factory_address (str) – The smart contract address of the exchange factory

Return type

Optional[Exchange]

__init__(exchanges)#
Parameters

exchanges (Dict[PrimaryKey, Exchange]) –

Return type

None