Fix failing api when max_open_trades is unlimited

This commit is contained in:
Matthias 2021-01-12 19:24:37 +01:00
parent 60ea32e398
commit ac43591c44
2 changed files with 10 additions and 4 deletions

View File

@ -649,7 +649,8 @@ class RPC:
trades = Trade.get_open_trades()
return {
'current': len(trades),
'max': float(self._freqtrade.config['max_open_trades']),
'max': (int(self._freqtrade.config['max_open_trades'])
if self._freqtrade.config['max_open_trades'] != float('inf') else -1),
'total_stake': sum((trade.open_rate * trade.amount) for trade in trades)
}

View File

@ -364,14 +364,19 @@ def test_api_count(botclient, mocker, ticker, fee, markets):
assert_response(rc)
assert rc.json()["current"] == 0
assert rc.json()["max"] == 1.0
assert rc.json()["max"] == 1
# Create some test data
ftbot.enter_positions()
rc = client_get(client, f"{BASE_URI}/count")
assert_response(rc)
assert rc.json()["current"] == 1.0
assert rc.json()["max"] == 1.0
assert rc.json()["current"] == 1
assert rc.json()["max"] == 1
ftbot.config['max_open_trades'] = float('inf')
rc = client_get(client, f"{BASE_URI}/count")
assert rc.json()["max"] == -1
def test_api_locks(botclient):