Don't skip trades if the exchange doesn't do inclusive filtering
This commit is contained in:
@@ -2287,6 +2287,9 @@ class Exchange:
|
|||||||
trades: List[List] = []
|
trades: List[List] = []
|
||||||
# DEFAULT_TRADES_COLUMNS: 0 -> timestamp
|
# DEFAULT_TRADES_COLUMNS: 0 -> timestamp
|
||||||
# DEFAULT_TRADES_COLUMNS: 1 -> id
|
# DEFAULT_TRADES_COLUMNS: 1 -> id
|
||||||
|
has_overlap = self._ft_has.get('trades_pagination_overlap', True)
|
||||||
|
# Skip last trade by default since its the key for the next call
|
||||||
|
x = slice(None, -1) if has_overlap else slice(None)
|
||||||
|
|
||||||
if not from_id or not self._valid_trade_pagination_id(pair, from_id):
|
if not from_id or not self._valid_trade_pagination_id(pair, from_id):
|
||||||
# Fetch first elements using timebased method to get an ID to paginate on
|
# Fetch first elements using timebased method to get an ID to paginate on
|
||||||
@@ -2295,19 +2298,19 @@ class Exchange:
|
|||||||
# e.g. Binance returns the "last 1000" candles within a 1h time interval
|
# e.g. Binance returns the "last 1000" candles within a 1h time interval
|
||||||
# - so we will miss the first trades.
|
# - so we will miss the first trades.
|
||||||
t, from_id = await self._async_fetch_trades(pair, since=since)
|
t, from_id = await self._async_fetch_trades(pair, since=since)
|
||||||
trades.extend(t[:-1])
|
trades.extend(t[x])
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
t, from_id_next = await self._async_fetch_trades(
|
t, from_id_next = await self._async_fetch_trades(
|
||||||
pair, params={self._trades_pagination_arg: from_id})
|
pair, params={self._trades_pagination_arg: from_id})
|
||||||
if t:
|
if t:
|
||||||
# Skip last id since its the key for the next call
|
trades.extend(t[x])
|
||||||
trades.extend(t[:-1])
|
|
||||||
if from_id == from_id_next or 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.
|
||||||
trades.extend(t[-1:])
|
if has_overlap:
|
||||||
|
trades.extend(t[-1:])
|
||||||
break
|
break
|
||||||
|
|
||||||
from_id = from_id_next
|
from_id = from_id_next
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ class Kraken(Exchange):
|
|||||||
"ohlcv_has_history": False,
|
"ohlcv_has_history": False,
|
||||||
"trades_pagination": "id",
|
"trades_pagination": "id",
|
||||||
"trades_pagination_arg": "since",
|
"trades_pagination_arg": "since",
|
||||||
|
"trades_pagination_overlap": False,
|
||||||
"mark_ohlcv_timeframe": "4h",
|
"mark_ohlcv_timeframe": "4h",
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,7 +158,7 @@ class Kraken(Exchange):
|
|||||||
|
|
||||||
return fees if is_short else -fees
|
return fees if is_short else -fees
|
||||||
|
|
||||||
def _get_trade_pagination_next_value(self, trades: List[Dict]) -> str:
|
def _get_trade_pagination_next_value(self, trades: List[Dict]):
|
||||||
"""
|
"""
|
||||||
Extract pagination id for the next "from_id" value
|
Extract pagination id for the next "from_id" value
|
||||||
Applies only to fetch_trade_history by id.
|
Applies only to fetch_trade_history by id.
|
||||||
|
|||||||
Reference in New Issue
Block a user