From fd22c87295c6f059220bbed5a06271ec2096f4b2 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 19 Oct 2019 10:05:30 +0200 Subject: [PATCH] Some minor cleanups to trades download methods and docs --- docs/data-download.md | 10 +++++----- freqtrade/configuration/cli_options.py | 3 ++- freqtrade/exchange/exchange.py | 11 +++++------ 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/data-download.md b/docs/data-download.md index 83f5cd568..bf4792ea3 100644 --- a/docs/data-download.md +++ b/docs/data-download.md @@ -59,12 +59,12 @@ This will download ticker data for all the currency pairs you defined in `pairs. ### Trades (tick) data -By default, download-data downloads Candles (OHLCV) data. Some exchanges also provide historic trade-data via their API. +By default, `download-data` subcommand downloads Candles (OHLCV) data. Some exchanges also provide historic trade-data via their API. This data can be useful if you need many different timeframes, since it is only downloaded once, and then resampled locally to the desired timeframes. -Since this data is large by default, the files use gzip by default. They are stored in your data-directory with the naming convention of `-trades.json.gz` (`ETH_BTC_trades.json.gz`). Incremental mode is supported, so downloading the data once per week with `--days 8` will create an incremental data-repository. +Since this data is large by default, the files use gzip by default. They are stored in your data-directory with the naming convention of `-trades.json.gz` (`ETH_BTC-trades.json.gz`). Incremental mode is also supported, as for historic OHLCV data, so downloading the data once per week with `--days 8` will create an incremental data-repository. -To use this mode, simply add `--dl-trades` to your call. This will swap the download-method to trades, and resamples the data locally. +To use this mode, simply add `--dl-trades` to your call. This will swap the download method to download trades, and resamples the data locally. Example call: @@ -76,11 +76,11 @@ freqtrade download-data --exchange binance --pairs XRP/ETH ETH/BTC --days 20 --d While this method uses async calls, it will be slow, since it requires the result of the previous call to generate the next request to the exchange. !!! Warning - This datatype is not available during trading. It probably will never be since all exchanges tested don't provide this data in real time, but with a delay of a few 100 candles. + The historic trades are not available during Freqtrade dry-run and live trade modes because all exchanges tested provide this data with a delay of few 100 candles, so it's not suitable for real-time trading. ### Historic Kraken data -The Kraken API does only provide 720 historic candles, which is sufficient for regular trading operations, but is a problem for backtesting. +The Kraken API does only provide 720 historic candles, which is sufficient for FreqTrade dry-run and live trade modes, but is a problem for backtesting. To download data for the Kraken exchange, using `--dl-trades` is mandatory, otherwise the bot will download the same 720 candles over and over, and you'll not have enough backtest data. ## Next step diff --git a/freqtrade/configuration/cli_options.py b/freqtrade/configuration/cli_options.py index 9868ab874..650123127 100644 --- a/freqtrade/configuration/cli_options.py +++ b/freqtrade/configuration/cli_options.py @@ -275,7 +275,8 @@ AVAILABLE_CLI_OPTIONS = { ), "download_trades": Arg( '--dl-trades', - help='Download trades instead of OHLCV data.', + help='Download trades instead of OHLCV data. The bot will resample trades to the ' + 'desired timeframe as specified as --timeframes/-t.', action='store_true', ), "exchange": Arg( diff --git a/freqtrade/exchange/exchange.py b/freqtrade/exchange/exchange.py index 86078ae05..f8d3d840a 100644 --- a/freqtrade/exchange/exchange.py +++ b/freqtrade/exchange/exchange.py @@ -754,7 +754,7 @@ class Exchange: Handles exchange errors, does one call to the exchange. :param pair: Pair to fetch trade data for :param since: Since as integer timestamp in milliseconds - returns tuple: (pair, ticker_interval, ohlcv_list) + returns: List of dicts containing trades """ try: # fetch trades asynchronously @@ -790,7 +790,7 @@ class Exchange: :param since: Since as integer timestamp in milliseconds :param until: Until as integer timestamp in milliseconds :param from_id: Download data starting with ID (if id is known). Ignores "since" if set. - returns tuple: (pair, ticker_interval, ohlcv_list) + returns tuple: (pair, trades-list) """ trades: List[Dict] = [] @@ -831,7 +831,7 @@ class Exchange: :param pair: Pair to fetch trade data for :param since: Since as integer timestamp in milliseconds :param until: Until as integer timestamp in milliseconds - returns tuple: (pair, ticker_interval, ohlcv_list) + returns tuple: (pair, trades-list) """ trades: List[Dict] = [] @@ -857,9 +857,6 @@ class Exchange: """ Async wrapper handling downloading trades using either time or id based methods. """ - if not self.exchange_has("fetchTrades"): - # TODO: Maybe don't stop the bot ... ? - raise OperationalException("This exchange does not suport downloading Trades.") if self._trades_pagination == 'time': return await self._async_get_trade_history_time( @@ -889,6 +886,8 @@ class Exchange: :param from_id: Download data starting with ID (if id is known) :returns List of tickers """ + if not self.exchange_has("fetchTrades"): + raise OperationalException("This exchange does not suport downloading Trades.") return asyncio.get_event_loop().run_until_complete( self._async_get_trade_history(pair=pair, since=since,