Using ujson to load ticker files from disk during backtest
is over 30% faster.
This commit is contained in:
parent
bd46b4faf3
commit
af34540450
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
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
|
||||||
@ -67,7 +68,7 @@ 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:
|
||||||
pairdata = json.load(tickerdata)
|
pairdata = ujson.load(tickerdata)
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@ -163,7 +164,7 @@ def load_cached_data_for_updating(filename: str,
|
|||||||
# read the cached file
|
# read the cached file
|
||||||
if os.path.isfile(filename):
|
if os.path.isfile(filename):
|
||||||
with open(filename, "rt") as file:
|
with open(filename, "rt") as file:
|
||||||
data = json.load(file)
|
data = ujson.load(file)
|
||||||
# remove the last item, because we are not sure if it is correct
|
# remove the last item, because we are not sure if it is correct
|
||||||
# it could be fetched when the candle was incompleted
|
# it could be fetched when the candle was incompleted
|
||||||
if data:
|
if data:
|
||||||
|
@ -17,6 +17,7 @@ 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
|
||||||
|
|
||||||
# Required for hyperopt
|
# Required for hyperopt
|
||||||
scikit-optimize==0.5.2
|
scikit-optimize==0.5.2
|
||||||
|
Loading…
Reference in New Issue
Block a user