Parametrize ohlcv_candle_limit (per call)

This commit is contained in:
Matthias 2019-06-09 14:52:17 +02:00
parent 3380543878
commit 9f2e0b11d1
2 changed files with 11 additions and 7 deletions

View File

@ -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`. 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 ```json
"exchange": { "exchange": {
"name": "kraken", "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 !!! Warning

View File

@ -74,6 +74,7 @@ class Exchange(object):
_ft_has_default: Dict = { _ft_has_default: Dict = {
"stoploss_on_exchange": False, "stoploss_on_exchange": False,
"order_time_in_force": ["gtc"], "order_time_in_force": ["gtc"],
"ohlcv_candle_limit": 500,
"ohlcv_partial_candle": True, "ohlcv_partial_candle": True,
} }
_ft_has: Dict = {} _ft_has: Dict = {}
@ -112,7 +113,8 @@ class Exchange(object):
logger.info("Overriding exchange._ft_has with config params, result: %s", self._ft_has) logger.info("Overriding exchange._ft_has with config params, result: %s", self._ft_has)
# Assign this directly for easy access # 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 # Initialize ccxt objects
self._api: ccxt.Exchange = self._init_ccxt( self._api: ccxt.Exchange = self._init_ccxt(
@ -521,10 +523,8 @@ class Exchange(object):
async def _async_get_history(self, pair: str, async def _async_get_history(self, pair: str,
ticker_interval: str, ticker_interval: str,
since_ms: int) -> List: 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( logger.debug(
"one_call: %s msecs (%s)", "one_call: %s msecs (%s)",
one_call, one_call,
@ -581,7 +581,8 @@ class Exchange(object):
self._pairs_last_refresh_time[(pair, ticker_interval)] = ticks[-1][0] // 1000 self._pairs_last_refresh_time[(pair, ticker_interval)] = ticks[-1][0] // 1000
# keeping parsed dataframe in cache # keeping parsed dataframe in cache
self._klines[(pair, ticker_interval)] = parse_ticker_dataframe( 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 return tickers
def _now_is_time_to_refresh(self, pair: str, ticker_interval: str) -> bool: def _now_is_time_to_refresh(self, pair: str, ticker_interval: str) -> bool: