Merge pull request #1092 from freqtrade/revert-1090-ujson-loader

Revert "backtesting: try to load data with ujson if it exists"
This commit is contained in:
Matthias 2018-07-29 12:23:25 +01:00 committed by GitHub
commit 42024134ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,12 +1,7 @@
# pragma pylint: disable=missing-docstring # pragma pylint: disable=missing-docstring
import gzip import gzip
try: import json
import ujson as json
except ImportError:
# see mypy/issues/1153
import json # type: ignore
import inspect
import logging import logging
import os import os
from typing import Optional, List, Dict, Tuple, Any from typing import Optional, List, Dict, Tuple, Any
@ -19,14 +14,6 @@ from freqtrade.arguments import TimeRange
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
def json_load(data):
"""Try to load data with ujson"""
if inspect.getfullargspec(json.load)[5].get('precise_float'):
return json.load(data, precise_float=True)
else:
return json.load(data)
def trim_tickerlist(tickerlist: List[Dict], timerange: TimeRange) -> List[Dict]: def trim_tickerlist(tickerlist: List[Dict], timerange: TimeRange) -> List[Dict]:
if not tickerlist: if not tickerlist:
return tickerlist return tickerlist
@ -76,11 +63,11 @@ def load_tickerdata_file(
if os.path.isfile(gzipfile): if os.path.isfile(gzipfile):
logger.debug('Loading ticker data from file %s', gzipfile) logger.debug('Loading ticker data from file %s', gzipfile)
with gzip.open(gzipfile) as tickerdata: with gzip.open(gzipfile) as tickerdata:
pairdata = json_load(tickerdata) pairdata = json.load(tickerdata)
elif os.path.isfile(file): elif os.path.isfile(file):
logger.debug('Loading ticker data from file %s', file) logger.debug('Loading ticker data from file %s', file)
with open(file) as tickerdata: with open(file) as tickerdata:
pairdata = json_load(tickerdata) pairdata = json.load(tickerdata)
else: else:
return None return None
@ -176,7 +163,7 @@ def load_cached_data_for_updating(filename: str,
# read the cached file # read the cached file
if os.path.isfile(filename): if os.path.isfile(filename):
with open(filename, "rt") as file: with open(filename, "rt") as file:
data = json_load(file) data = json.load(file)
# remove the last item, because we are not sure if it is correct # remove the last item, because we are not sure if it is correct
# it could be fetched when the candle was incompleted # it could be fetched when the candle was incompleted
if data: if data: