Futures candles should go into a subdirectory
This commit is contained in:
parent
fae7167bf3
commit
7baf11a497
@ -65,7 +65,7 @@ ARGS_CONVERT_DATA_OHLCV = ARGS_CONVERT_DATA + ["timeframes"]
|
|||||||
|
|
||||||
ARGS_CONVERT_TRADES = ["pairs", "timeframes", "exchange", "dataformat_ohlcv", "dataformat_trades"]
|
ARGS_CONVERT_TRADES = ["pairs", "timeframes", "exchange", "dataformat_ohlcv", "dataformat_trades"]
|
||||||
|
|
||||||
ARGS_LIST_DATA = ["exchange", "dataformat_ohlcv", "pairs"]
|
ARGS_LIST_DATA = ["exchange", "dataformat_ohlcv", "pairs", "trading_mode"]
|
||||||
|
|
||||||
ARGS_DOWNLOAD_DATA = ["pairs", "pairs_file", "days", "new_pairs_days", "include_inactive",
|
ARGS_DOWNLOAD_DATA = ["pairs", "pairs_file", "days", "new_pairs_days", "include_inactive",
|
||||||
"timerange", "download_trades", "exchange", "timeframes",
|
"timerange", "download_trades", "exchange", "timeframes",
|
||||||
|
@ -156,7 +156,8 @@ def start_list_data(args: Dict[str, Any]) -> None:
|
|||||||
from freqtrade.data.history.idatahandler import get_datahandler
|
from freqtrade.data.history.idatahandler import get_datahandler
|
||||||
dhc = get_datahandler(config['datadir'], config['dataformat_ohlcv'])
|
dhc = get_datahandler(config['datadir'], config['dataformat_ohlcv'])
|
||||||
|
|
||||||
paircombs = dhc.ohlcv_get_available_data(config['datadir'])
|
# TODO-lev: trading-mode should be parsed at config level, and available as Enum in the config.
|
||||||
|
paircombs = dhc.ohlcv_get_available_data(config['datadir'], config.get('trading_mode', 'spot'))
|
||||||
|
|
||||||
if args['pairs']:
|
if args['pairs']:
|
||||||
paircombs = [comb for comb in paircombs if comb[0] in args['pairs']]
|
paircombs = [comb for comb in paircombs if comb[0] in args['pairs']]
|
||||||
|
@ -21,12 +21,15 @@ class HDF5DataHandler(IDataHandler):
|
|||||||
_columns = DEFAULT_DATAFRAME_COLUMNS
|
_columns = DEFAULT_DATAFRAME_COLUMNS
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def ohlcv_get_available_data(cls, datadir: Path) -> ListPairsWithTimeframes:
|
def ohlcv_get_available_data(cls, datadir: Path, trading_mode: str) -> ListPairsWithTimeframes:
|
||||||
"""
|
"""
|
||||||
Returns a list of all pairs with ohlcv data available in this datadir
|
Returns a list of all pairs with ohlcv data available in this datadir
|
||||||
:param datadir: Directory to search for ohlcv files
|
:param datadir: Directory to search for ohlcv files
|
||||||
|
:param trading_mode: trading-mode to be used
|
||||||
:return: List of Tuples of (pair, timeframe)
|
:return: List of Tuples of (pair, timeframe)
|
||||||
"""
|
"""
|
||||||
|
if trading_mode != 'spot':
|
||||||
|
datadir = datadir.joinpath('futures')
|
||||||
_tmp = [
|
_tmp = [
|
||||||
re.search(
|
re.search(
|
||||||
cls._OHLCV_REGEX, p.name
|
cls._OHLCV_REGEX, p.name
|
||||||
|
@ -38,10 +38,11 @@ class IDataHandler(ABC):
|
|||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
@abstractclassmethod
|
@abstractclassmethod
|
||||||
def ohlcv_get_available_data(cls, datadir: Path) -> ListPairsWithTimeframes:
|
def ohlcv_get_available_data(cls, datadir: Path, trading_mode: str) -> ListPairsWithTimeframes:
|
||||||
"""
|
"""
|
||||||
Returns a list of all pairs with ohlcv data available in this datadir
|
Returns a list of all pairs with ohlcv data available in this datadir
|
||||||
:param datadir: Directory to search for ohlcv files
|
:param datadir: Directory to search for ohlcv files
|
||||||
|
:param trading_mode: trading-mode to be used
|
||||||
:return: List of Tuples of (pair, timeframe)
|
:return: List of Tuples of (pair, timeframe)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -178,6 +179,15 @@ class IDataHandler(ABC):
|
|||||||
"""
|
"""
|
||||||
return trades_remove_duplicates(self._trades_load(pair, timerange=timerange))
|
return trades_remove_duplicates(self._trades_load(pair, timerange=timerange))
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def create_dir_if_needed(cls, datadir: Path):
|
||||||
|
"""
|
||||||
|
Creates datadir if necessary
|
||||||
|
should only create directories for "futures" mode at the moment.
|
||||||
|
"""
|
||||||
|
if not datadir.parent.is_dir():
|
||||||
|
datadir.parent.mkdir()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _pair_data_filename(
|
def _pair_data_filename(
|
||||||
cls,
|
cls,
|
||||||
@ -188,6 +198,7 @@ class IDataHandler(ABC):
|
|||||||
) -> Path:
|
) -> Path:
|
||||||
pair_s = misc.pair_to_filename(pair)
|
pair_s = misc.pair_to_filename(pair)
|
||||||
if candle_type:
|
if candle_type:
|
||||||
|
datadir = datadir.joinpath('futures')
|
||||||
candle_type = f"-{candle_type}"
|
candle_type = f"-{candle_type}"
|
||||||
filename = datadir.joinpath(f'{pair_s}-{timeframe}{candle_type}.{cls._get_file_extension()}')
|
filename = datadir.joinpath(f'{pair_s}-{timeframe}{candle_type}.{cls._get_file_extension()}')
|
||||||
return filename
|
return filename
|
||||||
|
@ -23,12 +23,15 @@ class JsonDataHandler(IDataHandler):
|
|||||||
_columns = DEFAULT_DATAFRAME_COLUMNS
|
_columns = DEFAULT_DATAFRAME_COLUMNS
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def ohlcv_get_available_data(cls, datadir: Path) -> ListPairsWithTimeframes:
|
def ohlcv_get_available_data(cls, datadir: Path, trading_mode: str) -> ListPairsWithTimeframes:
|
||||||
"""
|
"""
|
||||||
Returns a list of all pairs with ohlcv data available in this datadir
|
Returns a list of all pairs with ohlcv data available in this datadir
|
||||||
:param datadir: Directory to search for ohlcv files
|
:param datadir: Directory to search for ohlcv files
|
||||||
|
:param trading_mode: trading-mode to be used
|
||||||
:return: List of Tuples of (pair, timeframe)
|
:return: List of Tuples of (pair, timeframe)
|
||||||
"""
|
"""
|
||||||
|
if trading_mode != 'spot':
|
||||||
|
datadir = datadir.joinpath('futures')
|
||||||
_tmp = [
|
_tmp = [
|
||||||
re.search(
|
re.search(
|
||||||
cls._OHLCV_REGEX, p.name
|
cls._OHLCV_REGEX, p.name
|
||||||
@ -74,6 +77,7 @@ class JsonDataHandler(IDataHandler):
|
|||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
filename = self._pair_data_filename(self._datadir, pair, timeframe, candle_type)
|
filename = self._pair_data_filename(self._datadir, pair, timeframe, candle_type)
|
||||||
|
self.create_dir_if_needed(filename)
|
||||||
_data = data.copy()
|
_data = data.copy()
|
||||||
# Convert date to int
|
# Convert date to int
|
||||||
_data['date'] = _data['date'].view(np.int64) // 1000 // 1000
|
_data['date'] = _data['date'].view(np.int64) // 1000 // 1000
|
||||||
|
@ -254,7 +254,8 @@ def list_available_pairs(timeframe: Optional[str] = None, stake_currency: Option
|
|||||||
|
|
||||||
dh = get_datahandler(config['datadir'], config.get('dataformat_ohlcv', None))
|
dh = get_datahandler(config['datadir'], config.get('dataformat_ohlcv', None))
|
||||||
|
|
||||||
pair_interval = dh.ohlcv_get_available_data(config['datadir'])
|
# TODO-lev: xmatt to decide: use candle-type or market mode for this endpoint??
|
||||||
|
pair_interval = dh.ohlcv_get_available_data(config['datadir'], 'spot')
|
||||||
|
|
||||||
if timeframe:
|
if timeframe:
|
||||||
pair_interval = [pair for pair in pair_interval if pair[1] == timeframe]
|
pair_interval = [pair for pair in pair_interval if pair[1] == timeframe]
|
||||||
|
Loading…
Reference in New Issue
Block a user