Some minor cleanups to trades download methods and docs

This commit is contained in:
Matthias 2019-10-19 10:05:30 +02:00
parent 5b58141f6b
commit fd22c87295
3 changed files with 12 additions and 12 deletions

View File

@ -59,12 +59,12 @@ This will download ticker data for all the currency pairs you defined in `pairs.
### Trades (tick) data ### 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. 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 `<pair>-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 `<pair>-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: 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. 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 !!! 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 ### 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. 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 ## Next step

View File

@ -275,7 +275,8 @@ AVAILABLE_CLI_OPTIONS = {
), ),
"download_trades": Arg( "download_trades": Arg(
'--dl-trades', '--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', action='store_true',
), ),
"exchange": Arg( "exchange": Arg(

View File

@ -754,7 +754,7 @@ class Exchange:
Handles exchange errors, does one call to the exchange. Handles exchange errors, does one call to the exchange.
:param pair: Pair to fetch trade data for :param pair: Pair to fetch trade data for
:param since: Since as integer timestamp in milliseconds :param since: Since as integer timestamp in milliseconds
returns tuple: (pair, ticker_interval, ohlcv_list) returns: List of dicts containing trades
""" """
try: try:
# fetch trades asynchronously # fetch trades asynchronously
@ -790,7 +790,7 @@ class Exchange:
:param since: Since as integer timestamp in milliseconds :param since: Since as integer timestamp in milliseconds
:param until: Until 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. :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] = [] trades: List[Dict] = []
@ -831,7 +831,7 @@ class Exchange:
:param pair: Pair to fetch trade data for :param pair: Pair to fetch trade data for
:param since: Since as integer timestamp in milliseconds :param since: Since as integer timestamp in milliseconds
:param until: Until 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] = [] trades: List[Dict] = []
@ -857,9 +857,6 @@ class Exchange:
""" """
Async wrapper handling downloading trades using either time or id based methods. 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': if self._trades_pagination == 'time':
return await self._async_get_trade_history_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) :param from_id: Download data starting with ID (if id is known)
:returns List of tickers :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( return asyncio.get_event_loop().run_until_complete(
self._async_get_trade_history(pair=pair, since=since, self._async_get_trade_history(pair=pair, since=since,