categorise_pairs#
API documentation for tradingstrategy.alternative_data.coingecko.categorise_pairs Python function.
- categorise_pairs(coingecko_universe, pairs_df)[source]#
Categorise trading pairs by their Coingecko category.
This produces category data for trading pairs (not for assets, same asset can be in multiple trading pairs)
Trading pairs are categorised by their base token
Example:
pairs_df = client.fetch_pair_universe().to_pandas() coingecko_universe = CoingeckoUniverse.load() category_df = categorise_pairs(coingecko_universe, pairs_df) # Get pair_ids for all tokens in Coingecko's DeFi category mask = category_df["category"] == "Decentralized Finance (DeFi)" pair_ids = category_df[mask]["pair_id"]
See also
SAMPLE_CATEGORIES
for soe example categories.See also another example in
tradingstrategy.utils.token_filter.deduplicate_pairs_by_volume()
.- Parameters:
coingecko_universe (CoingeckoUniverse) – Coingecko data bundle.
pairs_df (DataFrame) – As produced by
tradingstrategy.client.Client
- Returns:
A new dataframe which contains (pair_id int, address str, category str) for each token, and no index.
Each pair_id has multiple rows, one for each category where it is contained.
- Return type:
DataFrame