Added KWarg to calls to ujson, this aligns it FP presicion handing
with how python json manages imports. Added log. All DFs are now aligns, tests passes. We cannot call import ujson as json as the kwarg breaks regular json.
This commit is contained in:
parent
801b77cf8c
commit
3b7bcf9b35
@ -11,13 +11,13 @@ from freqtrade import misc, constants, OperationalException
|
||||
from freqtrade.exchange import Exchange
|
||||
from freqtrade.arguments import TimeRange
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
import importlib
|
||||
ujson_found = importlib.util.find_spec("ujson")
|
||||
if ujson_found is not None:
|
||||
import ujson
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
logger.debug('Loaded UltraJson ujson in optimize.py')
|
||||
|
||||
def trim_tickerlist(tickerlist: List[Dict], timerange: TimeRange) -> List[Dict]:
|
||||
if not tickerlist:
|
||||
@ -68,12 +68,15 @@ 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:
|
||||
if ujson_found is not None:
|
||||
pairdata = ujson.load(tickerdata)
|
||||
pairdata = ujson.load(tickerdata, precise_float=True)
|
||||
else:
|
||||
pairdata = json.load(tickerdata)
|
||||
else:
|
||||
@ -171,7 +174,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:
|
||||
|
Loading…
Reference in New Issue
Block a user