Fix failing api when max_open_trades is unlimited
This commit is contained in:
parent
60ea32e398
commit
ac43591c44
@ -649,7 +649,8 @@ class RPC:
|
|||||||
trades = Trade.get_open_trades()
|
trades = Trade.get_open_trades()
|
||||||
return {
|
return {
|
||||||
'current': len(trades),
|
'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)
|
'total_stake': sum((trade.open_rate * trade.amount) for trade in trades)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -364,14 +364,19 @@ def test_api_count(botclient, mocker, ticker, fee, markets):
|
|||||||
assert_response(rc)
|
assert_response(rc)
|
||||||
|
|
||||||
assert rc.json()["current"] == 0
|
assert rc.json()["current"] == 0
|
||||||
assert rc.json()["max"] == 1.0
|
assert rc.json()["max"] == 1
|
||||||
|
|
||||||
# Create some test data
|
# Create some test data
|
||||||
ftbot.enter_positions()
|
ftbot.enter_positions()
|
||||||
rc = client_get(client, f"{BASE_URI}/count")
|
rc = client_get(client, f"{BASE_URI}/count")
|
||||||
assert_response(rc)
|
assert_response(rc)
|
||||||
assert rc.json()["current"] == 1.0
|
assert rc.json()["current"] == 1
|
||||||
assert rc.json()["max"] == 1.0
|
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):
|
def test_api_locks(botclient):
|
||||||
|
Loading…
Reference in New Issue
Block a user