Merge pull request #1417 from mishaker/last_candle_close
Adding "copy" as a parameter to klines. default to True
This commit is contained in:
commit
30fe06aa55
@ -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
|
||||||
|
|
||||||
|
@ -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')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user