Allow passing price to buy function

This commit is contained in:
Matthias
2018-10-09 07:06:11 +02:00
parent d23dc3ec41
commit 5029003957
2 changed files with 54 additions and 3 deletions

View File

@@ -425,7 +425,7 @@ class FreqtradeBot(object):
return True
return False
def execute_buy(self, pair: str, stake_amount: float) -> bool:
def execute_buy(self, pair: str, stake_amount: float, price: Optional[float] = None) -> bool:
"""
Executes a limit buy for the given pair
:param pair: pair for which we want to create a LIMIT_BUY
@@ -436,8 +436,11 @@ class FreqtradeBot(object):
stake_currency = self.config['stake_currency']
fiat_currency = self.config.get('fiat_display_currency', None)
# Calculate amount
buy_limit = self.get_target_bid(pair, self.exchange.get_ticker(pair))
if price:
buy_limit = price
else:
# Calculate amount
buy_limit = self.get_target_bid(pair, self.exchange.get_ticker(pair))
min_stake_amount = self._get_min_pair_stake_amount(pair_s, buy_limit)
if min_stake_amount is not None and min_stake_amount > stake_amount: