Skip to content
This repository was archived by the owner on Feb 3, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.4.238] - 2024-12-17
### Fixes
[CCXT] fix failed market fetch

## [2.4.237] - 2024-12-12
### Added
[Trades] add get_real_or_estimated_trade_fee
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# OctoBot-Trading [2.4.237](https://github.com/Drakkar-Software/OctoBot-Trading/blob/master/CHANGELOG.md)
# OctoBot-Trading [2.4.238](https://github.com/Drakkar-Software/OctoBot-Trading/blob/master/CHANGELOG.md)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/903b6b22bceb4661b608a86fea655f69)](https://app.codacy.com/gh/Drakkar-Software/OctoBot-Trading?utm_source=github.com&utm_medium=referral&utm_content=Drakkar-Software/OctoBot-Trading&utm_campaign=Badge_Grade_Dashboard)
[![PyPI](https://img.shields.io/pypi/v/OctoBot-Trading.svg)](https://pypi.python.org/pypi/OctoBot-Trading/)
[![Coverage Status](https://coveralls.io/repos/github/Drakkar-Software/OctoBot-Trading/badge.svg?branch=master)](https://coveralls.io/github/Drakkar-Software/OctoBot-Trading?branch=master)
Expand Down
2 changes: 1 addition & 1 deletion octobot_trading/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
# License along with this library.

PROJECT_NAME = "OctoBot-Trading"
VERSION = "2.4.237" # major.minor.revision
VERSION = "2.4.238" # major.minor.revision
6 changes: 6 additions & 0 deletions octobot_trading/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,12 @@ class NetworkError(RetriableFailedRequest):
"""


class FailedMarketStatusRequest(RetriableFailedRequest):
"""
Raised when an exchange fails to fetch its market status
"""


class RateLimitExceeded(OctoBotExchangeError):
"""
Raised upon an exchange API rate limit error
Expand Down
36 changes: 36 additions & 0 deletions octobot_trading/exchanges/connectors/ccxt/ccxt_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ def __init__(
self.is_authenticated: bool = False
self.rest_name: str = rest_name or self.exchange_manager.exchange_class_string
self.force_authentication: bool = force_auth

self._force_next_market_reload: bool = False

# used to save exchange local elements in subclasses
self.saved_data: dict[str, typing.Any] = {}
Expand Down Expand Up @@ -124,6 +126,31 @@ def load_user_inputs_from_class(cls, tentacles_setup_config, tentacle_config):
# no user input in connector
pass

def _ensure_successful_markets_fetch(self, client):
if not client.markets:
return False
symbols = list[str](client.markets)
if self.exchange_manager.is_future:
found_future_markets = False
for symbol in symbols:
if commons_symbols.parse_symbol(symbol).is_future():
found_future_markets = True
break
if not found_future_markets:
raise octobot_trading.errors.FailedMarketStatusRequest(
f"No future markets found for {self.exchange_manager.exchange_name} - {len(symbols)} fetched markets: {symbols}"
)
if not self.exchange_manager.is_future:
found_spot_markets = False
for symbol in symbols:
if commons_symbols.parse_symbol(symbol).is_spot():
found_spot_markets = True
break
if not found_spot_markets:
raise octobot_trading.errors.FailedMarketStatusRequest(
f"No spot markets found for {self.exchange_manager.exchange_name} - {len(symbols)} fetched markets: {symbols}"
)

async def _filtered_if_necessary_load_markets(
self,
client,
Expand All @@ -136,9 +163,14 @@ async def _filtered_if_necessary_load_markets(
await client.load_markets(reload=reload)
else:
await client.load_markets(reload=reload)
self._ensure_successful_markets_fetch(client)
self.logger.info(
f"Loaded {len(client.markets) if client.markets else 0} [{self.exchange_manager.exchange_name}] markets"
)
except octobot_trading.errors.FailedMarketStatusRequest as err:
# failed to fetch markets, force reload for next time
self._force_next_market_reload = True
raise err
except Exception as err:
# ensure this is not a proxy error, raise dedicated error if it is
if proxy_error := ccxt_client_util.get_proxy_error_if_any(self, err):
Expand All @@ -163,6 +195,10 @@ async def load_symbol_markets(
reload=False,
market_filter: typing.Optional[typing.Callable[[dict], bool]] = None
):
if self._force_next_market_reload:
self.logger.info(f"Forced market reload for {self.exchange_manager.exchange_name}")
reload = True
self._force_next_market_reload = False
authenticated_cache = self.exchange_manager.exchange.requires_authentication_for_this_configuration_only()
force_load_markets = reload
if not force_load_markets:
Expand Down
Loading