bug fix: book order limit for binance

This commit is contained in:
Nullart 2018-06-19 21:33:42 +08:00
parent 65ce10a124
commit 97a621325b
2 changed files with 11 additions and 1 deletions

View File

@ -83,7 +83,7 @@ CONF_SCHEMA = {
'properties': { 'properties': {
'use_book_order': {'type': 'boolean'}, 'use_book_order': {'type': 'boolean'},
'book_order_min': {'type': 'number', 'minimum': 1}, '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'] 'required': ['use_book_order']
}, },

View File

@ -243,6 +243,16 @@ def get_balances() -> dict:
@retrier @retrier
def get_order_book(pair: str, limit: Optional[int] = 100) -> dict: def get_order_book(pair: str, limit: Optional[int] = 100) -> dict:
try: 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) return _API.fetch_order_book(pair, limit)
except ccxt.NotSupported as e: except ccxt.NotSupported as e:
raise OperationalException( raise OperationalException(