mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 10:21:59 +00:00
Refactor get_buy_rate to use rate variable
This commit is contained in:
parent
de48a697b0
commit
5f71232038
|
@ -242,11 +242,10 @@ class FreqtradeBot:
|
||||||
logger.info(f"Using cached buy rate for {pair}.")
|
logger.info(f"Using cached buy rate for {pair}.")
|
||||||
return rate
|
return rate
|
||||||
|
|
||||||
config_bid_strategy = self.config.get('bid_strategy', {})
|
bid_strategy = self.config.get('bid_strategy', {})
|
||||||
if 'use_order_book' in config_bid_strategy and\
|
if 'use_order_book' in bid_strategy and bid_strategy.get('use_order_book', False):
|
||||||
config_bid_strategy.get('use_order_book', False):
|
|
||||||
logger.info('Getting price from order book')
|
logger.info('Getting price from order book')
|
||||||
order_book_top = config_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
|
||||||
|
@ -256,11 +255,12 @@ class FreqtradeBot:
|
||||||
else:
|
else:
|
||||||
logger.info('Using Last Ask / Last Price')
|
logger.info('Using Last Ask / Last Price')
|
||||||
ticker = self.exchange.fetch_ticker(pair)
|
ticker = self.exchange.fetch_ticker(pair)
|
||||||
if ticker['ask'] < ticker['last']:
|
rate = ticker['ask']
|
||||||
ticker_rate = ticker['ask']
|
if rate < ticker['last']:
|
||||||
|
ticker_rate = rate
|
||||||
else:
|
else:
|
||||||
balance = self.config['bid_strategy']['ask_last_balance']
|
balance = self.config['bid_strategy']['ask_last_balance']
|
||||||
ticker_rate = ticker['ask'] + balance * (ticker['last'] - ticker['ask'])
|
ticker_rate = rate + balance * (ticker['last'] - rate)
|
||||||
used_rate = ticker_rate
|
used_rate = ticker_rate
|
||||||
|
|
||||||
self._buy_rate_cache[pair] = used_rate
|
self._buy_rate_cache[pair] = used_rate
|
||||||
|
|
Loading…
Reference in New Issue
Block a user