mirror of
https://github.com/TauricResearch/TradingAgents.git
synced 2026-09-28 15:32:35 +03:00
style: normalise blank lines between definitions
- two between top-level definitions, one between methods, none doubled inside a body
This commit is contained in:
@@ -156,6 +156,7 @@ VENDOR_METHODS = {
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
def get_category_for_method(method: str) -> str:
|
||||
"""Get the category that contains the specified method."""
|
||||
for category, info in TOOLS_CATEGORIES.items():
|
||||
@@ -163,6 +164,7 @@ def get_category_for_method(method: str) -> str:
|
||||
return category
|
||||
raise ValueError(f"Method '{method}' not found in any category")
|
||||
|
||||
|
||||
def get_vendor(category: str, method: str = None) -> str:
|
||||
"""Get the configured vendor for a data category or specific tool method.
|
||||
Tool-level configuration takes precedence over category-level.
|
||||
@@ -178,6 +180,7 @@ def get_vendor(category: str, method: str = None) -> str:
|
||||
# Fall back to category-level configuration
|
||||
return config.get("data_vendors", {}).get(category, "default")
|
||||
|
||||
|
||||
def route_to_vendor(method: str, *args, **kwargs):
|
||||
"""Route method calls to appropriate vendor implementation with fallback support."""
|
||||
category = get_category_for_method(method)
|
||||
|
||||
+3
-1
@@ -34,6 +34,7 @@ def get_api_key() -> str:
|
||||
)
|
||||
return api_key
|
||||
|
||||
|
||||
def format_datetime_for_api(date_input, end_of_day: bool = False) -> str:
|
||||
"""Convert various date formats to the YYYYMMDDTHHMM Alpha Vantage expects.
|
||||
|
||||
@@ -60,10 +61,12 @@ def format_datetime_for_api(date_input, end_of_day: bool = False) -> str:
|
||||
else:
|
||||
raise ValueError(f"Date must be string or datetime object, got {type(date_input)}")
|
||||
|
||||
|
||||
class AlphaVantageRateLimitError(VendorRateLimitError):
|
||||
"""Raised when the Alpha Vantage API rate limit is exceeded."""
|
||||
pass
|
||||
|
||||
|
||||
def _make_api_request(function_name: str, params: dict) -> dict | str:
|
||||
"""Helper function to make API requests and handle responses.
|
||||
|
||||
@@ -119,7 +122,6 @@ def _make_api_request(function_name: str, params: dict) -> dict | str:
|
||||
return response_text
|
||||
|
||||
|
||||
|
||||
def _filter_csv_by_date_range(csv_data: str, start_date: str, end_date: str) -> str:
|
||||
"""
|
||||
Filter CSV data to include only rows within the specified date range.
|
||||
|
||||
@@ -32,6 +32,7 @@ def get_news(ticker, start_date, end_date) -> dict[str, str] | str:
|
||||
|
||||
return _make_api_request("NEWS_SENTIMENT", params)
|
||||
|
||||
|
||||
def get_global_news(curr_date, look_back_days: int | None = None, limit: int | None = None) -> dict[str, str] | str:
|
||||
"""Returns global market news & sentiment data without ticker-specific filtering.
|
||||
|
||||
|
||||
+1
@@ -64,6 +64,7 @@ def _coverage_dates(posts) -> list:
|
||||
dates.append(datetime.now(timezone.utc) - _SEARCH_LOOKBACK)
|
||||
return dates
|
||||
|
||||
|
||||
_RSS = "https://www.reddit.com/r/{sub}/search.rss?{qs}"
|
||||
# A descriptive, identified User-Agent (per Reddit's API etiquette). Reddit
|
||||
# blocks generic/anonymous tokens like bare "Mozilla/5.0" or "curl/…" but
|
||||
|
||||
+1
-1
@@ -69,6 +69,7 @@ def get_YFin_data_online(
|
||||
|
||||
return header + csv_string
|
||||
|
||||
|
||||
def get_stock_stats_indicators_window(
|
||||
symbol: Annotated[str, "ticker symbol of the company"],
|
||||
indicator: Annotated[str, "technical indicator to get the analysis and report of"],
|
||||
@@ -269,7 +270,6 @@ def get_stockstats_indicator(
|
||||
return str(indicator_value)
|
||||
|
||||
|
||||
|
||||
def get_closes(symbol: str, start_date: str, end_date: str) -> pd.Series:
|
||||
"""Daily closes from ``start_date`` up to, not including, ``end_date``."""
|
||||
canonical = normalize_symbol(symbol)
|
||||
|
||||
Reference in New Issue
Block a user