From cab82e8e606a8052a2c13ef8ffa10ab6945f4e12 Mon Sep 17 00:00:00 2001 From: initrv Date: Sun, 2 Apr 2023 02:59:02 +0300 Subject: [PATCH 01/22] Add sb3 learn progress bar --- config_examples/config_freqai.example.json | 3 ++- docs/freqai-parameter-table.md | 1 + freqtrade/constants.py | 1 + freqtrade/freqai/prediction_models/ReinforcementLearner.py | 3 ++- requirements-freqai-rl.txt | 3 +++ 5 files changed, 9 insertions(+), 2 deletions(-) diff --git a/config_examples/config_freqai.example.json b/config_examples/config_freqai.example.json index 65a93379e..7878bd2c2 100644 --- a/config_examples/config_freqai.example.json +++ b/config_examples/config_freqai.example.json @@ -73,7 +73,8 @@ 10, 20 ], - "plot_feature_importances": 0 + "plot_feature_importances": 0, + "progress_bar": false }, "data_split_parameters": { "test_size": 0.33, diff --git a/docs/freqai-parameter-table.md b/docs/freqai-parameter-table.md index 9822a895a..fe265d483 100644 --- a/docs/freqai-parameter-table.md +++ b/docs/freqai-parameter-table.md @@ -85,6 +85,7 @@ Mandatory parameters are marked as **Required** and have to be set in one of the | `net_arch` | Network architecture which is well described in [`stable_baselines3` doc](https://stable-baselines3.readthedocs.io/en/master/guide/custom_policy.html#examples). In summary: `[, dict(vf=[], pi=[])]`. By default this is set to `[128, 128]`, which defines 2 shared hidden layers with 128 units each. | `randomize_starting_position` | Randomize the starting point of each episode to avoid overfitting.
**Datatype:** bool.
Default: `False`. | `drop_ohlc_from_features` | Do not include the normalized ohlc data in the feature set passed to the agent during training (ohlc will still be used for driving the environment in all cases)
**Datatype:** Boolean.
**Default:** `False` +| `progress_bar` | Display a progress bar with the current progress, elapsed time and estimated remaining time.
**Datatype:** Boolean.
Default: `False`. ### Additional parameters diff --git a/freqtrade/constants.py b/freqtrade/constants.py index ebb946221..00f072678 100644 --- a/freqtrade/constants.py +++ b/freqtrade/constants.py @@ -599,6 +599,7 @@ CONF_SCHEMA = { "policy_type": {"type": "string", "default": "MlpPolicy"}, "net_arch": {"type": "array", "default": [128, 128]}, "randomize_startinng_position": {"type": "boolean", "default": False}, + "progress_bar": {"type": "boolean", "default": False}, "model_reward_parameters": { "type": "object", "properties": { diff --git a/freqtrade/freqai/prediction_models/ReinforcementLearner.py b/freqtrade/freqai/prediction_models/ReinforcementLearner.py index e795703d4..a194c7290 100644 --- a/freqtrade/freqai/prediction_models/ReinforcementLearner.py +++ b/freqtrade/freqai/prediction_models/ReinforcementLearner.py @@ -71,7 +71,8 @@ class ReinforcementLearner(BaseReinforcementLearningModel): model.learn( total_timesteps=int(total_timesteps), - callback=[self.eval_callback, self.tensorboard_callback] + callback=[self.eval_callback, self.tensorboard_callback], + progress_bar=self.freqai_info["rl_config"]["progress_bar"] ) if Path(dk.data_path / "best_model.zip").is_file(): diff --git a/requirements-freqai-rl.txt b/requirements-freqai-rl.txt index 4de7d8fab..5d76b0600 100644 --- a/requirements-freqai-rl.txt +++ b/requirements-freqai-rl.txt @@ -8,3 +8,6 @@ sb3-contrib==1.7.0; python_version < '3.11' # Gym is forced to this version by stable-baselines3. setuptools==65.5.1 # Should be removed when gym is fixed. gym==0.21; python_version < '3.11' +# Progress bar for stable-baselines3 and sb3-contrib +tqdm==4.65.0; python_version < '3.11' +rich==13.3.3; python_version < '3.11' From 4c608e7167e0f7c349e92e5a844f5e3b9cb18ed0 Mon Sep 17 00:00:00 2001 From: initrv Date: Sun, 2 Apr 2023 03:12:24 +0300 Subject: [PATCH 02/22] remove misplaced param --- config_examples/config_freqai.example.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/config_examples/config_freqai.example.json b/config_examples/config_freqai.example.json index 7878bd2c2..65a93379e 100644 --- a/config_examples/config_freqai.example.json +++ b/config_examples/config_freqai.example.json @@ -73,8 +73,7 @@ 10, 20 ], - "plot_feature_importances": 0, - "progress_bar": false + "plot_feature_importances": 0 }, "data_split_parameters": { "test_size": 0.33, From cfc04103888e27f4f9f27936bb4b74ad98fc06ba Mon Sep 17 00:00:00 2001 From: initrv Date: Sun, 2 Apr 2023 04:08:07 +0300 Subject: [PATCH 03/22] use rl_config get instead of freqai_info --- freqtrade/freqai/prediction_models/ReinforcementLearner.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/freqtrade/freqai/prediction_models/ReinforcementLearner.py b/freqtrade/freqai/prediction_models/ReinforcementLearner.py index a194c7290..65990da87 100644 --- a/freqtrade/freqai/prediction_models/ReinforcementLearner.py +++ b/freqtrade/freqai/prediction_models/ReinforcementLearner.py @@ -72,7 +72,7 @@ class ReinforcementLearner(BaseReinforcementLearningModel): model.learn( total_timesteps=int(total_timesteps), callback=[self.eval_callback, self.tensorboard_callback], - progress_bar=self.freqai_info["rl_config"]["progress_bar"] + progress_bar=self.rl_config.get('progress_bar', False) ) if Path(dk.data_path / "best_model.zip").is_file(): From 6bc8759321b32e348268b7d36d9901428596abbe Mon Sep 17 00:00:00 2001 From: Robert Caulk Date: Sat, 15 Apr 2023 20:01:12 +0200 Subject: [PATCH 04/22] Update constants.py Make progress bar true by default --- freqtrade/constants.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/freqtrade/constants.py b/freqtrade/constants.py index 0da6a3b18..b8e240419 100644 --- a/freqtrade/constants.py +++ b/freqtrade/constants.py @@ -600,7 +600,7 @@ CONF_SCHEMA = { "policy_type": {"type": "string", "default": "MlpPolicy"}, "net_arch": {"type": "array", "default": [128, 128]}, "randomize_starting_position": {"type": "boolean", "default": False}, - "progress_bar": {"type": "boolean", "default": False}, + "progress_bar": {"type": "boolean", "default": True}, "model_reward_parameters": { "type": "object", "properties": { From dba21c815a50366cfc6fc4a792bb1ad6ac28069b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Apr 2023 03:56:47 +0000 Subject: [PATCH 05/22] Bump tensorboard from 2.12.1 to 2.12.2 Bumps [tensorboard](https://github.com/tensorflow/tensorboard) from 2.12.1 to 2.12.2. - [Release notes](https://github.com/tensorflow/tensorboard/releases) - [Changelog](https://github.com/tensorflow/tensorboard/blob/master/RELEASE.md) - [Commits](https://github.com/tensorflow/tensorboard/commits) --- updated-dependencies: - dependency-name: tensorboard dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- requirements-freqai.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-freqai.txt b/requirements-freqai.txt index 840598d23..51396ab91 100644 --- a/requirements-freqai.txt +++ b/requirements-freqai.txt @@ -8,4 +8,4 @@ joblib==1.2.0 catboost==1.1.1; platform_machine != 'aarch64' and 'arm' not in platform_machine and python_version < '3.11' lightgbm==3.3.5 xgboost==1.7.5 -tensorboard==2.12.1 +tensorboard==2.12.2 From f1730ab51bd8b89601c4a729893fbbf763583334 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Apr 2023 03:56:52 +0000 Subject: [PATCH 06/22] Bump httpx from 0.23.3 to 0.24.0 Bumps [httpx](https://github.com/encode/httpx) from 0.23.3 to 0.24.0. - [Release notes](https://github.com/encode/httpx/releases) - [Changelog](https://github.com/encode/httpx/blob/master/CHANGELOG.md) - [Commits](https://github.com/encode/httpx/compare/0.23.3...0.24.0) --- updated-dependencies: - dependency-name: httpx dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- requirements-dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index 690a7ee70..8c7738f64 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -19,7 +19,7 @@ isort==5.12.0 # For datetime mocking time-machine==2.9.0 # fastapi testing -httpx==0.23.3 +httpx==0.24.0 # Convert jupyter notebooks to markdown documents nbconvert==7.3.1 From f1fcd0760d08e9cbbdc72d6078572c6aebb43e72 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Apr 2023 03:57:07 +0000 Subject: [PATCH 07/22] Bump pytest from 7.3.0 to 7.3.1 Bumps [pytest](https://github.com/pytest-dev/pytest) from 7.3.0 to 7.3.1. - [Release notes](https://github.com/pytest-dev/pytest/releases) - [Changelog](https://github.com/pytest-dev/pytest/blob/main/CHANGELOG.rst) - [Commits](https://github.com/pytest-dev/pytest/compare/7.3.0...7.3.1) --- updated-dependencies: - dependency-name: pytest dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- requirements-dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index 690a7ee70..e90930b62 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -10,7 +10,7 @@ coveralls==3.3.1 ruff==0.0.261 mypy==1.2.0 pre-commit==3.2.2 -pytest==7.3.0 +pytest==7.3.1 pytest-asyncio==0.21.0 pytest-cov==4.0.0 pytest-mock==3.10.0 From 864f53bc4b06a87893a3e641b65d448a75730f07 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Apr 2023 03:57:23 +0000 Subject: [PATCH 08/22] Bump cryptography from 40.0.1 to 40.0.2 Bumps [cryptography](https://github.com/pyca/cryptography) from 40.0.1 to 40.0.2. - [Release notes](https://github.com/pyca/cryptography/releases) - [Changelog](https://github.com/pyca/cryptography/blob/main/CHANGELOG.rst) - [Commits](https://github.com/pyca/cryptography/compare/40.0.1...40.0.2) --- updated-dependencies: - dependency-name: cryptography dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index e09f8ba77..9e66e7f9d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,7 +3,7 @@ pandas==1.5.3 pandas-ta==0.3.14b ccxt==3.0.59 -cryptography==40.0.1 +cryptography==40.0.2 aiohttp==3.8.4 SQLAlchemy==2.0.9 python-telegram-bot==13.15 From 7c95848271d1b1cada8057a240d429aae7ec5064 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Apr 2023 03:57:33 +0000 Subject: [PATCH 09/22] Bump rich from 13.3.3 to 13.3.4 Bumps [rich](https://github.com/Textualize/rich) from 13.3.3 to 13.3.4. - [Release notes](https://github.com/Textualize/rich/releases) - [Changelog](https://github.com/Textualize/rich/blob/master/CHANGELOG.md) - [Commits](https://github.com/Textualize/rich/compare/v13.3.3...v13.3.4) --- updated-dependencies: - dependency-name: rich dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index e09f8ba77..620010234 100644 --- a/requirements.txt +++ b/requirements.txt @@ -20,7 +20,7 @@ jinja2==3.1.2 tables==3.8.0 blosc==1.11.1 joblib==1.2.0 -rich==13.3.3 +rich==13.3.4 pyarrow==11.0.0; platform_machine != 'armv7l' # find first, C search in arrays From d1b600e7b0c419d433c7b6bfc23aff4732cf9b12 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Apr 2023 04:29:10 +0000 Subject: [PATCH 10/22] Bump fastapi from 0.95.0 to 0.95.1 Bumps [fastapi](https://github.com/tiangolo/fastapi) from 0.95.0 to 0.95.1. - [Release notes](https://github.com/tiangolo/fastapi/releases) - [Commits](https://github.com/tiangolo/fastapi/compare/0.95.0...0.95.1) --- updated-dependencies: - dependency-name: fastapi dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index e09f8ba77..a0a6e760f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -35,7 +35,7 @@ orjson==3.8.10 sdnotify==0.3.2 # API Server -fastapi==0.95.0 +fastapi==0.95.1 pydantic==1.10.7 uvicorn==0.21.1 pyjwt==2.6.0 From 8a8cd6798810a14d179b94e05c3252d0c33277f1 Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 17 Apr 2023 07:12:03 +0200 Subject: [PATCH 11/22] Improve ccxt_ohlcv test debuggability --- tests/exchange/test_ccxt_compat.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/exchange/test_ccxt_compat.py b/tests/exchange/test_ccxt_compat.py index 4a65b16d7..34a4a1f0b 100644 --- a/tests/exchange/test_ccxt_compat.py +++ b/tests/exchange/test_ccxt_compat.py @@ -530,7 +530,8 @@ class TestCCXTExchange(): candles = res[3] candle_count = exchange.ohlcv_candle_limit(timeframe, candle_type, since_ms) * 0.9 candle_count1 = (now.timestamp() * 1000 - since_ms) // timeframe_ms - assert len(candles) >= min(candle_count, candle_count1) + assert len(candles) >= min(candle_count, candle_count1), \ + f"{len(candles)} < {candle_count} in {timeframe}, Offset: {offset} " assert candles[0][0] == since_ms or (since_ms + timeframe_ms) def test_ccxt__async_get_candle_history(self, exchange: EXCHANGE_FIXTURE_TYPE): From 6c6d2a0f43e445084bbfac7f48870bcbf5922d24 Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 17 Apr 2023 07:22:26 +0200 Subject: [PATCH 12/22] Improve live test resiliance --- tests/exchange/test_ccxt_compat.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/exchange/test_ccxt_compat.py b/tests/exchange/test_ccxt_compat.py index 34a4a1f0b..60855ca54 100644 --- a/tests/exchange/test_ccxt_compat.py +++ b/tests/exchange/test_ccxt_compat.py @@ -528,10 +528,11 @@ class TestCCXTExchange(): assert res[1] == timeframe assert res[2] == candle_type candles = res[3] - candle_count = exchange.ohlcv_candle_limit(timeframe, candle_type, since_ms) * 0.9 - candle_count1 = (now.timestamp() * 1000 - since_ms) // timeframe_ms + factor = 0.9 + candle_count = exchange.ohlcv_candle_limit(timeframe, candle_type, since_ms) * factor + candle_count1 = (now.timestamp() * 1000 - since_ms) // timeframe_ms * factor assert len(candles) >= min(candle_count, candle_count1), \ - f"{len(candles)} < {candle_count} in {timeframe}, Offset: {offset} " + f"{len(candles)} < {candle_count} in {timeframe}, Offset: {offset} {factor}" assert candles[0][0] == since_ms or (since_ms + timeframe_ms) def test_ccxt__async_get_candle_history(self, exchange: EXCHANGE_FIXTURE_TYPE): From 8aec71e27ef605f1cf06acb39c99523a3ff93317 Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 17 Apr 2023 07:25:09 +0200 Subject: [PATCH 13/22] Add bitvavo sublass to properly set ohlcv limit --- freqtrade/exchange/__init__.py | 1 + freqtrade/exchange/bitvavo.py | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 freqtrade/exchange/bitvavo.py diff --git a/freqtrade/exchange/__init__.py b/freqtrade/exchange/__init__.py index df10e40e5..8092d5af8 100644 --- a/freqtrade/exchange/__init__.py +++ b/freqtrade/exchange/__init__.py @@ -6,6 +6,7 @@ from freqtrade.exchange.exchange import Exchange from freqtrade.exchange.binance import Binance from freqtrade.exchange.bitpanda import Bitpanda from freqtrade.exchange.bittrex import Bittrex +from freqtrade.exchange.bitvavo import Bitvavo from freqtrade.exchange.bybit import Bybit from freqtrade.exchange.coinbasepro import Coinbasepro from freqtrade.exchange.exchange_utils import (ROUND_DOWN, ROUND_UP, amount_to_contract_precision, diff --git a/freqtrade/exchange/bitvavo.py b/freqtrade/exchange/bitvavo.py new file mode 100644 index 000000000..ba1d355cc --- /dev/null +++ b/freqtrade/exchange/bitvavo.py @@ -0,0 +1,23 @@ +"""Kucoin exchange subclass.""" +import logging +from typing import Dict + +from freqtrade.exchange import Exchange + + +logger = logging.getLogger(__name__) + + +class Bitvavo(Exchange): + """Bitvavo exchange class. + + Contains adjustments needed for Freqtrade to work with this exchange. + + Please note that this exchange is not included in the list of exchanges + officially supported by the Freqtrade development team. So some features + may still not work as expected. + """ + + _ft_has: Dict = { + "ohlcv_candle_limit": 1440, + } From d73e7f292a96fc0a6181ac9076174fc2bb8bda70 Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 17 Apr 2023 19:42:41 +0200 Subject: [PATCH 14/22] simplify Leverage tier code --- freqtrade/exchange/exchange.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/freqtrade/exchange/exchange.py b/freqtrade/exchange/exchange.py index ba7d79f97..b5ea247ef 100644 --- a/freqtrade/exchange/exchange.py +++ b/freqtrade/exchange/exchange.py @@ -2371,12 +2371,12 @@ class Exchange: # Must fetch the leverage tiers for each market separately # * This is slow(~45s) on Okx, makes ~90 api calls to load all linear swap markets markets = self.markets - symbols = [] - for symbol, market in markets.items(): + symbols = [ + symbol for symbol, market in markets.items() if (self.market_is_future(market) - and market['quote'] == self._config['stake_currency']): - symbols.append(symbol) + and market['quote'] == self._config['stake_currency']) + ] tiers: Dict[str, List[Dict]] = {} From b2ea464250c1030d0ef197c0922083a4e9cfd40a Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 17 Apr 2023 19:48:33 +0200 Subject: [PATCH 15/22] Handle individual exceptions when initializing leverage tiers closes #8515 closes #8512 closes #8514 --- freqtrade/exchange/exchange.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/freqtrade/exchange/exchange.py b/freqtrade/exchange/exchange.py index b5ea247ef..fd9ddfba6 100644 --- a/freqtrade/exchange/exchange.py +++ b/freqtrade/exchange/exchange.py @@ -2404,17 +2404,18 @@ class Exchange: with self._loop_lock: results = self.loop.run_until_complete(gather_results()) - for symbol, res in results: - tiers[symbol] = res + for res in results: + if isinstance(res, Exception): + logger.warning(f"Leverage tier exception: {repr(res)}") + continue + symbol, tier = res + tiers[symbol] = tier if len(coros) > 0: self.cache_leverage_tiers(tiers, self._config['stake_currency']) logger.info(f"Done initializing {len(symbols)} markets.") return tiers - else: - return {} - else: - return {} + return {} def cache_leverage_tiers(self, tiers: Dict[str, List[Dict]], stake_currency: str) -> None: From 14bca509da52131c5bed0215e128bd8f58da3b4d Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 17 Apr 2023 19:55:58 +0200 Subject: [PATCH 16/22] Cleanup some code --- freqtrade/exchange/exchange.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/freqtrade/exchange/exchange.py b/freqtrade/exchange/exchange.py index fd9ddfba6..358e71c85 100644 --- a/freqtrade/exchange/exchange.py +++ b/freqtrade/exchange/exchange.py @@ -2396,13 +2396,13 @@ class Exchange: else: logger.info("Using cached leverage_tiers.") - async def gather_results(): + async def gather_results(input_coro): return await asyncio.gather(*input_coro, return_exceptions=True) for input_coro in chunks(coros, 100): with self._loop_lock: - results = self.loop.run_until_complete(gather_results()) + results = self.loop.run_until_complete(gather_results(input_coro)) for res in results: if isinstance(res, Exception): From 362974b831b4e499f6f6523b87c306191522542e Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 17 Apr 2023 20:00:57 +0200 Subject: [PATCH 17/22] Update test to properly capture errors from leverage initialization --- tests/exchange/test_okx.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/exchange/test_okx.py b/tests/exchange/test_okx.py index 7a3fa22f0..3824eddb7 100644 --- a/tests/exchange/test_okx.py +++ b/tests/exchange/test_okx.py @@ -1,14 +1,14 @@ from datetime import datetime, timedelta, timezone from pathlib import Path -from unittest.mock import MagicMock, PropertyMock +from unittest.mock import AsyncMock, MagicMock, PropertyMock import ccxt import pytest from freqtrade.enums import CandleType, MarginMode, TradingMode -from freqtrade.exceptions import RetryableOrderError +from freqtrade.exceptions import RetryableOrderError, TemporaryError from freqtrade.exchange.exchange import timeframe_to_minutes -from tests.conftest import EXMS, get_mock_coro, get_patched_exchange, log_has +from tests.conftest import EXMS, get_patched_exchange, log_has from tests.exchange.test_exchange import ccxt_exceptionhandlers @@ -278,7 +278,7 @@ def test_load_leverage_tiers_okx(default_conf, mocker, markets, tmpdir, caplog, 'fetchLeverageTiers': False, 'fetchMarketLeverageTiers': True, }) - api_mock.fetch_market_leverage_tiers = get_mock_coro(side_effect=[ + api_mock.fetch_market_leverage_tiers = AsyncMock(side_effect=[ [ { 'tier': 1, @@ -341,6 +341,7 @@ def test_load_leverage_tiers_okx(default_conf, mocker, markets, tmpdir, caplog, } }, ], + TemporaryError("this Failed"), [ { 'tier': 1, From f049268354d1406c7f8bf205dd8f66b7ab016996 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Apr 2023 18:03:14 +0000 Subject: [PATCH 18/22] Bump ccxt from 3.0.59 to 3.0.69 Bumps [ccxt](https://github.com/ccxt/ccxt) from 3.0.59 to 3.0.69. - [Release notes](https://github.com/ccxt/ccxt/releases) - [Changelog](https://github.com/ccxt/ccxt/blob/master/CHANGELOG.md) - [Commits](https://github.com/ccxt/ccxt/compare/3.0.59...3.0.69) --- updated-dependencies: - dependency-name: ccxt dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 07ddde148..7db852961 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,7 @@ numpy==1.24.2 pandas==1.5.3 pandas-ta==0.3.14b -ccxt==3.0.59 +ccxt==3.0.69 cryptography==40.0.2 aiohttp==3.8.4 SQLAlchemy==2.0.9 From 7ff35fea3c297cb5643654345aeb293edfcb87f0 Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 17 Apr 2023 20:20:38 +0200 Subject: [PATCH 19/22] Default weekly report to monday closes #8502 --- freqtrade/optimize/optimize_reports.py | 3 ++- tests/optimize/test_optimize_reports.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/freqtrade/optimize/optimize_reports.py b/freqtrade/optimize/optimize_reports.py index b4925770d..cbae6aede 100644 --- a/freqtrade/optimize/optimize_reports.py +++ b/freqtrade/optimize/optimize_reports.py @@ -273,7 +273,8 @@ def _get_resample_from_period(period: str) -> str: if period == 'day': return '1d' if period == 'week': - return '1w' + # Weekly defaulting to Monday. + return '1W-MON' if period == 'month': return '1M' raise ValueError(f"Period {period} is not supported.") diff --git a/tests/optimize/test_optimize_reports.py b/tests/optimize/test_optimize_reports.py index 0cc32baaf..9fdd0d61e 100644 --- a/tests/optimize/test_optimize_reports.py +++ b/tests/optimize/test_optimize_reports.py @@ -465,7 +465,7 @@ def test_generate_periodic_breakdown_stats(testdatadir): def test__get_resample_from_period(): assert _get_resample_from_period('day') == '1d' - assert _get_resample_from_period('week') == '1w' + assert _get_resample_from_period('week') == '1W-MON' assert _get_resample_from_period('month') == '1M' with pytest.raises(ValueError, match=r"Period noooo is not supported."): _get_resample_from_period('noooo') From dfe8b3e832f348ab5fbff1ec85ba23ab57ca3984 Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 17 Apr 2023 20:32:07 +0200 Subject: [PATCH 20/22] Improve ruff rule selection --- pyproject.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index baf707c68..28de6a1d8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -68,6 +68,9 @@ target-version = "py38" extend-select = [ "C90", # mccabe # "N", # pep8-naming + "F", # pyflakes + "E", # pycodestyle + "W", # pycodestyle "UP", # pyupgrade "TID", # flake8-tidy-imports # "EXE", # flake8-executable From caf524c68584995e5ef6e4d2ba165ca4279e264f Mon Sep 17 00:00:00 2001 From: Matthias Date: Tue, 18 Apr 2023 18:01:12 +0200 Subject: [PATCH 21/22] Don't fail on leverage tier loading error closes #8512 --- freqtrade/exchange/exchange.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/freqtrade/exchange/exchange.py b/freqtrade/exchange/exchange.py index 358e71c85..7e276d538 100644 --- a/freqtrade/exchange/exchange.py +++ b/freqtrade/exchange/exchange.py @@ -2431,14 +2431,17 @@ class Exchange: def load_cached_leverage_tiers(self, stake_currency: str) -> Optional[Dict[str, List[Dict]]]: filename = self._config['datadir'] / "futures" / f"leverage_tiers_{stake_currency}.json" if filename.is_file(): - tiers = file_load_json(filename) - updated = tiers.get('updated') - if updated: - updated_dt = parser.parse(updated) - if updated_dt < datetime.now(timezone.utc) - timedelta(weeks=4): - logger.info("Cached leverage tiers are outdated. Will update.") - return None - return tiers['data'] + try: + tiers = file_load_json(filename) + updated = tiers.get('updated') + if updated: + updated_dt = parser.parse(updated) + if updated_dt < datetime.now(timezone.utc) - timedelta(weeks=4): + logger.info("Cached leverage tiers are outdated. Will update.") + return None + return tiers['data'] + except Exception: + logger.exception("Error loading cached leverage tiers. Refreshing.") return None def fill_leverage_tiers(self) -> None: From f1e03a68739fd62d36eb7f893ef6b1e233f7dc64 Mon Sep 17 00:00:00 2001 From: Matthias Date: Wed, 19 Apr 2023 18:20:25 +0200 Subject: [PATCH 22/22] Update variable to better reflect it's content --- freqtrade/rpc/api_server/api_v1.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/freqtrade/rpc/api_server/api_v1.py b/freqtrade/rpc/api_server/api_v1.py index 8ea70bb69..8aa706e62 100644 --- a/freqtrade/rpc/api_server/api_v1.py +++ b/freqtrade/rpc/api_server/api_v1.py @@ -303,11 +303,11 @@ def get_strategy(strategy: str, config=Depends(get_config)): @router.get('/freqaimodels', response_model=FreqAIModelListResponse, tags=['freqai']) def list_freqaimodels(config=Depends(get_config)): from freqtrade.resolvers.freqaimodel_resolver import FreqaiModelResolver - strategies = FreqaiModelResolver.search_all_objects( + models = FreqaiModelResolver.search_all_objects( config, False) - strategies = sorted(strategies, key=lambda x: x['name']) + models = sorted(models, key=lambda x: x['name']) - return {'freqaimodels': [x['name'] for x in strategies]} + return {'freqaimodels': [x['name'] for x in models]} @router.get('/available_pairs', response_model=AvailablePairs, tags=['candle data'])