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:
commit
42024134ec
@ -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:
|
||||||
|
Loading…
Reference in New Issue
Block a user