From e4a439ea9227bf3171d48a9d146bb25ddc98d320 Mon Sep 17 00:00:00 2001 From: Tomortec Date: Fri, 27 Jun 2025 23:07:45 +0800 Subject: [PATCH] fix: unexpected recusion caused by same name functions --- tradingagents/dataflows/__init__.py | 6 ++---- tradingagents/dataflows/binance_utils.py | 14 +++++++------- tradingagents/dataflows/blockbeats_utils.py | 2 +- tradingagents/dataflows/coindesk_utils.py | 2 +- tradingagents/dataflows/interface.py | 8 ++++---- 5 files changed, 15 insertions(+), 17 deletions(-) diff --git a/tradingagents/dataflows/__init__.py b/tradingagents/dataflows/__init__.py index 0ff6e10f..e10e0873 100644 --- a/tradingagents/dataflows/__init__.py +++ b/tradingagents/dataflows/__init__.py @@ -1,8 +1,6 @@ -from .blockbeats_utils import get_blockbeats_news -from .coindesk_utils import get_coindesk_news -from .finnhub_utils import get_data_in_range +from .blockbeats_utils import fetch_news_from_blockbeats +from .coindesk_utils import fetch_news_from_coindesk from .googlenews_utils import getNewsData -from .yfin_utils import YFinanceUtils from .binance_utils import * from .reddit_utils import fetch_top_from_category from .stockstats_utils import StockstatsUtils diff --git a/tradingagents/dataflows/binance_utils.py b/tradingagents/dataflows/binance_utils.py index 46da0334..b3af8a6a 100644 --- a/tradingagents/dataflows/binance_utils.py +++ b/tradingagents/dataflows/binance_utils.py @@ -3,7 +3,7 @@ from binance.um_futures import UMFutures um_futures_client = UMFutures() -def get_binance_klines(symbol: str, interval: str, limit: int = 75): +def fetch_klines_from_binance(symbol: str, interval: str, limit: int = 75): """ Fetch historical klines (candlestick data) from Binance. @@ -14,7 +14,7 @@ def get_binance_klines(symbol: str, interval: str, limit: int = 75): """ return um_futures_client.klines(symbol=symbol, interval=interval, limit=limit) -def get_binance_depth(symbol: str, limit: int = 50): +def fetch_depth_from_binance(symbol: str, limit: int = 50): """ Fetch the order book depth from Binance. @@ -24,7 +24,7 @@ def get_binance_depth(symbol: str, limit: int = 50): """ return um_futures_client.depth(symbol=symbol, limit=limit) -def get_binance_24hr_pricechange(symbol: str): +def fetch_24hr_pricechange_from_binance(symbol: str): """ Fetch 24-hour ticker price change statistics from Binance. @@ -33,7 +33,7 @@ def get_binance_24hr_pricechange(symbol: str): """ return um_futures_client.ticker_24hr_price_change(symbol=symbol) -def get_binance_toplongshort_position_ratio(symbol: str, period: str, limit: int = 50): +def fetch_toplongshort_position_ratio_from_binance(symbol: str, period: str, limit: int = 50): """ Fetch the top long/short position ratio from Binance. @@ -44,7 +44,7 @@ def get_binance_toplongshort_position_ratio(symbol: str, period: str, limit: int """ return um_futures_client.top_long_short_position_ratio(symbol=symbol, period=period, limit=limit) -def get_binance_toplongshort_account_ratio(symbol: str, period: str, limit: int = 50): +def fetch_toplongshort_account_ratio_from_binance(symbol: str, period: str, limit: int = 50): """ Fetch the top long/short account ratio from Binance. @@ -55,7 +55,7 @@ def get_binance_toplongshort_account_ratio(symbol: str, period: str, limit: int """ return um_futures_client.top_long_short_account_ratio(symbol=symbol, period=period, limit=limit) -def get_binance_global_longshort_account_ratio(symbol: str, period: str, limit: int = 50): +def fetch_global_longshort_account_ratio_from_binance(symbol: str, period: str, limit: int = 50): """ Fetch the global long/short account ratio from Binance. @@ -66,7 +66,7 @@ def get_binance_global_longshort_account_ratio(symbol: str, period: str, limit: """ return um_futures_client.long_short_account_ratio(symbol=symbol, period=period, limit=limit) -def get_binance_taker_longshort_ratio(symbol: str, period: str, limit: int = 50): +def fetch_taker_longshort_ratio_from_binance(symbol: str, period: str, limit: int = 50): """ Fetch the taker long/short ratio from Binance. diff --git a/tradingagents/dataflows/blockbeats_utils.py b/tradingagents/dataflows/blockbeats_utils.py index 8205916f..7c3c1546 100644 --- a/tradingagents/dataflows/blockbeats_utils.py +++ b/tradingagents/dataflows/blockbeats_utils.py @@ -1,7 +1,7 @@ import requests -def get_blockbeats_news(count = 10): +def fetch_news_from_blockbeats(count = 10): url = f"https://api.theblockbeats.news/v1/open-api/open-flash?page=1&size={count}&type=push&lang=cn" response = requests.get(url) if response.status_code == 200: diff --git a/tradingagents/dataflows/coindesk_utils.py b/tradingagents/dataflows/coindesk_utils.py index 5382fb87..b0f093b4 100644 --- a/tradingagents/dataflows/coindesk_utils.py +++ b/tradingagents/dataflows/coindesk_utils.py @@ -2,7 +2,7 @@ import os import requests -def get_coindesk_news(tickers=[], count=10) -> list[dict[str, str]]: +def fetch_news_from_coindesk(tickers=[], count=10) -> list[dict[str, str]]: """ Fetches the latest news from Coindesk for a given ticker. diff --git a/tradingagents/dataflows/interface.py b/tradingagents/dataflows/interface.py index 2058b0ce..d0130a12 100644 --- a/tradingagents/dataflows/interface.py +++ b/tradingagents/dataflows/interface.py @@ -1,6 +1,6 @@ from typing import Annotated, Dict -from .blockbeats_utils import get_blockbeats_news -from .coindesk_utils import get_coindesk_news +from .blockbeats_utils import fetch_news_from_blockbeats +from .coindesk_utils import fetch_news_from_coindesk from .reddit_utils import fetch_top_from_category from .yfin_utils import * from .stockstats_utils import * @@ -29,7 +29,7 @@ def get_blockbeats_news(count: Annotated[int, "news' count, no more than 50"] = if count > 50: raise ValueError("Count should not be more than 50") - news = get_blockbeats_news(count) + news = fetch_news_from_blockbeats(count) if len(news) == 0: return "" @@ -54,7 +54,7 @@ def get_coindesk_news( Returns: str: A formatted string containing the latest news articles and meta information. """ - news = get_coindesk_news(tickers, count) + news = fetch_news_from_coindesk(tickers, count) if len(news) == 0: return ""