add ticker argumet to get_target_bid

This commit is contained in:
iuvbio 2019-03-02 17:24:48 +01:00
parent 24c587518a
commit c36fa0c7e2

View File

@ -206,7 +206,7 @@ class FreqtradeBot(object):
self.state = State.STOPPED self.state = State.STOPPED
return state_changed return state_changed
def get_target_bid(self, pair: str) -> float: def get_target_bid(self, pair: str, ticker: Dict = None) -> float:
""" """
Calculates bid target between current ask price and last price Calculates bid target between current ask price and last price
:return: float: Price :return: float: Price
@ -223,6 +223,7 @@ class FreqtradeBot(object):
logger.info('...top %s order book buy rate %0.8f', order_book_top, order_book_rate) logger.info('...top %s order book buy rate %0.8f', order_book_top, order_book_rate)
used_rate = order_book_rate used_rate = order_book_rate
else: else:
if not ticker:
logger.info('Using Last Ask / Last Price') logger.info('Using Last Ask / Last Price')
ticker = self.exchange.get_ticker(pair) ticker = self.exchange.get_ticker(pair)
if ticker['ask'] < ticker['last']: if ticker['ask'] < ticker['last']:
@ -269,12 +270,10 @@ class FreqtradeBot(object):
return stake_amount return stake_amount
def _get_min_pair_stake_amount(self, pair: str, price: float) -> Optional[float]: def _get_min_pair_stake_amount(self, pair: str, price: float) -> Optional[float]:
markets = self.exchange.get_markets() try:
markets = [m for m in markets if m['symbol'] == pair] market = self.exchange.markets[pair]
if not markets: except KeyError:
raise ValueError(f'Can\'t get market information for symbol {pair}') raise ValueError(f"Can't get market information for symbol {pair}")
market = markets[0]
if 'limits' not in market: if 'limits' not in market:
return None return None