From be4bc4955c2ffb4e72e603bb92fb62123a8767e2 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 5 Mar 2022 14:11:21 +0100 Subject: [PATCH 01/16] Explicitly check for None to determine if initial stoploss was set closes #6460 --- freqtrade/constants.py | 2 +- freqtrade/persistence/models.py | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/freqtrade/constants.py b/freqtrade/constants.py index 066a07c62..200917d43 100644 --- a/freqtrade/constants.py +++ b/freqtrade/constants.py @@ -140,7 +140,7 @@ CONF_SCHEMA = { 'minProperties': 1 }, 'amount_reserve_percent': {'type': 'number', 'minimum': 0.0, 'maximum': 0.5}, - 'stoploss': {'type': 'number', 'maximum': 0, 'exclusiveMaximum': True}, + 'stoploss': {'type': 'number', 'maximum': 0, 'exclusiveMaximum': True, 'minimum': -1}, 'trailing_stop': {'type': 'boolean'}, 'trailing_stop_positive': {'type': 'number', 'minimum': 0, 'maximum': 1}, 'trailing_stop_positive_offset': {'type': 'number', 'minimum': 0, 'maximum': 1}, diff --git a/freqtrade/persistence/models.py b/freqtrade/persistence/models.py index af093a1eb..92d1def30 100644 --- a/freqtrade/persistence/models.py +++ b/freqtrade/persistence/models.py @@ -304,7 +304,7 @@ class LocalTrade(): # absolute value of the initial stop loss initial_stop_loss: float = 0.0 # percentage value of the initial stop loss - initial_stop_loss_pct: float = 0.0 + initial_stop_loss_pct: Optional[float] = None # stoploss order id which is on exchange stoploss_order_id: Optional[str] = None # last update time of the stoploss order on exchange @@ -446,7 +446,8 @@ class LocalTrade(): new_loss = float(current_price * (1 - abs(stoploss))) # no stop loss assigned yet - if not self.stop_loss: + # if not self.stop_loss: + if self.initial_stop_loss_pct is None: logger.debug(f"{self.pair} - Assigning new stoploss...") self._set_new_stoploss(new_loss, stoploss) self.initial_stop_loss = new_loss @@ -786,6 +787,7 @@ class LocalTrade(): logger.info(f"Stoploss for {trade} needs adjustment...") # Force reset of stoploss trade.stop_loss = None + trade.initial_stop_loss_pct = None trade.adjust_stop_loss(trade.open_rate, desired_stoploss) logger.info(f"New stoploss: {trade.stop_loss}.") From d74e3091de415cf7ee7722b7afe14968feab1cec Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Mar 2022 03:01:09 +0000 Subject: [PATCH 02/16] Bump fastapi from 0.74.1 to 0.75.0 Bumps [fastapi](https://github.com/tiangolo/fastapi) from 0.74.1 to 0.75.0. - [Release notes](https://github.com/tiangolo/fastapi/releases) - [Commits](https://github.com/tiangolo/fastapi/compare/0.74.1...0.75.0) --- updated-dependencies: - dependency-name: fastapi 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 bcdcb02a9..2be9bfe21 100644 --- a/requirements.txt +++ b/requirements.txt @@ -31,7 +31,7 @@ python-rapidjson==1.6 sdnotify==0.3.2 # API Server -fastapi==0.74.1 +fastapi==0.75.0 uvicorn==0.17.5 pyjwt==2.3.0 aiofiles==0.8.0 From 708def3d96289c33b297c1b083b2aead3dbc4e37 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Mar 2022 03:01:15 +0000 Subject: [PATCH 03/16] Bump sqlalchemy from 1.4.31 to 1.4.32 Bumps [sqlalchemy](https://github.com/sqlalchemy/sqlalchemy) from 1.4.31 to 1.4.32. - [Release notes](https://github.com/sqlalchemy/sqlalchemy/releases) - [Changelog](https://github.com/sqlalchemy/sqlalchemy/blob/main/CHANGES) - [Commits](https://github.com/sqlalchemy/sqlalchemy/commits) --- updated-dependencies: - dependency-name: sqlalchemy 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 bcdcb02a9..875a3e885 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,7 +6,7 @@ ccxt==1.74.63 # Pin cryptography for now due to rust build errors with piwheels cryptography==36.0.1 aiohttp==3.8.1 -SQLAlchemy==1.4.31 +SQLAlchemy==1.4.32 python-telegram-bot==13.11 arrow==1.2.2 cachetools==4.2.2 From 67a8b8b6317eea1512dda812134736f5e9bfdfc5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Mar 2022 03:01:19 +0000 Subject: [PATCH 04/16] Bump pytest-asyncio from 0.18.1 to 0.18.2 Bumps [pytest-asyncio](https://github.com/pytest-dev/pytest-asyncio) from 0.18.1 to 0.18.2. - [Release notes](https://github.com/pytest-dev/pytest-asyncio/releases) - [Commits](https://github.com/pytest-dev/pytest-asyncio/compare/v0.18.1...v0.18.2) --- updated-dependencies: - dependency-name: pytest-asyncio 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 9fc8a18ad..f81844d26 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -8,7 +8,7 @@ flake8==4.0.1 flake8-tidy-imports==4.6.0 mypy==0.931 pytest==7.0.1 -pytest-asyncio==0.18.1 +pytest-asyncio==0.18.2 pytest-cov==3.0.0 pytest-mock==3.7.0 pytest-random-order==1.0.4 From 1d63bb66a98332a006af255dfe2a2c51d59d9fe2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Mar 2022 03:01:23 +0000 Subject: [PATCH 05/16] Bump mkdocs-material from 8.2.3 to 8.2.5 Bumps [mkdocs-material](https://github.com/squidfunk/mkdocs-material) from 8.2.3 to 8.2.5. - [Release notes](https://github.com/squidfunk/mkdocs-material/releases) - [Changelog](https://github.com/squidfunk/mkdocs-material/blob/master/CHANGELOG) - [Commits](https://github.com/squidfunk/mkdocs-material/compare/8.2.3...8.2.5) --- updated-dependencies: - dependency-name: mkdocs-material dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- docs/requirements-docs.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/requirements-docs.txt b/docs/requirements-docs.txt index 839485629..0ca0e4b63 100644 --- a/docs/requirements-docs.txt +++ b/docs/requirements-docs.txt @@ -1,4 +1,4 @@ mkdocs==1.2.3 -mkdocs-material==8.2.3 +mkdocs-material==8.2.5 mdx_truly_sane_lists==1.2 pymdown-extensions==9.2 From f1d2cb9ce42f2ae8c1b8d62c7092ffbffa4c832e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Mar 2022 03:01:25 +0000 Subject: [PATCH 06/16] Bump types-cachetools from 4.2.9 to 4.2.10 Bumps [types-cachetools](https://github.com/python/typeshed) from 4.2.9 to 4.2.10. - [Release notes](https://github.com/python/typeshed/releases) - [Commits](https://github.com/python/typeshed/commits) --- updated-dependencies: - dependency-name: types-cachetools 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 9fc8a18ad..1e50be196 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -20,7 +20,7 @@ time-machine==2.6.0 nbconvert==6.4.2 # mypy types -types-cachetools==4.2.9 +types-cachetools==4.2.10 types-filelock==3.2.5 types-requests==2.27.11 types-tabulate==0.8.5 From 0c8dd7e50233110b414dc5afac8e6ca87d16a15f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Mar 2022 03:01:33 +0000 Subject: [PATCH 07/16] Bump ccxt from 1.74.63 to 1.75.12 Bumps [ccxt](https://github.com/ccxt/ccxt) from 1.74.63 to 1.75.12. - [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/1.74.63...1.75.12) --- updated-dependencies: - dependency-name: ccxt 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 bcdcb02a9..769b0de4a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,7 @@ numpy==1.22.2 pandas==1.4.1 pandas-ta==0.3.14b -ccxt==1.74.63 +ccxt==1.75.12 # Pin cryptography for now due to rust build errors with piwheels cryptography==36.0.1 aiohttp==3.8.1 From 25964f70d8dd560852905c04e406e1c45455f86a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Mar 2022 03:12:15 +0000 Subject: [PATCH 08/16] Bump actions/checkout from 2 to 3 Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 3. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v2...v3) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/ci.yml | 12 ++++++------ .github/workflows/docker_update_readme.yml | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 407894bd2..6b576bd5d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,7 +23,7 @@ jobs: python-version: ["3.8", "3.9", "3.10"] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up Python uses: actions/setup-python@v2 @@ -118,7 +118,7 @@ jobs: python-version: ["3.8", "3.9", "3.10"] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up Python uses: actions/setup-python@v2 @@ -210,7 +210,7 @@ jobs: python-version: ["3.8", "3.9", "3.10"] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up Python uses: actions/setup-python@v2 @@ -262,7 +262,7 @@ jobs: docs_check: runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Documentation syntax run: | @@ -325,7 +325,7 @@ jobs: if: (github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'release') && github.repository == 'freqtrade/freqtrade' steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up Python uses: actions/setup-python@v2 @@ -405,7 +405,7 @@ jobs: if: (github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'release') && github.repository == 'freqtrade/freqtrade' steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Extract branch name shell: bash diff --git a/.github/workflows/docker_update_readme.yml b/.github/workflows/docker_update_readme.yml index 95a6e82e2..ebb773ad7 100644 --- a/.github/workflows/docker_update_readme.yml +++ b/.github/workflows/docker_update_readme.yml @@ -8,7 +8,7 @@ jobs: dockerHubDescription: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v3 - name: Docker Hub Description uses: peter-evans/dockerhub-description@v2.4.3 env: From 3c83d8c74a8078dc0779614318454f63597e4fe9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Mar 2022 05:24:08 +0000 Subject: [PATCH 09/16] Bump actions/setup-python from 2 to 3 Bumps [actions/setup-python](https://github.com/actions/setup-python) from 2 to 3. - [Release notes](https://github.com/actions/setup-python/releases) - [Commits](https://github.com/actions/setup-python/compare/v2...v3) --- updated-dependencies: - dependency-name: actions/setup-python dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/ci.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6b576bd5d..216a53bc1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,7 +26,7 @@ jobs: - uses: actions/checkout@v3 - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v3 with: python-version: ${{ matrix.python-version }} @@ -121,7 +121,7 @@ jobs: - uses: actions/checkout@v3 - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v3 with: python-version: ${{ matrix.python-version }} @@ -213,7 +213,7 @@ jobs: - uses: actions/checkout@v3 - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v3 with: python-version: ${{ matrix.python-version }} @@ -269,7 +269,7 @@ jobs: ./tests/test_docs.sh - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v3 with: python-version: 3.8 @@ -328,7 +328,7 @@ jobs: - uses: actions/checkout@v3 - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v3 with: python-version: 3.8 From 17041b78fc1ba574fcd9de865e25e5658c23e298 Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 7 Mar 2022 19:39:15 +0100 Subject: [PATCH 10/16] Add stoploss-limit-ratio to full config sample --- config_examples/config_full.example.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config_examples/config_full.example.json b/config_examples/config_full.example.json index d675fb1a9..7931476b4 100644 --- a/config_examples/config_full.example.json +++ b/config_examples/config_full.example.json @@ -56,7 +56,8 @@ "forcebuy": "market", "stoploss": "market", "stoploss_on_exchange": false, - "stoploss_on_exchange_interval": 60 + "stoploss_on_exchange_interval": 60, + "stoploss_on_exchange_limit_ratio": 0.99 }, "order_time_in_force": { "buy": "gtc", From f2ed6165e936fc2b44c4fb5d24bc0b62ae774ea3 Mon Sep 17 00:00:00 2001 From: Matthias Date: Tue, 8 Mar 2022 19:35:30 +0100 Subject: [PATCH 11/16] convert price to precision price before verifying stoploss adjustment closes #6504 --- freqtrade/freqtradebot.py | 4 +++- tests/test_freqtradebot.py | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index 207bfbc12..ac6ad65de 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -907,7 +907,9 @@ class FreqtradeBot(LoggingMixin): :param order: Current on exchange stoploss order :return: None """ - if self.exchange.stoploss_adjust(trade.stop_loss, order): + stoploss_norm = self.exchange.price_to_precision(trade.pair, trade.stop_loss) + + if self.exchange.stoploss_adjust(stoploss_norm, order): # we check if the update is necessary update_beat = self.strategy.order_types.get('stoploss_on_exchange_interval', 60) if (datetime.utcnow() - trade.stoploss_last_update).total_seconds() >= update_beat: diff --git a/tests/test_freqtradebot.py b/tests/test_freqtradebot.py index 7ed1a68f8..e5f8d3694 100644 --- a/tests/test_freqtradebot.py +++ b/tests/test_freqtradebot.py @@ -1360,6 +1360,32 @@ def test_handle_stoploss_on_exchange_trailing_error( assert log_has_re(r"Could not create trailing stoploss order for pair ETH/USDT\..*", caplog) +def test_stoploss_on_exchange_price_rounding( + mocker, default_conf_usdt, fee, open_trade_usdt) -> None: + patch_RPCManager(mocker) + mocker.patch.multiple( + 'freqtrade.exchange.Exchange', + get_fee=fee, + ) + price_mock = MagicMock(side_effect=lambda p, s: int(s)) + stoploss_mock = MagicMock(return_value={'id': '13434334'}) + adjust_mock = MagicMock(return_value=False) + mocker.patch.multiple( + 'freqtrade.exchange.Binance', + stoploss=stoploss_mock, + stoploss_adjust=adjust_mock, + price_to_precision=price_mock, + ) + freqtrade = get_patched_freqtradebot(mocker, default_conf_usdt) + open_trade_usdt.stoploss_order_id = '13434334' + open_trade_usdt.stop_loss = 222.55 + + freqtrade.handle_trailing_stoploss_on_exchange(open_trade_usdt, {}) + assert price_mock.call_count == 1 + assert adjust_mock.call_count == 1 + assert adjust_mock.call_args_list[0][0][0] == 222 + + @pytest.mark.usefixtures("init_persistence") def test_handle_stoploss_on_exchange_custom_stop( mocker, default_conf_usdt, fee, limit_buy_order_usdt, limit_sell_order_usdt) -> None: From 6e10439f908a11a41501b3dad216f1ad8e90b80a Mon Sep 17 00:00:00 2001 From: Matthias Date: Wed, 9 Mar 2022 17:35:41 +0100 Subject: [PATCH 12/16] Map usdt fiat to correct coingecko fiat --- freqtrade/rpc/fiat_convert.py | 1 + 1 file changed, 1 insertion(+) diff --git a/freqtrade/rpc/fiat_convert.py b/freqtrade/rpc/fiat_convert.py index 82a6a4778..70f3647b6 100644 --- a/freqtrade/rpc/fiat_convert.py +++ b/freqtrade/rpc/fiat_convert.py @@ -23,6 +23,7 @@ coingecko_mapping = { 'eth': 'ethereum', 'bnb': 'binancecoin', 'sol': 'solana', + 'usdt': 'tether', } From a837571e2bbdca7afcfcf33be94d4d6ba14f49f5 Mon Sep 17 00:00:00 2001 From: Matthias Date: Wed, 9 Mar 2022 19:01:38 +0100 Subject: [PATCH 13/16] Improve dry-run-wallets in futures case test --- tests/test_wallets.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/test_wallets.py b/tests/test_wallets.py index e7b804a0b..73a34bbae 100644 --- a/tests/test_wallets.py +++ b/tests/test_wallets.py @@ -356,3 +356,9 @@ def test_sync_wallet_futures_dry(mocker, default_conf, fee): positions['ETC/BTC'].side == 'long' positions['XRP/BTC'].side == 'long' positions['LTC/BTC'].side == 'short' + + assert freqtrade.wallets.get_starting_balance() == default_conf['dry_run_wallet'] + total = freqtrade.wallets.get_total('BTC') + free = freqtrade.wallets.get_free('BTC') + used = freqtrade.wallets.get_used('BTC') + assert free + used == total From 0d754111e994342934f53911d614a3a038a82f8b Mon Sep 17 00:00:00 2001 From: Matthias Date: Wed, 9 Mar 2022 19:02:22 +0100 Subject: [PATCH 14/16] Fix dry-run-wallets bug in case of futures --- freqtrade/wallets.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/freqtrade/wallets.py b/freqtrade/wallets.py index 7a46f0397..d93689a0e 100644 --- a/freqtrade/wallets.py +++ b/freqtrade/wallets.py @@ -104,16 +104,16 @@ class Wallets: size = position.amount collateral = position.stake_amount leverage = position.leverage - tot_in_trades -= collateral + tot_in_trades += collateral _positions[position.pair] = PositionWallet( position.pair, position=size, leverage=leverage, collateral=collateral, side=position.trade_direction ) - current_stake = self.start_cap + tot_profit + current_stake = self.start_cap + tot_profit - tot_in_trades used_stake = tot_in_trades - total_stake = current_stake - tot_in_trades + total_stake = current_stake + tot_in_trades _wallets[self._config['stake_currency']] = Wallet( currency=self._config['stake_currency'], From 98755c18742bbe2dc1d32e98fadb5e471b93a327 Mon Sep 17 00:00:00 2001 From: Matthias Date: Thu, 10 Mar 2022 06:47:17 +0100 Subject: [PATCH 15/16] Fix wrong estimated output from /balance endpoints --- freqtrade/rpc/rpc.py | 4 ++++ tests/rpc/test_rpc.py | 7 +++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/freqtrade/rpc/rpc.py b/freqtrade/rpc/rpc.py index a77f6f69c..f47bc2668 100644 --- a/freqtrade/rpc/rpc.py +++ b/freqtrade/rpc/rpc.py @@ -586,6 +586,9 @@ class RPC: if coin == stake_currency: rate = 1.0 est_stake = balance.total + if self._config.get('trading_mode', TradingMode.SPOT) != TradingMode.SPOT: + # in Futures, "total" includes the locked stake, and therefore all positions + est_stake = balance.free else: try: pair = self._freqtrade.exchange.get_valid_pair_combination(coin, stake_currency) @@ -614,6 +617,7 @@ class RPC: symbol: str position: PositionWallet for symbol, position in self._freqtrade.wallets.get_all_positions().items(): + total += position.collateral currencies.append({ 'currency': symbol, diff --git a/tests/rpc/test_rpc.py b/tests/rpc/test_rpc.py index 7e34506d6..11fb5e0a1 100644 --- a/tests/rpc/test_rpc.py +++ b/tests/rpc/test_rpc.py @@ -650,8 +650,8 @@ def test_rpc_balance_handle(default_conf, mocker, tickers): rpc._fiat_converter = CryptoToFiatConverter() result = rpc._rpc_balance(default_conf['stake_currency'], default_conf['fiat_display_currency']) - assert prec_satoshi(result['total'], 12.309096315) - assert prec_satoshi(result['value'], 184636.44472997) + assert prec_satoshi(result['total'], 30.309096315) + assert prec_satoshi(result['value'], 454636.44472997) assert tickers.call_count == 1 assert tickers.call_args_list[0][1]['cached'] is True assert 'USD' == result['symbol'] @@ -661,7 +661,7 @@ def test_rpc_balance_handle(default_conf, mocker, tickers): 'free': 10.0, 'balance': 12.0, 'used': 2.0, - 'est_stake': 12.0, + 'est_stake': 10.0, # In futures mode, "free" is used here. 'stake': 'BTC', 'is_position': False, 'leverage': 1.0, @@ -706,7 +706,6 @@ def test_rpc_balance_handle(default_conf, mocker, tickers): 'side': 'short', } ] - assert result['total'] == 12.309096315331816 def test_rpc_start(mocker, default_conf) -> None: From f6c263882d42e25f48c63f057c4d8c9e378366ef Mon Sep 17 00:00:00 2001 From: Matthias Date: Thu, 10 Mar 2022 07:09:48 +0100 Subject: [PATCH 16/16] Update outdated TODO-lev --- freqtrade/freqtradebot.py | 1 - 1 file changed, 1 deletion(-) diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index 0d634756e..cbc6be11a 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -507,7 +507,6 @@ class FreqtradeBot(LoggingMixin): If the strategy triggers the adjustment, a new order gets issued. Once that completes, the existing trade is modified to match new data. """ - # TODO-lev: Check what changes are necessary for DCA in relation to shorts. if self.strategy.max_entry_position_adjustment > -1: count_of_buys = trade.nr_of_successful_entries if count_of_buys > self.strategy.max_entry_position_adjustment: