mirror of
https://github.com/freqtrade/freqtrade.git
synced 2025-12-14 11:51:19 +00:00
refactor: fetch_orders pagination to base class
This commit is contained in:
@@ -155,6 +155,7 @@ class Exchange:
|
||||
"ccxt_futures_name": "swap",
|
||||
"needs_trading_fees": False, # use fetch_trading_fees to cache fees
|
||||
"order_props_in_contracts": ["amount", "filled", "remaining"],
|
||||
"fetch_orders_limit_minutes": None, # "fetch_orders" is not time-limited by default
|
||||
# Override createMarketBuyOrderRequiresPrice where ccxt has it wrong
|
||||
"marketOrderRequiresPrice": False,
|
||||
"exchange_has_overrides": {}, # Dictionary overriding ccxt's "has".
|
||||
@@ -1742,7 +1743,7 @@ class Exchange:
|
||||
return orders
|
||||
|
||||
@retrier(retries=0)
|
||||
def fetch_orders(
|
||||
def _fetch_orders(
|
||||
self, pair: str, since: datetime, params: dict | None = None
|
||||
) -> list[CcxtOrder]:
|
||||
"""
|
||||
@@ -1781,6 +1782,22 @@ class Exchange:
|
||||
except ccxt.BaseError as e:
|
||||
raise OperationalException(e) from e
|
||||
|
||||
def fetch_orders(
|
||||
self, pair: str, since: datetime, params: dict | None = None
|
||||
) -> list[CcxtOrder]:
|
||||
if self._config["dry_run"]:
|
||||
return []
|
||||
if (limit := self._ft_has.get("fetch_orders_limit_minutes")) is not None:
|
||||
orders = []
|
||||
while since < dt_now():
|
||||
until = since + timedelta(minutes=limit - 1)
|
||||
orders += self._fetch_orders(pair, since, params={"until": dt_ts(until)})
|
||||
since = until
|
||||
return orders
|
||||
|
||||
else:
|
||||
return self._fetch_orders(pair, since, params=params)
|
||||
|
||||
@retrier
|
||||
def fetch_trading_fees(self) -> dict[str, Any]:
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user