Change DataProvider interface to accept pair per method
This commit is contained in:
parent
e529a4c261
commit
48728e2d66
@ -6,6 +6,7 @@ from pandas import DataFrame
|
|||||||
|
|
||||||
from freqtrade import misc
|
from freqtrade import misc
|
||||||
from freqtrade.configuration import TimeRange
|
from freqtrade.configuration import TimeRange
|
||||||
|
from freqtrade.data.converter import parse_ticker_dataframe
|
||||||
|
|
||||||
from .idatahandler import IDataHandler
|
from .idatahandler import IDataHandler
|
||||||
|
|
||||||
@ -25,31 +26,40 @@ class JsonDataHandler(IDataHandler):
|
|||||||
# Check if regex found something and only return these results
|
# Check if regex found something and only return these results
|
||||||
return [match[0].replace('_', '/') for match in _tmp if match]
|
return [match[0].replace('_', '/') for match in _tmp if match]
|
||||||
|
|
||||||
def ohlcv_store(self, timeframe: str, data: DataFrame) -> None:
|
def ohlcv_store(self, pair: str, timeframe: str, data: DataFrame) -> None:
|
||||||
"""
|
"""
|
||||||
Store data
|
Store data
|
||||||
"""
|
"""
|
||||||
filename = JsonDataHandler._pair_data_filename(self._datadir, self._pair, timeframe)
|
filename = JsonDataHandler._pair_data_filename(self._datadir, pair, timeframe)
|
||||||
misc.file_dump_json(filename, data, is_zip=self._use_zip)
|
misc.file_dump_json(filename, data, is_zip=self._use_zip)
|
||||||
|
|
||||||
def ohlcv_append(self, timeframe: str, data: DataFrame) -> None:
|
def ohlcv_append(self, pair: str, timeframe: str, data: DataFrame) -> None:
|
||||||
"""
|
"""
|
||||||
Append data to existing files
|
Append data to existing files
|
||||||
"""
|
"""
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
def ohlcv_load(self, timeframe: str, timerange: Optional[TimeRange] = None) -> DataFrame:
|
def _ohlcv_load(self, pair: str, timeframe: str,
|
||||||
|
timerange: Optional[TimeRange] = None,
|
||||||
|
fill_up_missing: bool = True,
|
||||||
|
drop_incomplete: bool = True,
|
||||||
|
) -> DataFrame:
|
||||||
"""
|
"""
|
||||||
Load data for one pair
|
Load data for one pair from disk.
|
||||||
|
Implements the loading and conversation to a Pandas dataframe.
|
||||||
:return: Dataframe
|
:return: Dataframe
|
||||||
"""
|
"""
|
||||||
filename = JsonDataHandler._pair_data_filename(self._datadir, self._pair, timeframe)
|
filename = JsonDataHandler._pair_data_filename(self._datadir, pair, timeframe)
|
||||||
pairdata = misc.file_load_json(filename)
|
pairdata = misc.file_load_json(filename)
|
||||||
if not pairdata:
|
if not pairdata:
|
||||||
return []
|
return DataFrame()
|
||||||
|
|
||||||
if timerange:
|
if timerange:
|
||||||
pairdata = IDataHandler.trim_tickerlist(pairdata, timerange)
|
pairdata = IDataHandler.trim_tickerlist(pairdata, timerange)
|
||||||
|
return parse_ticker_dataframe(pairdata, timeframe,
|
||||||
|
pair=self._pair,
|
||||||
|
fill_missing=fill_up_missing,
|
||||||
|
drop_incomplete=drop_incomplete)
|
||||||
return pairdata
|
return pairdata
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -62,26 +72,26 @@ class JsonDataHandler(IDataHandler):
|
|||||||
# Check if regex found something and only return these results to avoid exceptions.
|
# Check if regex found something and only return these results to avoid exceptions.
|
||||||
return [match[0].replace('_', '/') for match in _tmp if match]
|
return [match[0].replace('_', '/') for match in _tmp if match]
|
||||||
|
|
||||||
def trades_store(self, data: List[Dict]):
|
def trades_store(self, pair: str, data: List[Dict]):
|
||||||
"""
|
"""
|
||||||
Store data
|
Store data
|
||||||
"""
|
"""
|
||||||
filename = self._pair_trades_filename(self._datadir, self._pair)
|
filename = self._pair_trades_filename(self._datadir, pair)
|
||||||
misc.file_dump_json(filename, data, is_zip=self._use_zip)
|
misc.file_dump_json(filename, data, is_zip=self._use_zip)
|
||||||
|
|
||||||
def trades_append(self, data: DataFrame):
|
def trades_append(self, pair: str, data: DataFrame):
|
||||||
"""
|
"""
|
||||||
Append data to existing files
|
Append data to existing files
|
||||||
"""
|
"""
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
def trades_load(self, timerange: Optional[TimeRange] = None) -> List[Dict]:
|
def trades_load(self, pair: str, timerange: Optional[TimeRange] = None) -> List[Dict]:
|
||||||
"""
|
"""
|
||||||
Load a pair from file, either .json.gz or .json
|
Load a pair from file, either .json.gz or .json
|
||||||
# TODO: validate timerange ...
|
# TODO: validate timerange ...
|
||||||
:return: List of trades
|
:return: List of trades
|
||||||
"""
|
"""
|
||||||
filename = self._pair_trades_filename(self._datadir, self._pair)
|
filename = self._pair_trades_filename(self._datadir, pair)
|
||||||
tradesdata = misc.file_load_json(filename)
|
tradesdata = misc.file_load_json(filename)
|
||||||
if not tradesdata:
|
if not tradesdata:
|
||||||
return []
|
return []
|
||||||
|
Loading…
Reference in New Issue
Block a user