Make module optional,

hashed out by default in requirements.txt
optimise tests for module to decide how to load tickers.
This commit is contained in:
creslinux
2018-07-12 13:05:09 +00:00
parent 87f7d9972f
commit 801b77cf8c
2 changed files with 13 additions and 3 deletions

View File

@@ -2,7 +2,6 @@
import gzip
import json
import ujson
import logging
import os
from typing import Optional, List, Dict, Tuple, Any
@@ -12,6 +11,11 @@ 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__)
@@ -68,7 +72,10 @@ def load_tickerdata_file(
elif os.path.isfile(file):
logger.debug('Loading ticker data from file %s', file)
with open(file) as tickerdata:
pairdata = ujson.load(tickerdata)
if ujson_found is not None:
pairdata = ujson.load(tickerdata)
else:
pairdata = json.load(tickerdata)
else:
return None