This commit is contained in:
creslin 2018-07-29 07:47:40 +00:00 committed by GitHub
commit bb3a6d858a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 3 deletions

View File

@ -10,9 +10,16 @@ import arrow
from freqtrade import misc, constants, OperationalException
from freqtrade.exchange import Exchange
from freqtrade.arguments import TimeRange
import importlib
ujson_found = importlib.util.find_spec("ujson")
if ujson_found is not None:
import ujson
logger = logging.getLogger(__name__)
if ujson_found is not None:
logger.debug('Loaded UltraJson ujson in optimize.py')
def trim_tickerlist(tickerlist: List[Dict], timerange: TimeRange) -> List[Dict]:
if not tickerlist:
@ -63,11 +70,17 @@ def load_tickerdata_file(
if os.path.isfile(gzipfile):
logger.debug('Loading ticker data from file %s', gzipfile)
with gzip.open(gzipfile) as tickerdata:
pairdata = json.load(tickerdata)
if ujson_found is not None:
pairdata = ujson.load(tickerdata, precise_float=True)
else:
pairdata = json.load(tickerdata)
elif os.path.isfile(file):
logger.debug('Loading ticker data from file %s', file)
with open(file) as tickerdata:
pairdata = json.load(tickerdata)
if ujson_found is not None:
pairdata = ujson.load(tickerdata, precise_float=True)
else:
pairdata = json.load(tickerdata)
else:
return None
@ -163,7 +176,10 @@ def load_cached_data_for_updating(filename: str,
# read the cached file
if os.path.isfile(filename):
with open(filename, "rt") as file:
data = json.load(file)
if ujson_found is not None:
data = ujson.load(file, precise_float=True)
else:
data = json.load(file)
# remove the last item, because we are not sure if it is correct
# it could be fetched when the candle was incompleted
if data:

View File

@ -18,6 +18,10 @@ pytest-cov==2.5.1
tabulate==0.8.2
coinmarketcap==5.0.3
# Optional, speeds up ticker load
# Requires visual studio if on windows.
#ujson==1.35
# Required for hyperopt
scikit-optimize==0.5.2