Merge pull request #1142 from freqtrade/ujson-loader
backtesting: try to load data with ujson if it exists
This commit is contained in:
commit
0674c3e8f0
@ -1,7 +1,13 @@
|
|||||||
# pragma pylint: disable=missing-docstring
|
# pragma pylint: disable=missing-docstring
|
||||||
|
|
||||||
import gzip
|
import gzip
|
||||||
import json
|
try:
|
||||||
|
import ujson as json
|
||||||
|
_UJSON = True
|
||||||
|
except ImportError:
|
||||||
|
# see mypy/issues/1153
|
||||||
|
import json # type: ignore
|
||||||
|
_UJSON = False
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
from typing import Optional, List, Dict, Tuple, Any
|
from typing import Optional, List, Dict, Tuple, Any
|
||||||
@ -14,6 +20,14 @@ from freqtrade.arguments import TimeRange
|
|||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
def json_load(data):
|
||||||
|
"""Try to load data with ujson"""
|
||||||
|
if _UJSON:
|
||||||
|
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
|
||||||
|
Loading…
Reference in New Issue
Block a user