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 gzip
import json import json
import ujson
import logging import logging
import os import os
from typing import Optional, List, Dict, Tuple, Any 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.exchange import Exchange
from freqtrade.arguments import TimeRange 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__) logger = logging.getLogger(__name__)
@ -68,7 +72,10 @@ def load_tickerdata_file(
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:
if ujson_found is not None:
pairdata = ujson.load(tickerdata) pairdata = ujson.load(tickerdata)
else:
pairdata = json.load(tickerdata)
else: else:
return None return None

View File

@ -17,7 +17,10 @@ pytest-mock==1.10.0
pytest-cov==2.5.1 pytest-cov==2.5.1
tabulate==0.8.2 tabulate==0.8.2
coinmarketcap==5.0.3 coinmarketcap==5.0.3
ujson==1.35
# Optional, speeds up ticker load
# Requires visual studio in windows.
#ujson==1.35
# Required for hyperopt # Required for hyperopt
scikit-optimize==0.5.2 scikit-optimize==0.5.2