diff --git a/docs/configuration.md b/docs/configuration.md index 54470f278..c70f3425c 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -526,7 +526,7 @@ In line with that, if `ask_strategy.price_side` is set to `"bid"`, then the bot When selling with the orderbook enabled (`ask_strategy.use_order_book=True`), Freqtrade fetches the `ask_strategy.order_book_max` entries in the orderbook. Then each of the orderbook steps between `ask_strategy.order_book_min` and `ask_strategy.order_book_max` on the configured orderbook side are validated for a profitable sell-possibility based on the strategy configuration and the sell order is placed at the first profitable spot. -!!! Note: +!!! Note Using `order_book_max` higher than `order_book_min` only makes sense when ask_strategy.price_side is set to `"ask"`. The idea here is to place the sell order early, to be ahead in the queue. diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index 22a73a273..53493ad4c 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -647,12 +647,10 @@ class FreqtradeBot: config_ask_strategy = self.config.get('ask_strategy', {}) if config_ask_strategy.get('use_order_book', False): + # This code is only used for notifications, selling uses the generator directly logger.debug('Using order book to get sell rate') rate = next(self._order_book_gen(pair, f"{config_ask_strategy['price_side']}s")) - # order_book = self.exchange.get_order_book(pair, 1) - # rate = order_book[f"{config_ask_strategy['price_side']}s"][0][0] - else: rate = self.exchange.fetch_ticker(pair)[config_ask_strategy['price_side']] self._sell_rate_cache[pair] = rate diff --git a/tests/test_freqtradebot.py b/tests/test_freqtradebot.py index 655fe4684..49000382f 100644 --- a/tests/test_freqtradebot.py +++ b/tests/test_freqtradebot.py @@ -922,7 +922,8 @@ def test_process_informative_pairs_added(default_conf, ticker, mocker) -> None: ('bid', 4, 5, 10, 1.0, 5), # last bigger than bid ('bid', 4, 5, 10, 0.5, 5), # last bigger than bid ]) -def test_get_buy_rate(mocker, default_conf, caplog, side, ask, bid, last, last_ab, expected) -> None: +def test_get_buy_rate(mocker, default_conf, caplog, side, ask, bid, + last, last_ab, expected) -> None: default_conf['bid_strategy']['ask_last_balance'] = last_ab default_conf['bid_strategy']['price_side'] = side freqtrade = get_patched_freqtradebot(mocker, default_conf)