Change buy_rate calculation to use price_side
This commit is contained in:
parent
5f71232038
commit
e4b2949188
@ -244,18 +244,20 @@ class FreqtradeBot:
|
|||||||
|
|
||||||
bid_strategy = self.config.get('bid_strategy', {})
|
bid_strategy = self.config.get('bid_strategy', {})
|
||||||
if 'use_order_book' in bid_strategy and bid_strategy.get('use_order_book', False):
|
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_top = bid_strategy.get('order_book_top', 1)
|
||||||
order_book = self.exchange.get_order_book(pair, order_book_top)
|
order_book = self.exchange.get_order_book(pair, order_book_top)
|
||||||
logger.debug('order_book %s', order_book)
|
logger.debug('order_book %s', order_book)
|
||||||
# top 1 = index 0
|
# top 1 = index 0
|
||||||
order_book_rate = order_book['bids'][order_book_top - 1][0]
|
order_book_rate = order_book[f"{bid_strategy['price_side']}s"][order_book_top - 1][0]
|
||||||
logger.info('...top %s order book buy rate %0.8f', order_book_top, order_book_rate)
|
logger.info(f'...top {order_book_top} order book buy rate {order_book_rate:.8f}')
|
||||||
used_rate = order_book_rate
|
used_rate = order_book_rate
|
||||||
else:
|
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)
|
ticker = self.exchange.fetch_ticker(pair)
|
||||||
rate = ticker['ask']
|
rate = ticker[bid_strategy['price_side']]
|
||||||
if rate < ticker['last']:
|
if rate < ticker['last']:
|
||||||
ticker_rate = rate
|
ticker_rate = rate
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user