From 9f2e0b11d19772cfbe165ad6f8e67099ab98c175 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 9 Jun 2019 14:52:17 +0200 Subject: [PATCH] Parametrize ohlcv_candle_limit (per call) --- docs/configuration.md | 7 +++++-- freqtrade/exchange/exchange.py | 11 ++++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/docs/configuration.md b/docs/configuration.md index bbadb87e8..98953d73f 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -309,12 +309,15 @@ Advanced options can be configured using the `_ft_has_params` setting, which wil Available options are listed in the exchange-class as `_ft_has_default`. -For example, to test the order type `FOK` with Kraken: +For example, to test the order type `FOK` with Kraken, and modify candle_limit to 200 (so you only get 200 candles per call): ```json "exchange": { "name": "kraken", - "_ft_has_params": {"order_time_in_force": ["gtc", "fok"]} + "_ft_has_params": { + "order_time_in_force": ["gtc", "fok"], + "ohlcv_candle_limit": 200 + } ``` !!! Warning diff --git a/freqtrade/exchange/exchange.py b/freqtrade/exchange/exchange.py index 401a3571f..ea6996efb 100644 --- a/freqtrade/exchange/exchange.py +++ b/freqtrade/exchange/exchange.py @@ -74,6 +74,7 @@ class Exchange(object): _ft_has_default: Dict = { "stoploss_on_exchange": False, "order_time_in_force": ["gtc"], + "ohlcv_candle_limit": 500, "ohlcv_partial_candle": True, } _ft_has: Dict = {} @@ -112,7 +113,8 @@ class Exchange(object): logger.info("Overriding exchange._ft_has with config params, result: %s", self._ft_has) # Assign this directly for easy access - self._drop_incomplete = self._ft_has['ohlcv_partial_candle'] + self._ohlcv_candle_limit = self._ft_has['ohlcv_candle_limit'] + self._ohlcv_partial_candle = self._ft_has['ohlcv_partial_candle'] # Initialize ccxt objects self._api: ccxt.Exchange = self._init_ccxt( @@ -521,10 +523,8 @@ class Exchange(object): async def _async_get_history(self, pair: str, ticker_interval: str, since_ms: int) -> List: - # Assume exchange returns 500 candles - _LIMIT = 500 - one_call = timeframe_to_msecs(ticker_interval) * _LIMIT + one_call = timeframe_to_msecs(ticker_interval) * self._ohlcv_candle_limit logger.debug( "one_call: %s msecs (%s)", one_call, @@ -581,7 +581,8 @@ class Exchange(object): self._pairs_last_refresh_time[(pair, ticker_interval)] = ticks[-1][0] // 1000 # keeping parsed dataframe in cache self._klines[(pair, ticker_interval)] = parse_ticker_dataframe( - ticks, ticker_interval, fill_missing=True, drop_incomplete=self._drop_incomplete) + ticks, ticker_interval, fill_missing=True, + drop_incomplete=self._ohlcv_partial_candle) return tickers def _now_is_time_to_refresh(self, pair: str, ticker_interval: str) -> bool: