diff --git a/docs/configuration.md b/docs/configuration.md index 172ad468d..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 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 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': { 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/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'] diff --git a/freqtrade/rpc/rpc.py b/freqtrade/rpc/rpc.py index f53e9cdeb..d731f6fa4 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 @@ -254,9 +254,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_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) diff --git a/tests/rpc/test_rpc.py b/tests/rpc/test_rpc.py index 338af682b..7e3334c46 100644 --- a/tests/rpc/test_rpc.py +++ b/tests/rpc/test_rpc.py @@ -235,9 +235,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")))