Add get_open_trade_count() to simplify getting open trade count.

This commit is contained in:
Matthias
2022-08-21 10:03:04 +02:00
parent 085f81ec9e
commit 87a3115073
4 changed files with 13 additions and 3 deletions

View File

@@ -271,7 +271,7 @@ class FreqtradeBot(LoggingMixin):
Return the number of free open trades slots or 0 if
max number of open trades reached
"""
open_trades = len(Trade.get_open_trades())
open_trades = Trade.get_open_trade_count()
return max(0, self.config['max_open_trades'] - open_trades)
def update_funding_fees(self):

View File

@@ -1044,6 +1044,16 @@ class LocalTrade():
"""
return Trade.get_trades_proxy(is_open=True)
@staticmethod
def get_open_trade_count() -> int:
"""
get open trade count
"""
if Trade.use_db:
return Trade.query.filter(Trade.is_open.is_(True)).count()
else:
return len(LocalTrade.trades_open)
@staticmethod
def stoploss_reinitialization(desired_stoploss):
"""