From d211c7583d256401a27f4fa739592f7caa8f19e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Makrnac=C4=B1?= Date: Tue, 25 Nov 2025 00:35:28 +0300 Subject: [PATCH] Update exchange_info.py --- examples/rest_api/market/exchange_info.py | 36 +++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/examples/rest_api/market/exchange_info.py b/examples/rest_api/market/exchange_info.py index 7c2b3b5..903ba29 100644 --- a/examples/rest_api/market/exchange_info.py +++ b/examples/rest_api/market/exchange_info.py @@ -2,7 +2,39 @@ from aster.rest_api import Client from aster.lib.utils import config_logging +# --- Configuration --- +# Set the logging level to DEBUG to capture detailed information, +# including underlying HTTP requests if the 'aster' library supports it. config_logging(logging, logging.DEBUG) -client = Client() -logging.info(client.exchange_info()) +# Get a logger instance for this module +logger = logging.getLogger(__name__) + +# --- Execution --- + +# 1. Initialize the Aster REST API Client. +# Assuming the Client() constructor correctly handles base URLs and default configurations. +logger.info("Initializing Aster REST API client...") +try: + client = Client() + + # 2. Call the public endpoint to retrieve exchange meta information. + # This usually returns supported trading pairs, tick sizes, limits, etc. + logger.info("Fetching exchange information...") + exchange_info = client.exchange_info() + + # 3. Log the retrieved information. + logger.info("Exchange Info Retrieved Successfully (Partial Output):") + # Log the first 500 characters of the output to avoid overwhelming the log, + # but indicate if the output was truncated. + info_str = str(exchange_info) + if len(info_str) > 500: + logger.info(info_str[:500] + '... (Output truncated)') + else: + logger.info(info_str) + +except Exception as e: + logger.error(f"Failed to execute API call or process response: {e}") + +# Note: In a production environment, you would typically pass API keys/secrets +# to the Client() constructor or handle authentication separately.