Pass data_format to methods

This commit is contained in:
Matthias 2019-12-27 13:46:25 +01:00
parent 65f539e9d8
commit 9c5b94adf5
7 changed files with 44 additions and 15 deletions

View File

@ -106,6 +106,8 @@ Mandatory parameters are marked as **Required**, which means that they are requi
| `internals.sd_notify` | Enables use of the sd_notify protocol to tell systemd service manager about changes in the bot state and issue keep-alive pings. See [here](installation.md#7-optional-configure-freqtrade-as-a-systemd-service) for more details. <br> ***Datatype:*** *Boolean* | `internals.sd_notify` | Enables use of the sd_notify protocol to tell systemd service manager about changes in the bot state and issue keep-alive pings. See [here](installation.md#7-optional-configure-freqtrade-as-a-systemd-service) for more details. <br> ***Datatype:*** *Boolean*
| `logfile` | Specifies logfile name. Uses a rolling strategy for log file rotation for 10 files with the 1MB limit per file. <br> ***Datatype:*** *String* | `logfile` | Specifies logfile name. Uses a rolling strategy for log file rotation for 10 files with the 1MB limit per file. <br> ***Datatype:*** *String*
| `user_data_dir` | Directory containing user data. <br> *Defaults to `./user_data/`*. <br> ***Datatype:*** *String* | `user_data_dir` | Directory containing user data. <br> *Defaults to `./user_data/`*. <br> ***Datatype:*** *String*
| `dataformat_ohlcv` | Data format to use to store OHLCV historic data. <br> *Defaults to `json`*. <br> ***Datatype:*** *String*
| `dataformat_trades` | Data format to use to store trades historic data. <br> *Defaults to `jsongz`*. <br> ***Datatype:*** *String*
### Parameters in the strategy ### Parameters in the strategy

View File

@ -51,7 +51,7 @@ ARGS_CONVERT_DATA = ["pairs", "format_from", "format_to"]
ARGS_CONVERT_DATA_OHLCV = ARGS_CONVERT_DATA + ["timeframes"] ARGS_CONVERT_DATA_OHLCV = ARGS_CONVERT_DATA + ["timeframes"]
ARGS_DOWNLOAD_DATA = ["pairs", "pairs_file", "days", "download_trades", "exchange", ARGS_DOWNLOAD_DATA = ["pairs", "pairs_file", "days", "download_trades", "exchange",
"timeframes", "erase"] "timeframes", "erase", "dataformat_ohlcv", "dataformat_trades"]
ARGS_PLOT_DATAFRAME = ["pairs", "indicators1", "indicators2", "plot_limit", ARGS_PLOT_DATAFRAME = ["pairs", "indicators1", "indicators2", "plot_limit",
"db_url", "trade_source", "export", "exportfilename", "db_url", "trade_source", "export", "exportfilename",

View File

@ -344,6 +344,18 @@ AVAILABLE_CLI_OPTIONS = {
choices=constants.AVAILABLE_DATAHANDLERS, choices=constants.AVAILABLE_DATAHANDLERS,
required=True, required=True,
), ),
"dataformat_ohlcv": Arg(
'--data-format',
help='Storage format for downloaded ohlcv data. (default: `%(default)s`).',
choices=constants.AVAILABLE_DATAHANDLERS,
default='json'
),
"dataformat_trades": Arg(
'--data-format-trades',
help='Storage format for downloaded trades data. (default: `%(default)s`).',
choices=constants.AVAILABLE_DATAHANDLERS,
default='jsongz'
),
"exchange": Arg( "exchange": Arg(
'--exchange', '--exchange',
help=f'Exchange name (default: `{constants.DEFAULT_EXCHANGE}`). ' help=f'Exchange name (default: `{constants.DEFAULT_EXCHANGE}`). '

View File

@ -339,9 +339,16 @@ class Configuration:
self._args_to_config(config, argname='days', self._args_to_config(config, argname='days',
logstring='Detected --days: {}') logstring='Detected --days: {}')
self._args_to_config(config, argname='download_trades', self._args_to_config(config, argname='download_trades',
logstring='Detected --dl-trades: {}') logstring='Detected --dl-trades: {}')
self._args_to_config(config, argname='dataformat_ohlcv',
logstring='Using "{}" to store OHLCV data.')
self._args_to_config(config, argname='dataformat_trade',
logstring='Using "{}" to store trades data.')
def _process_runmode(self, config: Dict[str, Any]) -> None: def _process_runmode(self, config: Dict[str, Any]) -> None:
if not self.runmode: if not self.runmode:

View File

@ -216,17 +216,17 @@ CONF_SCHEMA = {
'process_throttle_secs': {'type': 'integer'}, 'process_throttle_secs': {'type': 'integer'},
'interval': {'type': 'integer'}, 'interval': {'type': 'integer'},
'sd_notify': {'type': 'boolean'}, 'sd_notify': {'type': 'boolean'},
'dataformat_ohlcv': { }
'type': 'string', },
'dataformat_ohlcv': {
'type': 'string',
'enum': AVAILABLE_DATAHANDLERS, 'enum': AVAILABLE_DATAHANDLERS,
'default': 'json' 'default': 'json'
}, },
'dataformat_trades': { 'dataformat_trades': {
'type': 'string', 'type': 'string',
'enum': AVAILABLE_DATAHANDLERS, 'enum': AVAILABLE_DATAHANDLERS,
'default': 'jsongz' 'default': 'jsongz'
}
}
} }
}, },
'definitions': { 'definitions': {

View File

@ -178,7 +178,7 @@ def _download_pair_history(datadir: Path,
:param timerange: range of time to download :param timerange: range of time to download
:return: bool with success state :return: bool with success state
""" """
data_handler = get_datahandler(datadir) data_handler = get_datahandler(datadir, data_handler=data_handler)
try: try:
logger.info( logger.info(
@ -327,12 +327,14 @@ def refresh_backtest_trades_data(exchange: Exchange, pairs: List[str], datadir:
def convert_trades_to_ohlcv(pairs: List[str], timeframes: List[str], def convert_trades_to_ohlcv(pairs: List[str], timeframes: List[str],
datadir: Path, timerange: TimeRange, erase=False) -> None: datadir: Path, timerange: TimeRange, erase=False,
data_format_ohlcv: str = 'json',
data_format_trades: str = 'jsongz') -> None:
""" """
Convert stored trades data to ohlcv data Convert stored trades data to ohlcv data
""" """
data_handler_trades = get_datahandler(datadir, data_format='jsongz') data_handler_trades = get_datahandler(datadir, data_format=data_format_trades)
data_handler_ohlcv = get_datahandler(datadir, data_format='json') data_handler_ohlcv = get_datahandler(datadir, data_format=data_format_ohlcv)
for pair in pairs: for pair in pairs:
trades = data_handler_trades.trades_load(pair) trades = data_handler_trades.trades_load(pair)

View File

@ -204,16 +204,22 @@ def start_download_data(args: Dict[str, Any]) -> None:
if config.get('download_trades'): if config.get('download_trades'):
pairs_not_available = refresh_backtest_trades_data( pairs_not_available = refresh_backtest_trades_data(
exchange, pairs=config["pairs"], datadir=config['datadir'], exchange, pairs=config["pairs"], datadir=config['datadir'],
timerange=timerange, erase=config.get("erase")) timerange=timerange, erase=config.get("erase"),
data_format=config['dataformat_trades'])
# Convert downloaded trade data to different timeframes # Convert downloaded trade data to different timeframes
convert_trades_to_ohlcv( convert_trades_to_ohlcv(
pairs=config["pairs"], timeframes=config["timeframes"], pairs=config["pairs"], timeframes=config["timeframes"],
datadir=config['datadir'], timerange=timerange, erase=config.get("erase")) datadir=config['datadir'], timerange=timerange, erase=config.get("erase"),
data_format_ohlcv=config['dataformat_ohlcv'],
data_format_trades=config['dataformat_trades'],
)
else: else:
pairs_not_available = refresh_backtest_ohlcv_data( pairs_not_available = refresh_backtest_ohlcv_data(
exchange, pairs=config["pairs"], timeframes=config["timeframes"], exchange, pairs=config["pairs"], timeframes=config["timeframes"],
datadir=config['datadir'], timerange=timerange, erase=config.get("erase")) datadir=config['datadir'], timerange=timerange, erase=config.get("erase"),
data_format=config['dataformat_ohlcv'])
except KeyboardInterrupt: except KeyboardInterrupt:
sys.exit("SIGINT received, aborting ...") sys.exit("SIGINT received, aborting ...")