Merge pull request #1417 from mishaker/last_candle_close

Adding "copy" as a parameter to klines. default to True
This commit is contained in:
Matthias 2018-12-22 19:14:18 +01:00 committed by GitHub
commit 30fe06aa55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View File

@ -158,9 +158,9 @@ class Exchange(object):
"""exchange ccxt id""" """exchange ccxt id"""
return self._api.id return self._api.id
def klines(self, pair: str) -> DataFrame: def klines(self, pair: str, copy=True) -> DataFrame:
if pair in self._klines: if pair in self._klines:
return self._klines[pair].copy() return self._klines[pair].copy() if copy else self._klines[pair]
else: else:
return None return None

View File

@ -814,6 +814,13 @@ def test_refresh_tickers(mocker, default_conf, caplog) -> None:
assert isinstance(exchange.klines(pair), DataFrame) assert isinstance(exchange.klines(pair), DataFrame)
assert len(exchange.klines(pair)) > 0 assert len(exchange.klines(pair)) > 0
# klines function should return a different object on each call
# if copy is "True"
assert exchange.klines(pair) is not exchange.klines(pair)
assert exchange.klines(pair) is not exchange.klines(pair, copy=True)
assert exchange.klines(pair, copy=True) is not exchange.klines(pair, copy=True)
assert exchange.klines(pair, copy=False) is exchange.klines(pair, copy=False)
# test caching # test caching
exchange.refresh_tickers(['IOTA/ETH', 'XRP/ETH'], '5m') exchange.refresh_tickers(['IOTA/ETH', 'XRP/ETH'], '5m')