From 12b471c64b7d87a888224ad9de034e604b10fd4f Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 20 Nov 2022 09:28:14 +0100 Subject: [PATCH 01/15] Prevent 2 parallel open orders through forceentry this leads to forgetting the prior order closes #7765 --- freqtrade/rpc/rpc.py | 3 +++ tests/rpc/test_rpc.py | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/freqtrade/rpc/rpc.py b/freqtrade/rpc/rpc.py index a0824bcc1..1d3f36844 100644 --- a/freqtrade/rpc/rpc.py +++ b/freqtrade/rpc/rpc.py @@ -774,6 +774,9 @@ class RPC: is_short = trade.is_short if not self._freqtrade.strategy.position_adjustment_enable: raise RPCException(f'position for {pair} already open - id: {trade.id}') + if trade.open_order_id is not None: + raise RPCException(f'position for {pair} already open - id: {trade.id} ' + f'and has open order {trade.open_order_id}') else: if Trade.get_open_trade_count() >= self._config['max_open_trades']: raise RPCException("Maximum number of trades is reached.") diff --git a/tests/rpc/test_rpc.py b/tests/rpc/test_rpc.py index ef6c8b204..8828b6f33 100644 --- a/tests/rpc/test_rpc.py +++ b/tests/rpc/test_rpc.py @@ -1066,6 +1066,11 @@ def test_rpc_force_entry(mocker, default_conf, ticker, fee, limit_buy_order_open trade = rpc._rpc_force_entry(pair, 0.0001, order_type='limit', stake_amount=0.05) assert trade.stake_amount == 0.05 assert trade.buy_tag == 'force_entry' + assert trade.open_order_id == 'mocked_limit_buy' + + freqtradebot.strategy.position_adjustment_enable = True + with pytest.raises(RPCException, match=r'position for LTC/BTC already open.*open order.*'): + rpc._rpc_force_entry(pair, 0.0001, order_type='limit', stake_amount=0.05) # Test not buying pair = 'XRP/BTC' From 0cb08024f1ef8e53ac3b10f2ae2fe53fa3e20219 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Nov 2022 03:01:59 +0000 Subject: [PATCH 02/15] Bump numpy from 1.23.4 to 1.23.5 Bumps [numpy](https://github.com/numpy/numpy) from 1.23.4 to 1.23.5. - [Release notes](https://github.com/numpy/numpy/releases) - [Changelog](https://github.com/numpy/numpy/blob/main/doc/RELEASE_WALKTHROUGH.rst) - [Commits](https://github.com/numpy/numpy/compare/v1.23.4...v1.23.5) --- updated-dependencies: - dependency-name: numpy 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 ec8b5ce7c..7827a7be6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -numpy==1.23.4 +numpy==1.23.5 pandas==1.5.1 pandas-ta==0.3.14b From 5cce8f4f2d07fdcf2e1e46cbd723b3fbec5a75f5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Nov 2022 03:02:00 +0000 Subject: [PATCH 03/15] Bump types-python-dateutil from 2.8.19.3 to 2.8.19.4 Bumps [types-python-dateutil](https://github.com/python/typeshed) from 2.8.19.3 to 2.8.19.4. - [Release notes](https://github.com/python/typeshed/releases) - [Commits](https://github.com/python/typeshed/commits) --- updated-dependencies: - dependency-name: types-python-dateutil 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 6e4d42538..ee4a22387 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -29,4 +29,4 @@ types-cachetools==5.2.1 types-filelock==3.2.7 types-requests==2.28.11.4 types-tabulate==0.9.0.0 -types-python-dateutil==2.8.19.3 +types-python-dateutil==2.8.19.4 From 3f9dacc9bef4881ecc66a44d3fe73f346db1e6f2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Nov 2022 03:02:15 +0000 Subject: [PATCH 04/15] Bump ccxt from 2.1.75 to 2.1.96 Bumps [ccxt](https://github.com/ccxt/ccxt) from 2.1.75 to 2.1.96. - [Release notes](https://github.com/ccxt/ccxt/releases) - [Changelog](https://github.com/ccxt/ccxt/blob/master/exchanges.cfg) - [Commits](https://github.com/ccxt/ccxt/compare/2.1.75...2.1.96) --- 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 ec8b5ce7c..fa4767a43 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,7 @@ numpy==1.23.4 pandas==1.5.1 pandas-ta==0.3.14b -ccxt==2.1.75 +ccxt==2.1.96 # Pin cryptography for now due to rust build errors with piwheels cryptography==38.0.1; platform_machine == 'armv7l' cryptography==38.0.3; platform_machine != 'armv7l' From ec15ef039845569dc000da052030b7764e549259 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Nov 2022 03:02:26 +0000 Subject: [PATCH 05/15] Bump nbconvert from 7.2.4 to 7.2.5 Bumps [nbconvert](https://github.com/jupyter/nbconvert) from 7.2.4 to 7.2.5. - [Release notes](https://github.com/jupyter/nbconvert/releases) - [Changelog](https://github.com/jupyter/nbconvert/blob/main/CHANGELOG.md) - [Commits](https://github.com/jupyter/nbconvert/compare/v7.2.4...v7.2.5) --- updated-dependencies: - dependency-name: nbconvert 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 6e4d42538..da5719dfd 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -22,7 +22,7 @@ time-machine==2.8.2 httpx==0.23.0 # Convert jupyter notebooks to markdown documents -nbconvert==7.2.4 +nbconvert==7.2.5 # mypy types types-cachetools==5.2.1 From 844334a7ea9a05544faac65480658dc7d67a2074 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Nov 2022 03:02:34 +0000 Subject: [PATCH 06/15] Bump uvicorn from 0.19.0 to 0.20.0 Bumps [uvicorn](https://github.com/encode/uvicorn) from 0.19.0 to 0.20.0. - [Release notes](https://github.com/encode/uvicorn/releases) - [Changelog](https://github.com/encode/uvicorn/blob/master/CHANGELOG.md) - [Commits](https://github.com/encode/uvicorn/compare/0.19.0...0.20.0) --- updated-dependencies: - dependency-name: uvicorn 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 ec8b5ce7c..036ca6335 100644 --- a/requirements.txt +++ b/requirements.txt @@ -38,7 +38,7 @@ sdnotify==0.3.2 # API Server fastapi==0.87.0 pydantic==1.10.2 -uvicorn==0.19.0 +uvicorn==0.20.0 pyjwt==2.6.0 aiofiles==22.1.0 psutil==5.9.4 From 8d1ee67ed438c08a418fc73e8b771ebf4e6d2f7f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Nov 2022 03:02:38 +0000 Subject: [PATCH 07/15] Bump httpx from 0.23.0 to 0.23.1 Bumps [httpx](https://github.com/encode/httpx) from 0.23.0 to 0.23.1. - [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.0...0.23.1) --- updated-dependencies: - dependency-name: httpx 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 6e4d42538..ec31df57c 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -19,7 +19,7 @@ isort==5.10.1 # For datetime mocking time-machine==2.8.2 # fastapi testing -httpx==0.23.0 +httpx==0.23.1 # Convert jupyter notebooks to markdown documents nbconvert==7.2.4 From f09fb2374b4378c6e4b00bb26e7e07e62d2ce613 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Nov 2022 03:02:47 +0000 Subject: [PATCH 08/15] Bump orjson from 3.8.1 to 3.8.2 Bumps [orjson](https://github.com/ijl/orjson) from 3.8.1 to 3.8.2. - [Release notes](https://github.com/ijl/orjson/releases) - [Changelog](https://github.com/ijl/orjson/blob/master/CHANGELOG.md) - [Commits](https://github.com/ijl/orjson/compare/3.8.1...3.8.2) --- updated-dependencies: - dependency-name: orjson 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 ec8b5ce7c..03945c1bd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -30,7 +30,7 @@ py_find_1st==1.1.5 # Load ticker files 30% faster python-rapidjson==1.9 # Properly format api responses -orjson==3.8.1 +orjson==3.8.2 # Notify systemd sdnotify==0.3.2 From beec9e2d1ad6956b88949dffdef4abcbd0689a6d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Nov 2022 05:36:52 +0000 Subject: [PATCH 09/15] Bump mypy from 0.990 to 0.991 Bumps [mypy](https://github.com/python/mypy) from 0.990 to 0.991. - [Release notes](https://github.com/python/mypy/releases) - [Commits](https://github.com/python/mypy/compare/v0.990...v0.991) --- updated-dependencies: - dependency-name: mypy 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 17fd99a0f..1eab3aa77 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -8,7 +8,7 @@ coveralls==3.3.1 flake8==5.0.4 flake8-tidy-imports==4.8.0 -mypy==0.990 +mypy==0.991 pre-commit==2.20.0 pytest==7.2.0 pytest-asyncio==0.20.2 From 2df0d613daed590ef0c9ab756646014518851c12 Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 21 Nov 2022 06:58:59 +0100 Subject: [PATCH 10/15] Bump types-dateutil for precommit --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b4a8336b9..ac5f47b00 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,7 +17,7 @@ repos: - types-filelock==3.2.7 - types-requests==2.28.11.4 - types-tabulate==0.9.0.0 - - types-python-dateutil==2.8.19.3 + - types-python-dateutil==2.8.19.4 # stages: [push] - repo: https://github.com/pycqa/isort From adc1174d2ee7ca2751bfc0b108d9dbb2679a0832 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Nov 2022 10:30:22 +0000 Subject: [PATCH 11/15] Bump types-requests from 2.28.11.4 to 2.28.11.5 Bumps [types-requests](https://github.com/python/typeshed) from 2.28.11.4 to 2.28.11.5. - [Release notes](https://github.com/python/typeshed/releases) - [Commits](https://github.com/python/typeshed/commits) --- updated-dependencies: - dependency-name: types-requests 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 1e1b755e7..ca76e5aee 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -27,6 +27,6 @@ nbconvert==7.2.5 # mypy types types-cachetools==5.2.1 types-filelock==3.2.7 -types-requests==2.28.11.4 +types-requests==2.28.11.5 types-tabulate==0.9.0.0 types-python-dateutil==2.8.19.4 From 7c00ef8a7619a59a6c1f49cc87e181417f309499 Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 21 Nov 2022 11:32:31 +0100 Subject: [PATCH 12/15] Bump pre-commit requests version --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ac5f47b00..ccf9d5098 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,7 +15,7 @@ repos: additional_dependencies: - types-cachetools==5.2.1 - types-filelock==3.2.7 - - types-requests==2.28.11.4 + - types-requests==2.28.11.5 - types-tabulate==0.9.0.0 - types-python-dateutil==2.8.19.4 # stages: [push] From 0fa521704381748fee5bd953573ca3d34fbb8e0b Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 21 Nov 2022 19:30:49 +0100 Subject: [PATCH 13/15] Improve protection setup lock_pair should be called when the order closes, not when the exit order is placed. it should also be called for stoploss orders, too. closes #7783 --- freqtrade/freqtradebot.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index 2e2638126..77b099d80 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -1133,10 +1133,8 @@ class FreqtradeBot(LoggingMixin): trade.exit_reason = ExitType.STOPLOSS_ON_EXCHANGE.value self.update_trade_state(trade, trade.stoploss_order_id, stoploss_order, stoploss_order=True) - # Lock pair for one candle to prevent immediate rebuys - self.strategy.lock_pair(trade.pair, datetime.now(timezone.utc), - reason='Auto lock') self._notify_exit(trade, "stoploss", True) + self.handle_protections(trade.pair, trade.trade_direction) return True if trade.open_order_id or not trade.is_open: @@ -1595,11 +1593,6 @@ class FreqtradeBot(LoggingMixin): trade.close_rate_requested = limit trade.exit_reason = exit_reason - if not sub_trade_amt: - # Lock pair for one candle to prevent immediate re-trading - self.strategy.lock_pair(trade.pair, datetime.now(timezone.utc), - reason='Auto lock') - self._notify_exit(trade, order_type, sub_trade=bool(sub_trade_amt), order=order_obj) # In case of market sell orders the order can be closed immediately if order.get('status', 'unknown') in ('closed', 'expired'): @@ -1809,6 +1802,8 @@ class FreqtradeBot(LoggingMixin): self._notify_enter(trade, order, fill=True, sub_trade=sub_trade) def handle_protections(self, pair: str, side: LongShort) -> None: + # Lock pair for one candle to prevent immediate rebuys + self.strategy.lock_pair(pair, datetime.now(timezone.utc), reason='Auto lock') prot_trig = self.protections.stop_per_pair(pair, side=side) if prot_trig: msg = {'type': RPCMessageType.PROTECTION_TRIGGER, } From 8cb2b4666d229a41320cf959c3eb6b10cf600d75 Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 21 Nov 2022 20:42:07 +0100 Subject: [PATCH 14/15] Improve proxy docs closes #7769 --- docs/configuration.md | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/docs/configuration.md b/docs/configuration.md index ce4453561..98ac7c124 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -665,6 +665,7 @@ You should also make sure to read the [Exchanges](exchanges.md) section of the d ### Using proxy with Freqtrade To use a proxy with freqtrade, export your proxy settings using the variables `"HTTP_PROXY"` and `"HTTPS_PROXY"` set to the appropriate values. +This will have the proxy settings applied to everything (telegram, coingecko, ...) except exchange requests. ``` bash export HTTP_PROXY="http://addr:port" @@ -672,17 +673,20 @@ export HTTPS_PROXY="http://addr:port" freqtrade ``` -#### Proxy just exchange requests +#### Proxy exchange requests -To use a proxy just for exchange connections (skips/ignores telegram and coingecko) - you can also define the proxies as part of the ccxt configuration. +To use a proxy for exchange connections - you can will have to define the proxies as part of the ccxt configuration. ``` json -"ccxt_config": { +{ + "exchange": { + "ccxt_config": { "aiohttp_proxy": "http://addr:port", "proxies": { - "http": "http://addr:port", - "https": "http://addr:port" + "http": "http://addr:port", + "https": "http://addr:port" }, + } } ``` From 5a489ce71b58515d61653fd1f25e1d4f034204ce Mon Sep 17 00:00:00 2001 From: Matthias Date: Tue, 22 Nov 2022 10:46:38 +0100 Subject: [PATCH 15/15] Fix docs typo --- docs/configuration.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/configuration.md b/docs/configuration.md index 98ac7c124..83b23425c 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -675,7 +675,7 @@ freqtrade #### Proxy exchange requests -To use a proxy for exchange connections - you can will have to define the proxies as part of the ccxt configuration. +To use a proxy for exchange connections - you will have to define the proxies as part of the ccxt configuration. ``` json {