CoingeckoUniverse#
API documentation for tradingstrategy.alternative_data.coingecko.CoingeckoUniverse Python class in Trading Strategy framework.
- class CoingeckoUniverse[source]#
Bases:
object
Coingecko data universe.
Manage loading and saving Coingecko data in a flat file database
Create id and address lookups for tokens
We provide a default bundle of first 1000 tokens as
DEFAULT_COINGECKO_BUNDLE
included in Trading Strategy PyPi package, sorted by the market cap at the time of creation
Example usage:
# Print out all categories Coingecko has in our default bundle from tradingstrategy.alternative_data.coingecko import CoingeckoUniverse # Loads the default bundle included in PyPi package coingecko_universe = CoingeckoUniverse.load() # Prints out all categories found in this bundle. # at the time of recording categories = sorted(list(coingecko_universe.get_all_categories()), key=str.lower) for cat in categories: print(cat)
Then you can use this universe to build trading pair universe of a specific category, see
categorise_pairs()
for details
- __init__(data)[source]#
Create new universe from raw JSON data.
Build access indices
- Parameters:
data (list[tradingstrategy.alternative_data.coingecko.CoingeckoEntry]) –
Methods
__init__
(data)Create new universe from raw JSON data.
Get list of Categories in our loade universe.
get_by_address
(address)Get entry by its smart contract address.
Get entry by its coingecko id.
get_entries_by_category
(category)Get all tokens under a certain Coingecko category.
load
([fname])Read JSON + zstd compressed Coingecko flat file database.
save
([fname])Create JSON + zstd compressed data file for Coingecko tokens.
Attributes
Raw data
Smart contract address -> entry map
Coingecko id -> entry map
Category -> list of entries map
- __init__(data)[source]#
Create new universe from raw JSON data.
Build access indices
- Parameters:
data (list[tradingstrategy.alternative_data.coingecko.CoingeckoEntry]) –
- data: list[tradingstrategy.alternative_data.coingecko.CoingeckoEntry]#
Raw data
- address_cache: dict[str, tradingstrategy.alternative_data.coingecko.CoingeckoEntry]#
Smart contract address -> entry map
See
get_by_address()
- id_cache: dict[str, tradingstrategy.alternative_data.coingecko.CoingeckoEntry]#
Coingecko id -> entry map
- category_cache: dict[str, list[tradingstrategy.alternative_data.coingecko.CoingeckoEntry]]#
Category -> list of entries map
- get_by_address(address)[source]#
Get entry by its smart contract address.
- Parameters:
address (str) – E.g. 0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9.
- Return type:
tradingstrategy.alternative_data.coingecko.CoingeckoEntry | None
- get_by_coingecko_id(id)[source]#
Get entry by its coingecko id.
- Parameters:
id (str) – E.g. bitcoin
- Return type:
tradingstrategy.alternative_data.coingecko.CoingeckoEntry | None
- get_all_categories()[source]#
Get list of Categories in our loade universe.
See
SAMPLE_CATEGORIES
for an example list
- get_entries_by_category(category)[source]#
Get all tokens under a certain Coingecko category.
- Parameters:
category (str) –
- Return type:
list[tradingstrategy.alternative_data.coingecko.CoingeckoEntry]
- static load(fname=PosixPath('/home/runner/work/docs/docs/deps/trade-executor/deps/trading-strategy/tradingstrategy/data_bundles/coingecko.json.zstd'))[source]#
Read JSON + zstd compressed Coingecko flat file database.
- Parameters:
fname (Path) – If not given, use the file bundled in trading-strategy package
- Return type:
- save(fname=PosixPath('/home/runner/work/docs/docs/deps/trade-executor/deps/trading-strategy/tradingstrategy/data_bundles/coingecko.json.zstd'))[source]#
Create JSON + zstd compressed data file for Coingecko tokens.
Save only raw data, no indices, which are re-created on read
- Parameters:
fname (Path) – If not given, use the file bundled in trading-strategy package
- Return type:
None