LegacyPairUniverse#
API documentation for tradingstrategy.pair.LegacyPairUniverse Python class in Trading Strategy framework.
- class LegacyPairUniverse[source]#
Bases:
object
The queries universe, as returned by the server.
Note
TODO: Legacy prototype implementation and will be deprecated.
Converts raw pair dataset to easier to use DEXPair in-memory index.
You likely want to use
PandasPairUniverse
, as its offers much more functionality than this implemetation.Methods
__init__
(pairs)create_from_pyarrow_table
(table)Convert columnar presentation to a Python in-memory objects.
Convert columnar presentation to a Python in-memory objects.
Filter for pairs that have see a trade for the last 30 days
get_all_pairs_on_exchange
(exchange_id)Get all trading pair on a decentralsied exchange.
Filter for pairs that have not see a trade for the last 30 days
get_pair_by_id
(pair_id)Resolve pair by its id.
get_pair_by_ticker
(base_token, quote_token)Get a trading pair by its ticker symbols.
get_pair_by_ticker_by_exchange
(exchange_id, ...)Get a trading pair by its ticker symbols.
Attributes
Internal id -> DEXPair mapping
- classmethod create_from_pyarrow_table(table)[source]#
Convert columnar presentation to a Python in-memory objects.
Some data manipulation is easier with objects instead of columns.
Note
This seems to quite slow operation. It is recommend you avoid this if you do not need row-like data.
- Parameters:
table (Table) –
- Return type:
- classmethod create_from_pyarrow_table_with_filters(table, chain_id_filter=None)[source]#
Convert columnar presentation to a Python in-memory objects.
Filter the pairs based on given filter arguments.
- Parameters:
- Return type:
- get_pair_by_id(pair_id)[source]#
Resolve pair by its id.
Only useful for debugging. Does a slow look
- get_pair_by_ticker(base_token, quote_token)[source]#
Get a trading pair by its ticker symbols.
Note that this method works only very simple universes, as any given pair is poised to have multiple tokens and multiple trading pairs on different exchanges.
- get_pair_by_ticker_by_exchange(exchange_id, base_token, quote_token)[source]#
Get a trading pair by its ticker symbols.
Note that this method works only very simple universes, as any given pair is poised to have multiple tokens and multiple trading pairs on different exchanges.
- Parameters:
- Raises:
DuplicatePair – If the universe contains more than single entry for the pair. Because we are looking by a token symbol there might be fake tokens with the same symbol.
- Returns:
None if there is no match
- Return type:
- get_all_pairs_on_exchange(exchange_id)[source]#
Get all trading pair on a decentralsied exchange.
Use ExchangeUniverse.get_by_chain_and_slug to resolve the exchange_id first. :param chain_id: E.g. ChainId.ethereum