From 31211a33fde625f401d19bfe20fd8564cf62feb1 Mon Sep 17 00:00:00 2001 From: Verbalinsurection Date: Tue, 25 Jan 2022 11:20:49 +0100 Subject: [PATCH 01/10] Fix ETH duplicate in CoinGecko --- freqtrade/rpc/fiat_convert.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/freqtrade/rpc/fiat_convert.py b/freqtrade/rpc/fiat_convert.py index ef9689d0a..f65fd2d54 100644 --- a/freqtrade/rpc/fiat_convert.py +++ b/freqtrade/rpc/fiat_convert.py @@ -77,6 +77,9 @@ class CryptoToFiatConverter: else: return None found = [x for x in self._coinlistings if x['symbol'] == crypto_symbol] + if crypto_symbol == 'eth': + found = [x for x in self._coinlistings if x['id'] == 'ethereum'] + if len(found) == 1: return found[0]['id'] From cbd213bc0ae802802d9c2cf765e69e947e486405 Mon Sep 17 00:00:00 2001 From: Stefano Ariestasia Date: Fri, 28 Jan 2022 09:16:56 +0900 Subject: [PATCH 02/10] fix typo --- docs/configuration.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/configuration.md b/docs/configuration.md index 172ad468d..2e9a4c975 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -173,7 +173,7 @@ Mandatory parameters are marked as **Required**, which means that they are requi | `dataformat_ohlcv` | Data format to use to store historical candle (OHLCV) data.
*Defaults to `json`*.
**Datatype:** String | `dataformat_trades` | Data format to use to store historical trades data.
*Defaults to `jsongz`*.
**Datatype:** String | `position_adjustment_enable` | Enables the strategy to use position adjustments (additional buys or sells). [More information here](strategy-callbacks.md#adjust-trade-position).
[Strategy Override](#parameters-in-the-strategy).
*Defaults to `false`.*
**Datatype:** Boolean -| `max_entry_position_adjustment` | Maximum additional buy(s) for each open trade on top of the first entry Order. Set it to `-1` for unlimited additional additional orders. [More information here](strategy-callbacks.md#adjust-trade-position).
[Strategy Override](#parameters-in-the-strategy).
*Defaults to `-1`.*
**Datatype:** Positive Integer or -1 +| `max_entry_position_adjustment` | Maximum additional buy(s) for each open trade on top of the first entry Order. Set it to `-1` for unlimited additional orders. [More information here](strategy-callbacks.md#adjust-trade-position).
[Strategy Override](#parameters-in-the-strategy).
*Defaults to `-1`.*
**Datatype:** Positive Integer or -1 ### Parameters in the strategy From b8f29802e55b070127d971ee985582214885bcaf Mon Sep 17 00:00:00 2001 From: Stefano Ariestasia Date: Fri, 28 Jan 2022 09:31:36 +0900 Subject: [PATCH 03/10] another typo --- docs/configuration.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/configuration.md b/docs/configuration.md index 2e9a4c975..d702fe8f9 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -173,7 +173,7 @@ Mandatory parameters are marked as **Required**, which means that they are requi | `dataformat_ohlcv` | Data format to use to store historical candle (OHLCV) data.
*Defaults to `json`*.
**Datatype:** String | `dataformat_trades` | Data format to use to store historical trades data.
*Defaults to `jsongz`*.
**Datatype:** String | `position_adjustment_enable` | Enables the strategy to use position adjustments (additional buys or sells). [More information here](strategy-callbacks.md#adjust-trade-position).
[Strategy Override](#parameters-in-the-strategy).
*Defaults to `false`.*
**Datatype:** Boolean -| `max_entry_position_adjustment` | Maximum additional buy(s) for each open trade on top of the first entry Order. Set it to `-1` for unlimited additional orders. [More information here](strategy-callbacks.md#adjust-trade-position).
[Strategy Override](#parameters-in-the-strategy).
*Defaults to `-1`.*
**Datatype:** Positive Integer or -1 +| `max_entry_position_adjustment` | Maximum additional order(s) for each open trade on top of the first entry Order. Set it to `-1` for unlimited additional orders. [More information here](strategy-callbacks.md#adjust-trade-position).
[Strategy Override](#parameters-in-the-strategy).
*Defaults to `-1`.*
**Datatype:** Positive Integer or -1 ### Parameters in the strategy From 9df7014de39186048f52741b0df705e8832fd66b Mon Sep 17 00:00:00 2001 From: Matthias Date: Fri, 28 Jan 2022 06:59:37 +0100 Subject: [PATCH 04/10] Skip kraken tests temporarily --- tests/exchange/test_ccxt_compat.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/exchange/test_ccxt_compat.py b/tests/exchange/test_ccxt_compat.py index 44c664c92..6314b6eb8 100644 --- a/tests/exchange/test_ccxt_compat.py +++ b/tests/exchange/test_ccxt_compat.py @@ -29,12 +29,12 @@ EXCHANGES = { 'hasQuoteVolume': True, 'timeframe': '5m', }, - 'kraken': { - 'pair': 'BTC/USDT', - 'stake_currency': 'USDT', - 'hasQuoteVolume': True, - 'timeframe': '5m', - }, + # 'kraken': { + # 'pair': 'BTC/USDT', + # 'stake_currency': 'USDT', + # 'hasQuoteVolume': True, + # 'timeframe': '5m', + # }, 'ftx': { 'pair': 'BTC/USDT', 'stake_currency': 'USDT', From 138e867a68f0ff3639d74cd6f7ca987e1a9c2a53 Mon Sep 17 00:00:00 2001 From: Matthias Date: Fri, 28 Jan 2022 07:20:47 +0100 Subject: [PATCH 05/10] Filter tickers on stake-currency for kraken --- freqtrade/exchange/exchange.py | 4 ++-- freqtrade/exchange/kraken.py | 8 +++++++- tests/exchange/test_ccxt_compat.py | 12 ++++++------ 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/freqtrade/exchange/exchange.py b/freqtrade/exchange/exchange.py index bfff7d06c..004fb2437 100644 --- a/freqtrade/exchange/exchange.py +++ b/freqtrade/exchange/exchange.py @@ -953,7 +953,7 @@ class Exchange: raise OperationalException(e) from e @retrier - def get_tickers(self, cached: bool = False) -> Dict: + def get_tickers(self, symbols: List[str] = None, cached: bool = False) -> Dict: """ :param cached: Allow cached result :return: fetch_tickers result @@ -963,7 +963,7 @@ class Exchange: if tickers: return tickers try: - tickers = self._api.fetch_tickers() + tickers = self._api.fetch_tickers(symbols) self._fetch_tickers_cache['fetch_tickers'] = tickers return tickers except ccxt.NotSupported as e: diff --git a/freqtrade/exchange/kraken.py b/freqtrade/exchange/kraken.py index 1b069aa6c..f4c8ca275 100644 --- a/freqtrade/exchange/kraken.py +++ b/freqtrade/exchange/kraken.py @@ -1,6 +1,6 @@ """ Kraken exchange subclass """ import logging -from typing import Any, Dict +from typing import Any, Dict, List import ccxt @@ -33,6 +33,12 @@ class Kraken(Exchange): return (parent_check and market.get('darkpool', False) is False) + def get_tickers(self, symbols: List[str] = None, cached: bool = False) -> Dict: + # Only fetch tickers for current stake currency + # Otherwise the request for kraken becomes too large. + symbols = list(self.get_markets(quote_currencies=[self._config['stake_currency']])) + return super().get_tickers(symbols=symbols, cached=cached) + @retrier def get_balances(self) -> dict: if self._config['dry_run']: diff --git a/tests/exchange/test_ccxt_compat.py b/tests/exchange/test_ccxt_compat.py index 6314b6eb8..44c664c92 100644 --- a/tests/exchange/test_ccxt_compat.py +++ b/tests/exchange/test_ccxt_compat.py @@ -29,12 +29,12 @@ EXCHANGES = { 'hasQuoteVolume': True, 'timeframe': '5m', }, - # 'kraken': { - # 'pair': 'BTC/USDT', - # 'stake_currency': 'USDT', - # 'hasQuoteVolume': True, - # 'timeframe': '5m', - # }, + 'kraken': { + 'pair': 'BTC/USDT', + 'stake_currency': 'USDT', + 'hasQuoteVolume': True, + 'timeframe': '5m', + }, 'ftx': { 'pair': 'BTC/USDT', 'stake_currency': 'USDT', From 660f474ab899b1bc2ff23957b37884a6cf6dcd82 Mon Sep 17 00:00:00 2001 From: Verbalinsurection Date: Tue, 25 Jan 2022 11:20:49 +0100 Subject: [PATCH 06/10] Fix ETH duplicate in CoinGecko --- freqtrade/rpc/fiat_convert.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/freqtrade/rpc/fiat_convert.py b/freqtrade/rpc/fiat_convert.py index ef9689d0a..f65fd2d54 100644 --- a/freqtrade/rpc/fiat_convert.py +++ b/freqtrade/rpc/fiat_convert.py @@ -77,6 +77,9 @@ class CryptoToFiatConverter: else: return None found = [x for x in self._coinlistings if x['symbol'] == crypto_symbol] + if crypto_symbol == 'eth': + found = [x for x in self._coinlistings if x['id'] == 'ethereum'] + if len(found) == 1: return found[0]['id'] From 2ba2144df18084cad294997f5ad793a5de4fb9f6 Mon Sep 17 00:00:00 2001 From: Verbalinsurection Date: Fri, 28 Jan 2022 11:17:16 +0100 Subject: [PATCH 07/10] Add tests for ETH fiat_convert --- tests/rpc/test_fiat_convert.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/rpc/test_fiat_convert.py b/tests/rpc/test_fiat_convert.py index 2fe5d4a56..c87cea259 100644 --- a/tests/rpc/test_fiat_convert.py +++ b/tests/rpc/test_fiat_convert.py @@ -148,10 +148,13 @@ def test_fiat_multiple_coins(mocker, caplog): {'id': 'helium', 'symbol': 'hnt', 'name': 'Helium'}, {'id': 'hymnode', 'symbol': 'hnt', 'name': 'Hymnode'}, {'id': 'bitcoin', 'symbol': 'btc', 'name': 'Bitcoin'}, + {'id': 'ethereum', 'symbol': 'eth', 'name': 'Ethereum'}, + {'id': 'ethereum-wormhole', 'symbol': 'eth', 'name': 'Ethereum Wormhole'}, ] assert fiat_convert._get_gekko_id('btc') == 'bitcoin' assert fiat_convert._get_gekko_id('hnt') is None + assert fiat_convert._get_gekko_id('eth') == 'ethereum' assert log_has('Found multiple mappings in goingekko for hnt.', caplog) From fb3c67d86b64c6d603de87a8b156e78398a661b7 Mon Sep 17 00:00:00 2001 From: Matthias Date: Fri, 28 Jan 2022 17:07:34 +0100 Subject: [PATCH 08/10] Accept that keys sometimes are not provided --- freqtrade/rpc/rpc.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/freqtrade/rpc/rpc.py b/freqtrade/rpc/rpc.py index 2374dbd39..a45ba8ea5 100644 --- a/freqtrade/rpc/rpc.py +++ b/freqtrade/rpc/rpc.py @@ -139,8 +139,8 @@ class RPC: 'runmode': config['runmode'].value, 'position_adjustment_enable': config.get('position_adjustment_enable', False), 'max_entry_position_adjustment': ( - config['max_entry_position_adjustment'] - if config['max_entry_position_adjustment'] != float('inf') + config.get('max_entry_position_adjustment', -1) + if config.get('max_entry_position_adjustment') != float('inf') else -1) } return val From e7409e74c2c4798c78559d47eb69842202fca288 Mon Sep 17 00:00:00 2001 From: Matthias Date: Fri, 28 Jan 2022 19:21:31 +0100 Subject: [PATCH 09/10] Remove default from position_adjustment (otherwise strategy parameters won't work anymore) --- freqtrade/constants.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/freqtrade/constants.py b/freqtrade/constants.py index f02e39792..d94e8d850 100644 --- a/freqtrade/constants.py +++ b/freqtrade/constants.py @@ -372,7 +372,7 @@ CONF_SCHEMA = { 'enum': AVAILABLE_DATAHANDLERS, 'default': 'jsongz' }, - 'position_adjustment_enable': {'type': 'boolean', 'default': False}, + 'position_adjustment_enable': {'type': 'boolean'}, 'max_entry_position_adjustment': {'type': ['integer', 'number'], 'minimum': -1}, }, 'definitions': { From d1d520769ebf60083e4db6bd569acd46a7ac3f3e Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 29 Jan 2022 14:25:33 +0100 Subject: [PATCH 10/10] Improve status table for position adjust don't show "/max" if no maximum is set closes #6317 --- freqtrade/rpc/rpc.py | 6 ++++-- tests/rpc/test_rpc.py | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/freqtrade/rpc/rpc.py b/freqtrade/rpc/rpc.py index a45ba8ea5..ed41dbb01 100644 --- a/freqtrade/rpc/rpc.py +++ b/freqtrade/rpc/rpc.py @@ -252,9 +252,11 @@ class RPC: profit_str ] if self._config.get('position_adjustment_enable', False): - max_buy = self._config['max_entry_position_adjustment'] + 1 + max_buy_str = '' + if self._config.get('max_entry_position_adjustment', -1) > 0: + max_buy_str = f"/{self._config['max_entry_position_adjustment'] + 1}" filled_buys = trade.nr_of_successful_buys - detail_trade.append(f"{filled_buys}/{max_buy}") + detail_trade.append(f"{filled_buys}{max_buy_str}") trades_list.append(detail_trade) profitcol = "Profit" if self._fiat_converter: diff --git a/tests/rpc/test_rpc.py b/tests/rpc/test_rpc.py index 27c509c94..46828b325 100644 --- a/tests/rpc/test_rpc.py +++ b/tests/rpc/test_rpc.py @@ -221,9 +221,13 @@ def test_rpc_status_table(default_conf, ticker, fee, mocker) -> None: assert '-0.06' == f'{fiat_profit_sum:.2f}' rpc._config['position_adjustment_enable'] = True + rpc._config['max_entry_position_adjustment'] = 3 result, headers, fiat_profit_sum = rpc._rpc_status_table(default_conf['stake_currency'], 'USD') assert "# Buys" in headers assert len(result[0]) == 5 + # 4th column should be 1/4 - as 1 order filled (a total of 4 is possible) + # 3 on top of the initial one. + assert result[0][4] == '1/4' mocker.patch('freqtrade.exchange.Exchange.get_rate', MagicMock(side_effect=ExchangeError("Pair 'ETH/BTC' not available")))