Merge pull request #1581 from hroff-1902/patch-11
Minor changes to exchange
This commit is contained in:
commit
e309f75118
@ -159,7 +159,6 @@ class Exchange(object):
|
|||||||
return self._api.id
|
return self._api.id
|
||||||
|
|
||||||
def klines(self, pair_interval: Tuple[str, str], copy=True) -> DataFrame:
|
def klines(self, pair_interval: Tuple[str, str], copy=True) -> DataFrame:
|
||||||
# create key tuple
|
|
||||||
if pair_interval in self._klines:
|
if pair_interval in self._klines:
|
||||||
return self._klines[pair_interval].copy() if copy else self._klines[pair_interval]
|
return self._klines[pair_interval].copy() if copy else self._klines[pair_interval]
|
||||||
else:
|
else:
|
||||||
@ -540,14 +539,10 @@ class Exchange(object):
|
|||||||
|
|
||||||
input_coroutines = []
|
input_coroutines = []
|
||||||
|
|
||||||
# Gather corotines to run
|
# Gather coroutines to run
|
||||||
for pair, ticker_interval in set(pair_list):
|
for pair, ticker_interval in set(pair_list):
|
||||||
# Calculating ticker interval in second
|
if not ((pair, ticker_interval) in self._klines) \
|
||||||
interval_in_sec = constants.TICKER_INTERVAL_MINUTES[ticker_interval] * 60
|
or self._now_is_time_to_refresh(pair, ticker_interval):
|
||||||
|
|
||||||
if not ((self._pairs_last_refresh_time.get((pair, ticker_interval), 0)
|
|
||||||
+ interval_in_sec) >= arrow.utcnow().timestamp
|
|
||||||
and (pair, ticker_interval) in self._klines):
|
|
||||||
input_coroutines.append(self._async_get_candle_history(pair, ticker_interval))
|
input_coroutines.append(self._async_get_candle_history(pair, ticker_interval))
|
||||||
else:
|
else:
|
||||||
logger.debug("Using cached ohlcv data for %s, %s ...", pair, ticker_interval)
|
logger.debug("Using cached ohlcv data for %s, %s ...", pair, ticker_interval)
|
||||||
@ -571,6 +566,13 @@ class Exchange(object):
|
|||||||
ticks, tick_interval, fill_missing=True)
|
ticks, tick_interval, fill_missing=True)
|
||||||
return tickers
|
return tickers
|
||||||
|
|
||||||
|
def _now_is_time_to_refresh(self, pair: str, ticker_interval: str) -> bool:
|
||||||
|
# Calculating ticker interval in seconds
|
||||||
|
interval_in_sec = constants.TICKER_INTERVAL_MINUTES[ticker_interval] * 60
|
||||||
|
|
||||||
|
return not ((self._pairs_last_refresh_time.get((pair, ticker_interval), 0)
|
||||||
|
+ interval_in_sec) >= arrow.utcnow().timestamp)
|
||||||
|
|
||||||
@retrier_async
|
@retrier_async
|
||||||
async def _async_get_candle_history(self, pair: str, tick_interval: str,
|
async def _async_get_candle_history(self, pair: str, tick_interval: str,
|
||||||
since_ms: Optional[int] = None) -> Tuple[str, str, List]:
|
since_ms: Optional[int] = None) -> Tuple[str, str, List]:
|
||||||
|
Loading…
Reference in New Issue
Block a user