From 73adbe9e0cecc2ccd904a7df8a7b3308c239885c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Nov 2024 03:56:42 +0000 Subject: [PATCH 1/3] chore(deps): bump pycoingecko from 3.1.0 to 3.2.0 Bumps [pycoingecko](https://github.com/man-c/pycoingecko) from 3.1.0 to 3.2.0. - [Changelog](https://github.com/man-c/pycoingecko/blob/master/CHANGELOG.md) - [Commits](https://github.com/man-c/pycoingecko/compare/3.1.0...3.2.0) --- updated-dependencies: - dependency-name: pycoingecko dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index ed7dd3e86..b30df7bb5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -20,7 +20,7 @@ jsonschema==4.23.0 TA-Lib==0.4.32 technical==1.4.4 tabulate==0.9.0 -pycoingecko==3.1.0 +pycoingecko==3.2.0 jinja2==3.1.4 tables==3.10.1 joblib==1.4.2 From 971cdbb918595e8a71b47cd174b2e85f34ac40d9 Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 18 Nov 2024 07:11:39 +0100 Subject: [PATCH 2/3] chore: Simplify coingecko wrapper after update --- freqtrade/util/coin_gecko.py | 19 +++---------------- tests/rpc/test_fiat_convert.py | 8 +++++--- 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/freqtrade/util/coin_gecko.py b/freqtrade/util/coin_gecko.py index f754e9bc0..515e9654f 100644 --- a/freqtrade/util/coin_gecko.py +++ b/freqtrade/util/coin_gecko.py @@ -4,23 +4,10 @@ from pycoingecko import CoinGeckoAPI class FtCoinGeckoApi(CoinGeckoAPI): """ Simple wrapper around pycoingecko's api to support Demo API keys. - """ - __API_URL_BASE = "https://api.coingecko.com/api/v3/" - __PRO_API_URL_BASE = "https://pro-api.coingecko.com/api/v3/" - _api_key: str = "" - def __init__(self, api_key: str = "", *, is_demo=True, retries=5): - super().__init__(retries=retries) - # Don't pass api_key to parent, instead set the header on the session directly - self._api_key = api_key - - if api_key and not is_demo: - self.api_base_url = self.__PRO_API_URL_BASE - self.session.params.update({"x_cg_pro_api_key": api_key}) + if api_key and is_demo: + super().__init__(retries=retries, demo_api_key=api_key) else: - # Use demo api key - self.api_base_url = self.__API_URL_BASE - if api_key: - self.session.params.update({"x_cg_demo_api_key": api_key}) + super().__init__(api_key=api_key, retries=retries) diff --git a/tests/rpc/test_fiat_convert.py b/tests/rpc/test_fiat_convert.py index 061df2e53..4ae7441c8 100644 --- a/tests/rpc/test_fiat_convert.py +++ b/tests/rpc/test_fiat_convert.py @@ -206,14 +206,16 @@ def test_convert_amount(mocker): def test_FtCoinGeckoApi(): ftc = FtCoinGeckoApi() - assert ftc._api_key == "" + assert ftc.extra_params is None assert ftc.api_base_url == "https://api.coingecko.com/api/v3/" # defaults to demo ftc = FtCoinGeckoApi(api_key="123456") - assert ftc._api_key == "123456" + assert ftc.extra_params is not None + assert ftc.extra_params["x_cg_demo_api_key"] == "123456" assert ftc.api_base_url == "https://api.coingecko.com/api/v3/" ftc = FtCoinGeckoApi(api_key="123456", is_demo=False) - assert ftc._api_key == "123456" + assert ftc.extra_params is not None + assert ftc.extra_params["x_cg_pro_api_key"] == "123456" assert ftc.api_base_url == "https://pro-api.coingecko.com/api/v3/" From fc3db2d29c2617e881a51d60c8ad3ce565f7b061 Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 18 Nov 2024 07:12:17 +0100 Subject: [PATCH 3/3] chore: force pycoingecko to be > 3.2.0 that's the first version supporting demo API keys --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index a5472d554..bb4575553 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -44,7 +44,7 @@ dependencies = [ "pandas-ta", "technical", "tabulate", - "pycoingecko", + "pycoingecko>=3.2.0", "py_find_1st", "python-rapidjson", "orjson",