From 97a621325b647dd53c6566453ca3a66435636cd8 Mon Sep 17 00:00:00 2001 From: Nullart Date: Tue, 19 Jun 2018 21:33:42 +0800 Subject: [PATCH] bug fix: book order limit for binance --- freqtrade/constants.py | 2 +- freqtrade/exchange/__init__.py | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/freqtrade/constants.py b/freqtrade/constants.py index 4031f9eed..4e15d471c 100644 --- a/freqtrade/constants.py +++ b/freqtrade/constants.py @@ -83,7 +83,7 @@ CONF_SCHEMA = { 'properties': { 'use_book_order': {'type': 'boolean'}, 'book_order_min': {'type': 'number', 'minimum': 1}, - 'book_order_max': {'type': 'number', 'minimum': 1} + 'book_order_max': {'type': 'number', 'minimum': 1, 'maximum': 50} }, 'required': ['use_book_order'] }, diff --git a/freqtrade/exchange/__init__.py b/freqtrade/exchange/__init__.py index e25f4c8b9..be5c3940d 100644 --- a/freqtrade/exchange/__init__.py +++ b/freqtrade/exchange/__init__.py @@ -243,6 +243,16 @@ def get_balances() -> dict: @retrier def get_order_book(pair: str, limit: Optional[int] = 100) -> dict: try: + params = {} + # 20180619: bittrex doesnt support limits -.- + # 20180619: binance limit fix.. binance currently has valid range + if _API.name == 'Binance': + limit_range = [5, 10, 20, 50, 100, 500, 1000] + for limitx in limit_range: + if limit < limitx: + limit = limitx + break + return _API.fetch_order_book(pair, limit) except ccxt.NotSupported as e: raise OperationalException(