From e4b29491888c05444ec47599238926597ecac83a Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 23 Feb 2020 14:13:43 +0100 Subject: [PATCH] Change buy_rate calculation to use price_side --- freqtrade/freqtradebot.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index aaa66fe81..2c9a960a4 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -244,18 +244,20 @@ class FreqtradeBot: bid_strategy = self.config.get('bid_strategy', {}) if 'use_order_book' in bid_strategy and bid_strategy.get('use_order_book', False): - logger.info('Getting price from order book') + logger.info( + f"Getting price from order book {bid_strategy['price_side'].capitalize()} side." + ) order_book_top = bid_strategy.get('order_book_top', 1) order_book = self.exchange.get_order_book(pair, order_book_top) logger.debug('order_book %s', order_book) # top 1 = index 0 - order_book_rate = order_book['bids'][order_book_top - 1][0] - logger.info('...top %s order book buy rate %0.8f', order_book_top, order_book_rate) + order_book_rate = order_book[f"{bid_strategy['price_side']}s"][order_book_top - 1][0] + logger.info(f'...top {order_book_top} order book buy rate {order_book_rate:.8f}') used_rate = order_book_rate else: - logger.info('Using Last Ask / Last Price') + logger.info(f"Using Last {bid_strategy['price_side'].capitalize()} / Last Price") ticker = self.exchange.fetch_ticker(pair) - rate = ticker['ask'] + rate = ticker[bid_strategy['price_side']] if rate < ticker['last']: ticker_rate = rate else: