Make process_maybe_execute_*() returning integers
This commit is contained in:
parent
4d56e3b36e
commit
b00406a7eb
@ -460,11 +460,11 @@ class FreqtradeBot:
|
|||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def process_maybe_execute_buys(self) -> None:
|
def process_maybe_execute_buys(self) -> int:
|
||||||
"""
|
"""
|
||||||
Tries to execute buy orders for trades in a safe way
|
Tries to execute buy orders for trades in a safe way
|
||||||
"""
|
"""
|
||||||
result = False
|
trades_created = 0
|
||||||
|
|
||||||
whitelist = copy.deepcopy(self.active_pair_whitelist)
|
whitelist = copy.deepcopy(self.active_pair_whitelist)
|
||||||
if not whitelist:
|
if not whitelist:
|
||||||
@ -483,39 +483,42 @@ class FreqtradeBot:
|
|||||||
# Create entity and execute trade for each pair from whitelist
|
# Create entity and execute trade for each pair from whitelist
|
||||||
for pair in whitelist:
|
for pair in whitelist:
|
||||||
try:
|
try:
|
||||||
if self.create_trade(pair):
|
trades_created += self.create_trade(pair)
|
||||||
result = True
|
|
||||||
except DependencyException as exception:
|
except DependencyException as exception:
|
||||||
logger.warning('Unable to create trade: %s', exception)
|
logger.warning('Unable to create trade: %s', exception)
|
||||||
|
|
||||||
if not result:
|
if not trades_created:
|
||||||
logger.debug("Found no buy signals for whitelisted currencies. "
|
logger.debug("Found no buy signals for whitelisted currencies. "
|
||||||
"Trying again...")
|
"Trying again...")
|
||||||
|
|
||||||
def process_maybe_execute_sells(self, trades: List[Any]) -> None:
|
return trades_created
|
||||||
|
|
||||||
|
def process_maybe_execute_sells(self, trades: List[Any]) -> int:
|
||||||
"""
|
"""
|
||||||
Tries to execute sell orders for trades in a safe way
|
Tries to execute sell orders for trades in a safe way
|
||||||
"""
|
"""
|
||||||
result = False
|
trades_closed = 0
|
||||||
for trade in trades:
|
for trade in trades:
|
||||||
try:
|
try:
|
||||||
self.update_trade_state(trade)
|
self.update_trade_state(trade)
|
||||||
|
|
||||||
if (self.strategy.order_types.get('stoploss_on_exchange') and
|
if (self.strategy.order_types.get('stoploss_on_exchange') and
|
||||||
self.handle_stoploss_on_exchange(trade)):
|
self.handle_stoploss_on_exchange(trade)):
|
||||||
result = True
|
trades_closed += 1
|
||||||
continue
|
continue
|
||||||
# Check if we can sell our current pair
|
# Check if we can sell our current pair
|
||||||
if trade.open_order_id is None and self.handle_trade(trade):
|
if trade.open_order_id is None and self.handle_trade(trade):
|
||||||
result = True
|
trades_closed += 1
|
||||||
|
|
||||||
except DependencyException as exception:
|
except DependencyException as exception:
|
||||||
logger.warning('Unable to sell trade: %s', exception)
|
logger.warning('Unable to sell trade: %s', exception)
|
||||||
|
|
||||||
# Updating wallets if any trade occured
|
# Updating wallets if any trade occured
|
||||||
if result:
|
if trades_closed:
|
||||||
self.wallets.update()
|
self.wallets.update()
|
||||||
|
|
||||||
|
return trades_closed
|
||||||
|
|
||||||
def get_real_amount(self, trade: Trade, order: Dict, order_amount: float = None) -> float:
|
def get_real_amount(self, trade: Trade, order: Dict, order_amount: float = None) -> float:
|
||||||
"""
|
"""
|
||||||
Get real amount for the trade
|
Get real amount for the trade
|
||||||
|
Loading…
Reference in New Issue
Block a user