Attempt to reduce diff as much as possible

This commit is contained in:
Matthias
2024-04-05 06:53:48 +02:00
parent 34d3389b23
commit e0f1b1e48e
+10 -17
View File
@@ -2520,13 +2520,10 @@ class Exchange:
else: else:
return trades[-1].get('timestamp') return trades[-1].get('timestamp')
async def _async_get_trade_history_id( async def _async_get_trade_history_id(self, pair: str,
self, until: int,
pair: str, since: Optional[int] = None,
until: Optional[int], from_id: Optional[str] = None) -> Tuple[str, List[List]]:
since: Optional[int] = None,
from_id: Optional[str] = None
) -> Tuple[str, List[List]]:
""" """
Asyncronously gets trade history using fetch_trades Asyncronously gets trade history using fetch_trades
use this when exchange uses id-based iteration (check `self._trades_pagination`) use this when exchange uses id-based iteration (check `self._trades_pagination`)
@@ -2558,7 +2555,7 @@ class Exchange:
pair, params={self._trades_pagination_arg: from_id}) pair, params={self._trades_pagination_arg: from_id})
if t: if t:
trades.extend(t[x]) trades.extend(t[x])
if from_id == from_id_next or (until and t[-1][0] > until): if from_id == from_id_next or t[-1][0] > until:
logger.debug(f"Stopping because from_id did not change. " logger.debug(f"Stopping because from_id did not change. "
f"Reached {t[-1][0]} > {until}") f"Reached {t[-1][0]} > {until}")
# Reached the end of the defined-download period - add last trade as well. # Reached the end of the defined-download period - add last trade as well.
@@ -2618,8 +2615,7 @@ class Exchange:
async def _async_get_trade_history(self, pair: str, async def _async_get_trade_history(self, pair: str,
since: Optional[int] = None, since: Optional[int] = None,
until: Optional[int] = None, until: Optional[int] = None,
from_id: Optional[str] = None, from_id: Optional[str] = None) -> Tuple[str, List[List]]:
) -> Tuple[str, List[List]]:
""" """
Async wrapper handling downloading trades using either time or id based methods. Async wrapper handling downloading trades using either time or id based methods.
""" """
@@ -2630,12 +2626,13 @@ class Exchange:
if until is None: if until is None:
until = ccxt.Exchange.milliseconds() until = ccxt.Exchange.milliseconds()
logger.debug(f"Exchange milliseconds: {until}") logger.debug(f"Exchange milliseconds: {until}")
if self._trades_pagination == 'time': if self._trades_pagination == 'time':
return await self._async_get_trade_history_time( return await self._async_get_trade_history_time(
pair=pair, since=since, until=until) pair=pair, since=since, until=until)
elif self._trades_pagination == 'id': elif self._trades_pagination == 'id':
return await self._async_get_trade_history_id( return await self._async_get_trade_history_id(
pair=pair, since=since, until=until, from_id=from_id, pair=pair, since=since, until=until, from_id=from_id
) )
else: else:
raise OperationalException(f"Exchange {self.name} does use neither time, " raise OperationalException(f"Exchange {self.name} does use neither time, "
@@ -2644,8 +2641,7 @@ class Exchange:
def get_historic_trades(self, pair: str, def get_historic_trades(self, pair: str,
since: Optional[int] = None, since: Optional[int] = None,
until: Optional[int] = None, until: Optional[int] = None,
from_id: Optional[str] = None, from_id: Optional[str] = None) -> Tuple[str, List]:
) -> Tuple[str, List]:
""" """
Get trade history data using asyncio. Get trade history data using asyncio.
Handles all async work and returns the list of candles. Handles all async work and returns the list of candles.
@@ -2661,10 +2657,7 @@ class Exchange:
with self._loop_lock: with self._loop_lock:
task = asyncio.ensure_future(self._async_get_trade_history( task = asyncio.ensure_future(self._async_get_trade_history(
pair=pair, pair=pair, since=since, until=until, from_id=from_id))
since=since,
until=until,
from_id=from_id))
for sig in [signal.SIGINT, signal.SIGTERM]: for sig in [signal.SIGINT, signal.SIGTERM]:
try: try: