Merge pull request #1 from xmatthias/ccxt_fix_cache

fix ticker_cache bug
This commit is contained in:
enenn 2018-03-16 19:40:59 +01:00 committed by GitHub
commit 78548d122a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -200,10 +200,10 @@ def get_ticker(pair: str, refresh: Optional[bool] = True) -> dict:
global _TICKER_CACHE global _TICKER_CACHE
try: try:
if not refresh: if not refresh:
if _TICKER_CACHE: if _TICKER_CACHE and pair in _TICKER_CACHE:
return _TICKER_CACHE return _TICKER_CACHE[pair]
_TICKER_CACHE = _API.fetch_ticker(pair) _TICKER_CACHE[pair] = _API.fetch_ticker(pair)
return _TICKER_CACHE return _TICKER_CACHE[pair]
except ccxt.NetworkError as e: except ccxt.NetworkError as e:
raise NetworkException( raise NetworkException(
'Could not load tickers due to networking error. Message: {}'.format(e) 'Could not load tickers due to networking error. Message: {}'.format(e)