Fix problem when limit is > max allowed limit

This commit is contained in:
Matthias 2020-10-13 20:38:02 +02:00
parent 8165cc11df
commit 07da21e633
2 changed files with 4 additions and 2 deletions

View File

@ -1077,7 +1077,7 @@ class Exchange:
"""
if not limit_range:
return limit
return min([x for x in limit_range if limit <= x])
return min([x for x in limit_range if limit <= x] + [max(limit_range)])
@retrier
def fetch_l2_order_book(self, pair: str, limit: int = 100) -> dict:

View File

@ -1458,7 +1458,9 @@ def test_get_next_limit_in_list():
assert Exchange.get_next_limit_in_list(21, limit_range) == 50
assert Exchange.get_next_limit_in_list(51, limit_range) == 100
assert Exchange.get_next_limit_in_list(1000, limit_range) == 1000
# assert Exchange.get_next_limit_in_list(1001, limit_range) == 1001
# Going over the limit ...
assert Exchange.get_next_limit_in_list(1001, limit_range) == 1000
assert Exchange.get_next_limit_in_list(2000, limit_range) == 1000
assert Exchange.get_next_limit_in_list(21, None) == 21
assert Exchange.get_next_limit_in_list(100, None) == 100