CoingeckoClient#

API documentation for tradingstrategy.alternative_data.coingecko.CoingeckoClient Python class in Trading Strategy framework.

class CoingeckoClient[source]#

Bases: object

Minimal implementation of Coingecko API client.

__init__(api_key, retries=10, demo=False)[source]#
Parameters:

api_key (str) –

Methods

__init__(api_key[, retries, demo])

fetch_coin_data(id[, localization, tickers, ...])

Get Coingecko metadata.

fetch_coin_markets([page, per_page, vs_currency])

Get data with market cap.

fetch_coins_list()

Get full Coingecko list of its tokens.

make_request(name, params)

Coingecko JSON get wrapper.

__init__(api_key, retries=10, demo=False)[source]#
Parameters:

api_key (str) –

make_request(name, params)[source]#

Coingecko JSON get wrapper.

Parameters:
fetch_coins_list()[source]#

Get full Coingecko list of its tokens.

  • Slow API call, not paginated

Example data:

[
  {
    "id": "3a-lending-protocol",
    "symbol": "a3a",
    "name": "3A",
    "platforms": {
      "ethereum": "0x3f817b28da4940f018c6b5c0a11c555ebb1264f9",
      "polygon-pos": "0x58c7b2828e7f2b2caa0cc7feef242fa3196d03df",
      "linea": "0x3d4b2132ed4ea0aa93903713a4de9f98e625a5c7"
    }
  },

  {
    "id": "aave",
    "symbol": "aave",
    "name": "Aave",
    "platforms": {
      "ethereum": "0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9",
      "avalanche": "0x63a72806098bd3d9520cc43356dd78afe5d386d9",
      "optimistic-ethereum": "0x76fb31fb4af56892a25e32cfc43de717950c9278",
      "near-protocol": "7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9.factory.bridge.near",
      "huobi-token": "0x202b4936fe1a82a4965220860ae46d7d3939bb25",
      "polygon-pos": "0xd6df932a45c0f255f85145f286ea0b292b21c90b",
      "fantom": "0x6a07a792ab2965c72a5b8088d3a069a7ac3a993b",
      "harmony-shard-0": "0xcf323aad9e522b93f11c352caa519ad0e14eb40f",
      "energi": "0xa7f2f790355e0c32cab03f92f6eb7f488e6f049a",
      "sora": "0x0091bd8d8295b25cab5a7b8b0e44498e678cfc15d872ede3215f7d4c7635ba36",
      "binance-smart-chain": "0xfb6115445bff7b52feb98650c87f44907e58f802"
    }
  },
  ...
Return type:

list[dict]

fetch_coin_markets(page=1, per_page=50, vs_currency='usd')[source]#

Get data with market cap.

Example:

[
  {
    "id": "bitcoin",
    "symbol": "btc",
    "name": "Bitcoin",
    "image": "https://coin-images.coingecko.com/coins/images/1/large/bitcoin.png?1696501400",
    "current_price": 67717,
    "market_cap": 1338238834727,
    "market_cap_rank": 1,
    "fully_diluted_valuation": 1421419419213,
    "total_volume": 44825773373,
    "high_24h": 69432,
    "low_24h": 66839,
    "price_change_24h": -1063.1365066438157,
    "price_change_percentage_24h": -1.5457,
    "market_cap_change_24h": -23226732811.611816,
    "market_cap_change_percentage_24h": -1.70601,
    "circulating_supply": 19771093,
    "total_supply": 21000000,
    "max_supply": 21000000,
    "ath": 73738,
    "ath_change_percentage": -8.16696,
    "ath_date": "2024-03-14T07:10:36.635Z",
    "atl": 67.81,
    "atl_change_percentage": 99762.53649,
    "atl_date": "2013-07-06T00:00:00.000Z",
    "roi": null,
    "last_updated": "2024-10-21T21:00:46.632Z"
  },
  {
    "id": "ethereum",
    "symbol": "eth",
    "name": "Ethereum",
    "image": "https://coin-images.coingecko.com/coins/images/279/large/ethereum.png?1696501628",
    "current_price": 2675.55,
    "market_cap": 322048937059,
    "market_cap_rank": 2,
    "fully_diluted_valuation": 322048937059,
    "total_volume": 19681005944,
    "high_24h": 2762.43,
    "low_24h": 2657.49,
    "price_change_24h": -37.684795187311465,
    "price_change_percentage_24h": -1.38892,
    "market_cap_change_24h": -4892365002.109253,
    "market_cap_change_percentage_24h": -1.4964,
    "circulating_supply": 120391113.890841,
    "total_supply": 120391113.890841,
    "max_supply": null,
    "ath": 4878.26,
    "ath_change_percentage": -45.15344,
    "ath_date": "2021-11-10T14:24:19.604Z",
    "atl": 0.432979,
    "atl_change_percentage": 617841.93025,
    "atl_date": "2015-10-20T00:00:00.000Z",
    "roi": {
      "times": 51.831064806183065,
      "currency": "btc",
      "percentage": 5183.106480618307
    },
    "last_updated": "2024-10-21T21:00:48.325Z"
  },
fetch_coin_data(id, localization=False, tickers=False, market_data=False, community_data=True, developer_data=True, sparkline=False)[source]#

Get Coingecko metadata.

Example:

{
  "id": "bitcoin",
  "symbol": "btc",
  "name": "Bitcoin",
  "web_slug": "bitcoin",
  "asset_platform_id": null,
  "platforms": {
    "": ""
  },
  "detail_platforms": {
    "": {
      "decimal_place": null,
      "contract_address": ""
    }
  },
  "block_time_in_minutes": 10,
  "hashing_algorithm": "SHA-256",
  "categories": [
    "Cryptocurrency",
    "Layer 1 (L1)",
    "FTX Holdings",
    "Proof of Work (PoW)",
    "Bitcoin Ecosystem",
    "GMCI 30 Index"
  ],
  "preview_listing": false,
  "public_notice": null,
  "additional_notices": [],
  "description": {
    "en": "Bitcoin is the first successful internet money based on peer-to-peer technology; whereby no central bank or authority is involved in the transaction and production of the Bitcoin currency. It was created by an anonymous individual/group under the name, Satoshi Nakamoto. The source code is available publicly as an open source project, anybody can look at it and be part of the developmental process.

Bitcoin is changing the way we see money as we speak. The idea was to produce a means of exchange, independent of any central authority, that could be transferred electronically in a secure, verifiable and immutable way. It is a decentralized peer-to-peer internet currency making mobile payment easy, very low transaction fees, protects your identity, and it works anywhere all the time with no central authority and banks.

Bitcoin is designed to have only 21 million BTC ever created, thus making it a deflationary currency. Bitcoin uses the <a href=”https://www.coingecko.com/en?hashing_algorithm=SHA-256”>SHA-256</a> hashing algorithm with an average transaction confirmation time of 10 minutes. Miners today are mining Bitcoin using ASIC chip dedicated to only mining Bitcoin, and the hash rate has shot up to peta hashes.

Being the first successful online cryptography currency, Bitcoin has inspired other alternative currencies such as <a href=”https://www.coingecko.com/en/coins/litecoin”>Litecoin</a>, <a href=”https://www.coingecko.com/en/coins/peercoin”>Peercoin</a>, <a href=”https://www.coingecko.com/en/coins/primecoin”>Primecoin</a>, and so on.

The cryptocurrency then took off with the innovation of the turing-complete smart contract by <a href=”https://www.coingecko.com/en/coins/ethereum”>Ethereum</a> which led to the development of other amazing projects such as <a href=”https://www.coingecko.com/en/coins/eos”>EOS</a>, <a href=”https://www.coingecko.com/en/coins/tron”>Tron</a>, and even crypto-collectibles such as <a href=”https://www.coingecko.com/buzz/ethereum-still-king-dapps-cryptokitties-need-1-billion-on-eos”>CryptoKitties</a>.”

}, “links”: {

“homepage”: [

http://www.bitcoin.org”, “”, “”

], “whitepaper”: “https://bitcoin.org/bitcoin.pdf”, “blockchain_site”: [

], “official_forum_url”: [

https://bitcointalk.org/”, “”, “”

], “chat_url”: [

“”, “”, “”

], “announcement_url”: [

“”, “”

], “twitter_screen_name”: “bitcoin”, “facebook_username”: “bitcoins”, “bitcointalk_thread_identifier”: null, “telegram_channel_identifier”: “”, “subreddit_url”: “https://www.reddit.com/r/Bitcoin/”, “repos_url”: {

“github”: [

https://github.com/bitcoin/bitcoin”, “https://github.com/bitcoin/bips

], “bitbucket”: []

}

}, “image”: {

}, “country_origin”: “”, “genesis_date”: “2009-01-03”, “sentiment_votes_up_percentage”: 84.79, “sentiment_votes_down_percentage”: 15.21, “watchlist_portfolio_users”: 1698440, “market_cap_rank”: 1, “community_data”: {

“facebook_likes”: null, “twitter_followers”: 6894643, “reddit_average_posts_48h”: 0, “reddit_average_comments_48h”: 0, “reddit_subscribers”: 0, “reddit_accounts_active_48h”: 0, “telegram_channel_user_count”: null

}, “developer_data”: {

“forks”: 36426, “stars”: 73168, “subscribers”: 3967, “total_issues”: 7743, “closed_issues”: 7380, “pull_requests_merged”: 11215, “pull_request_contributors”: 846, “code_additions_deletions_4_weeks”: {

“additions”: 1570, “deletions”: -1948

}, “commit_count_4_weeks”: 108, “last_4_weeks_commit_activity_series”: []

}, “status_updates”: [], “last_updated”: “2024-10-21T20:20:14.059Z”

}

Parameters:

id (str) –