#
tokens: 35017/50000 1/36 files (page 4/4)
lines: on (toggle) GitHub
raw markdown copy reset
This is page 4 of 4. Use http://codebase.md/calvernaz/alphavantage?lines=true&page={x} to view the full context.

# Directory Structure

```
├── .bumpversion.cfg
├── .github
│   ├── FUNDING.yml
│   └── workflows
│       └── publish.yml
├── .gitignore
├── .python-version
├── CONTRIBUTING.md
├── deploy
│   └── aws-stateless-mcp-lambda
│       ├── .aws-sam
│       │   └── build.toml
│       ├── deploy.sh
│       ├── lambda_function.py
│       ├── README.md
│       ├── requirements.txt
│       └── template.yaml
├── DEVELOPMENT.md
├── Dockerfile
├── LICENSE
├── pyproject.toml
├── pytest.ini
├── README.md
├── scripts
│   └── publish.py
├── smithery.yaml
├── src
│   ├── alphavantage_mcp_client
│   │   └── client.py
│   └── alphavantage_mcp_server
│       ├── __init__.py
│       ├── __main__.py
│       ├── api.py
│       ├── oauth.py
│       ├── prompts.py
│       ├── response_utils.py
│       ├── server.py
│       ├── telemetry_bootstrap.py
│       ├── telemetry_instrument.py
│       └── tools.py
├── tests
│   ├── test_api.py
│   ├── test_http_mcp_client.py
│   ├── test_http_transport.py
│   ├── test_integration.py
│   ├── test_stdio_transport.py
│   └── test_telemetry.py
└── uv.lock
```

# Files

--------------------------------------------------------------------------------
/src/alphavantage_mcp_server/api.py:
--------------------------------------------------------------------------------

```python
   1 | import os
   2 | 
   3 | import httpx
   4 | from dotenv import load_dotenv
   5 | 
   6 | from .telemetry_instrument import instrument_tool
   7 | 
   8 | load_dotenv()
   9 | 
  10 | API_KEY = os.getenv("ALPHAVANTAGE_API_KEY")
  11 | if not API_KEY:
  12 |     raise ValueError("ALPHAVANTAGE_API_KEY environment variable required")
  13 | 
  14 | API_BASE_URL = "https://www.alphavantage.co/query"
  15 | 
  16 | 
  17 | async def _make_api_request(
  18 |     https_params: dict[str, str], datatype: str
  19 | ) -> dict[str, str] | str:
  20 |     async with httpx.AsyncClient() as client:
  21 |         response = await client.get(API_BASE_URL, params=https_params)
  22 |         response.raise_for_status()
  23 |         return response.text if datatype == "csv" else response.json()
  24 | 
  25 | 
  26 | #####
  27 | # Core Stock APIs
  28 | #####
  29 | @instrument_tool("time_series_intraday")
  30 | async def fetch_intraday(
  31 |     symbol: str,
  32 |     interval: str = "60min",
  33 |     datatype: str = "json",
  34 |     adjusted: bool = True,
  35 |     extended_hours: bool = True,
  36 |     outputsize: str = "compact",
  37 |     month: str = None,
  38 | ) -> dict[str, str] | str:
  39 |     """
  40 |     Fetch intraday stock data from the Alpha Vantage API.
  41 | 
  42 |     :argument: symbol (str): The stock symbol to fetch.
  43 |     :argument: interval (str): The time interval for the data (default: "5min").
  44 |     :argument: datatype (str): The response data type (default: "json").
  45 |     :argument: adjusted (bool): The adjusted data flag (default: True).
  46 |     :argument: extended_hours (bool): The extended hours flag (default: True).
  47 |     :argument: outputsize (str): The output size for the data (default: "compact").
  48 |     :argument: month (str): The month of the data (default: None).
  49 | 
  50 |     :returns: The intraday stock data.
  51 |     """
  52 | 
  53 |     https_params = {
  54 |         "function": "TIME_SERIES_INTRADAY",
  55 |         "symbol": symbol,
  56 |         "interval": interval,
  57 |         "datatype": datatype,
  58 |         "adjusted": adjusted,
  59 |         "outputsize": outputsize,
  60 |         "extended_hours": extended_hours,
  61 |         "month": month,
  62 |         "apikey": API_KEY,
  63 |     }
  64 | 
  65 |     return await _make_api_request(https_params, datatype)
  66 | 
  67 | 
  68 | @instrument_tool("time_series_daily")
  69 | async def fetch_time_series_daily(
  70 |     symbol: str, datatype: str = "json", outputsize: str = "compact"
  71 | ) -> dict[str, str] | str:
  72 |     """
  73 |     Fetch daily stock data from the Alpha Vantage API.
  74 | 
  75 |     :argument: symbol (str): The stock symbol to fetch.
  76 |     :argument: datatype (str): The response data type (default: "json").
  77 | 
  78 |     :returns: The daily stock data.
  79 |     """
  80 | 
  81 |     https_params = {
  82 |         "function": "TIME_SERIES_DAILY",
  83 |         "symbol": symbol,
  84 |         "datatype": datatype,
  85 |         "outputsize": outputsize,
  86 |         "apikey": API_KEY,
  87 |     }
  88 |     return await _make_api_request(https_params, datatype)
  89 | 
  90 | 
  91 | @instrument_tool("time_series_daily_adjusted")
  92 | async def fetch_time_series_daily_adjusted(
  93 |     symbol: str, datatype: str = "json", outputsize: str = "compact"
  94 | ) -> dict[str, str] | str:
  95 |     """
  96 |     Fetch daily adjusted stock data from the Alpha Vantage API.
  97 | 
  98 |     :argument: symbol (str): The stock symbol to fetch.
  99 |     :argument: datatype (str): The response data type (default: "json").
 100 | 
 101 |     :returns: The daily adjusted stock data.
 102 |     """
 103 | 
 104 |     https_params = {
 105 |         "function": "TIME_SERIES_DAILY_ADJUSTED",
 106 |         "symbol": symbol,
 107 |         "datatype": datatype,
 108 |         "outputsize": outputsize,
 109 |         "apikey": API_KEY,
 110 |     }
 111 |     return await _make_api_request(https_params, datatype)
 112 | 
 113 | 
 114 | @instrument_tool("time_series_weekly")
 115 | async def fetch_time_series_weekly(
 116 |     symbol: str, datatype: str = "json"
 117 | ) -> dict[str, str] | str:
 118 |     """
 119 |     Fetch weekly stock data from the Alpha Vantage API.
 120 | 
 121 |     :argument: symbol (str): The stock symbol to fetch.
 122 |     :argument: datatype (str): The response data type (default: "json").
 123 | 
 124 |     :returns: The weekly stock data.
 125 |     """
 126 | 
 127 |     https_params = {
 128 |         "function": "TIME_SERIES_WEEKLY",
 129 |         "symbol": symbol,
 130 |         "datatype": datatype,
 131 |         "apikey": API_KEY,
 132 |     }
 133 |     return await _make_api_request(https_params, datatype)
 134 | 
 135 | 
 136 | @instrument_tool("time_series_weekly_adjusted")
 137 | async def fetch_time_series_weekly_adjusted(
 138 |     symbol: str, datatype: str = "json"
 139 | ) -> dict[str, str] | str:
 140 |     """
 141 |     Fetch weekly adjusted stock data from the Alpha Vantage API.
 142 | 
 143 |     :argument: symbol (str): The stock symbol to fetch.
 144 |     :argument: datatype (str): The response data type (default: "json").
 145 | 
 146 |     :returns: The weekly adjusted stock data.
 147 |     """
 148 | 
 149 |     https_params = {
 150 |         "function": "TIME_SERIES_WEEKLY_ADJUSTED",
 151 |         "symbol": symbol,
 152 |         "datatype": datatype,
 153 |         "apikey": API_KEY,
 154 |     }
 155 |     return await _make_api_request(https_params, datatype)
 156 | 
 157 | 
 158 | @instrument_tool("time_series_monthly")
 159 | async def fetch_time_series_monthly(
 160 |     symbol: str, datatype: str = "json"
 161 | ) -> dict[str, str] | str:
 162 |     """
 163 |     Fetch monthly stock data from the Alpha Vantage API.
 164 | 
 165 |     :argument: symbol (str): The stock symbol to fetch.
 166 |     :argument: datatype (str): The response data type (default: "json").
 167 | 
 168 |     :returns: The monthly stock data.
 169 |     """
 170 | 
 171 |     https_params = {
 172 |         "function": "TIME_SERIES_MONTHLY",
 173 |         "symbol": symbol,
 174 |         "datatype": datatype,
 175 |         "apikey": API_KEY,
 176 |     }
 177 |     return await _make_api_request(https_params, datatype)
 178 | 
 179 | 
 180 | @instrument_tool("time_series_monthly_adjusted")
 181 | async def fetch_time_series_monthly_adjusted(
 182 |     symbol: str, datatype: str = "json"
 183 | ) -> dict[str, str] | str:
 184 |     """
 185 |     Fetch monthly adjusted stock data from the Alpha Vantage API.
 186 | 
 187 |     :argument: symbol (str): The stock symbol to fetch.
 188 |     :argument: datatype (str): The response data type (default: "json").
 189 | 
 190 |     :returns: The monthly adjusted stock data.
 191 |     """
 192 | 
 193 |     https_params = {
 194 |         "function": "TIME_SERIES_MONTHLY_ADJUSTED",
 195 |         "symbol": symbol,
 196 |         "datatype": datatype,
 197 |         "apikey": API_KEY,
 198 |     }
 199 |     return await _make_api_request(https_params, datatype)
 200 | 
 201 | 
 202 | @instrument_tool("stock_quote")
 203 | async def fetch_quote(symbol: str, datatype: str = "json") -> dict[str, str] | str:
 204 |     """
 205 |     Fetch a stock quote from the Alpha Vantage API.
 206 | 
 207 |     :argument: symbol (str): The stock symbol to fetch.
 208 |     :argument: datatype (str): The response data type (default: "json").
 209 | 
 210 |     :returns: The stock quote data.
 211 |     """
 212 | 
 213 |     https_params = {
 214 |         "function": "GLOBAL_QUOTE",
 215 |         "symbol": symbol,
 216 |         "datatype": datatype,
 217 |         "apikey": API_KEY,
 218 |     }
 219 |     return await _make_api_request(https_params, datatype)
 220 | 
 221 | 
 222 | @instrument_tool("realtime_bulk_quotes")
 223 | async def fetch_realtime_bulk_quotes(
 224 |     symbols: list[str], datatype: str = "json"
 225 | ) -> dict[str, str] | str:
 226 |     """
 227 |     Fetch real-time bulk stock quotes from the Alpha Vantage API.
 228 | 
 229 |     :argument: symbols (list[str]): The stock symbols to fetch.
 230 |     :argument: datatype (str): The response data type (default: "json").
 231 | 
 232 |     :returns: The real-time bulk stock quotes.
 233 |     """
 234 | 
 235 |     https_params = {
 236 |         "function": "REALTIME_BULK_QUOTES",
 237 |         "symbols": ",".join(symbols[:100]),
 238 |         "datatype": datatype,
 239 |         "apikey": API_KEY,
 240 |     }
 241 |     return await _make_api_request(https_params, datatype)
 242 | 
 243 | 
 244 | @instrument_tool("symbol_search")
 245 | async def search_endpoint(
 246 |     keywords: str, datatype: str = "json"
 247 | ) -> dict[str, str] | str:
 248 |     """
 249 |     Search for endpoints from the Alpha Vantage API.
 250 | 
 251 |     :argument: keywords (str): The search keywords.
 252 |     :argument: datatype (str): The response data type (default: "json").
 253 | 
 254 |     :returns: The search results.
 255 |     """
 256 | 
 257 |     https_params = {
 258 |         "function": "SYMBOL_SEARCH",
 259 |         "keywords": keywords,
 260 |         "datatype": datatype,
 261 |         "apikey": API_KEY,
 262 |     }
 263 |     return await _make_api_request(https_params, datatype)
 264 | 
 265 | 
 266 | @instrument_tool("market_status")
 267 | async def fetch_market_status() -> dict[str, str] | str:
 268 |     """
 269 |     Fetch the market status from the Alpha Vantage API.
 270 | 
 271 |     :returns: The market status.
 272 |     """
 273 | 
 274 |     https_params = {"function": "MARKET_STATUS", "apikey": API_KEY}
 275 |     return await _make_api_request(https_params, "json")
 276 | 
 277 | 
 278 | #####
 279 | # Options data APIs
 280 | #####
 281 | 
 282 | 
 283 | @instrument_tool("realtime_options")
 284 | async def fetch_realtime_options(
 285 |     symbol: str, datatype: str = "json", contract: str = None
 286 | ) -> dict[str, str] | str:
 287 |     """
 288 |     Fetch real-time options data from the Alpha Vantage API.
 289 | 
 290 |     :argument: symbol (str): The stock symbol to fetch.
 291 |     :argument: datatype (str): The response data type (default: "json").
 292 |     :argument: contract (str): The contract ID (default: None)
 293 | 
 294 |     :returns: The real-time options' data.
 295 |     """
 296 | 
 297 |     https_params = {
 298 |         "function": "REALTIME_OPTIONS",
 299 |         "symbol": symbol,
 300 |         "datatype": datatype,
 301 |         "contract": contract,
 302 |         "apikey": API_KEY,
 303 |     }
 304 |     return await _make_api_request(https_params, datatype)
 305 | 
 306 | 
 307 | @instrument_tool("historical_options")
 308 | async def fetch_historical_options(
 309 |     symbol: str, datatype: str = "json", date: str = None
 310 | ) -> dict[str, str] | str:
 311 |     """
 312 |     Fetch historical options data from the Alpha Vantage API.
 313 | 
 314 |     :argument: symbol (str): The stock symbol to fetch.
 315 |     :argument: datatype (str): The response data type (default: "json").
 316 |     :argument: date (str): The date of the historical options (default: None)
 317 |     """
 318 | 
 319 |     https_params = {
 320 |         "function": "HISTORICAL_OPTIONS",
 321 |         "symbol": symbol,
 322 |         "datatype": datatype,
 323 |         "date": date,
 324 |         "apikey": API_KEY,
 325 |     }
 326 |     return await _make_api_request(https_params, datatype)
 327 | 
 328 | 
 329 | #####
 330 | # Alpha Intelligence APIs
 331 | #####
 332 | 
 333 | 
 334 | @instrument_tool("news_sentiment")
 335 | async def fetch_news_sentiment(
 336 |     tickers: list[str],
 337 |     datatype: str = "json",
 338 |     topics: list[str] = None,
 339 |     time_from: str = None,
 340 |     time_to: str = None,
 341 |     sort: str = "LATEST",
 342 |     limit: int = 50,
 343 | ) -> dict[str, str] | str:
 344 |     """
 345 |     Fetch news sentiment data from the Alpha Vantage API.
 346 | 
 347 |     :argument: tickers (list[str]): The stock tickers to fetch.
 348 |     :argument: datatype (str): The response data type (default: "json").
 349 |     :argument: topics (list[str]): The news topics (default: None).
 350 |     :argument: time_from (str): The start time (default: None).
 351 |     :argument: time_to (str): The end time (default: None).
 352 |     :argument: sort (str): The sort order (default: "LATEST").
 353 |     :argument: limit (int): The number of news articles to fetch (default: 50).
 354 | 
 355 |     :returns: The news sentiment data.
 356 |     """
 357 | 
 358 |     https_params = {
 359 |         "function": "NEWS_SENTIMENT",
 360 |         "tickers": ",".join(tickers),
 361 |         "datatype": datatype,
 362 |         "topics": ",".join(topics) if topics else None,
 363 |         "time_from": time_from,
 364 |         "time_to": time_to,
 365 |         "sort": sort,
 366 |         "limit": limit,
 367 |         "apikey": API_KEY,
 368 |     }
 369 |     return await _make_api_request(https_params, datatype)
 370 | 
 371 | 
 372 | @instrument_tool("top_gainers_losers")
 373 | async def fetch_top_gainer_losers() -> dict[str, str]:
 374 |     """
 375 |     Fetch the top gainers or losers from the Alpha Vantage API.
 376 | 
 377 |     :returns: The top gainers or losers data.
 378 |     """
 379 | 
 380 |     https_params = {
 381 |         "function": "TOP_GAINERS_LOSERS",
 382 |         "apikey": API_KEY,
 383 |     }
 384 |     return await _make_api_request(https_params, "json")
 385 | 
 386 | 
 387 | @instrument_tool("insider_transactions")
 388 | async def fetch_insider_transactions(symbol: str) -> dict[str, str]:
 389 |     """
 390 |     Fetch insider transactions from the Alpha Vantage API.
 391 | 
 392 |     :argument: symbol (str): The stock symbol to fetch.
 393 | 
 394 |     :returns: insider transactions' data.
 395 |     """
 396 | 
 397 |     https_params = {
 398 |         "function": "INSIDER_TRANSACTIONS",
 399 |         "symbol": symbol,
 400 |         "apikey": API_KEY,
 401 |     }
 402 |     return await _make_api_request(https_params, "json")
 403 | 
 404 | 
 405 | @instrument_tool("analytics_fixed_window")
 406 | async def fetch_analytics_fixed_window(
 407 |     symbols: list[str],
 408 |     interval: str,
 409 |     series_range: str = "full",
 410 |     ohlc: str = "close",
 411 |     calculations: list[str] = None,
 412 | ) -> dict[str, str]:
 413 |     """
 414 |     Fetch analytics data from the Alpha Vantage API.
 415 | 
 416 |     :argument: symbol (list[str]): The stock symbols to fetch.
 417 |     :argument: range (str): The range of the data (default: "full").
 418 |     :argument: interval (str): The time interval for the data.
 419 |     :argument: ohlc (str): The OHLC data type (default: "close").
 420 |     :argument: calculations (list[str]): The analytics calculations (default: None).
 421 | 
 422 |     :returns: The analytics data.
 423 |     """
 424 | 
 425 |     https_params = {
 426 |         "function": "ANALYTICS_FIXED_WINDOW",
 427 |         "symbol": ",".join(symbols),
 428 |         "range": series_range,
 429 |         "interval": interval,
 430 |         "ohlc": ohlc,
 431 |         "calculations": ",".join(calculations) if calculations else None,
 432 |         "apikey": API_KEY,
 433 |     }
 434 |     return await _make_api_request(https_params, "json")
 435 | 
 436 | 
 437 | @instrument_tool("analytics_sliding_window")
 438 | async def fetch_analytics_sliding_window(
 439 |     symbols: list[str],
 440 |     series_range: str = "full",
 441 |     ohlc: str = "close",
 442 |     interval: str = None,
 443 |     window_size: int = 10,
 444 |     calculations: list[str] = None,
 445 | ) -> dict[str, str]:
 446 |     """
 447 |     Fetch analytics data from the Alpha Vantage API.
 448 | 
 449 |     :argument: symbol (list[str]): The stock symbols to fetch.
 450 | 
 451 |     :returns: The analytics data.
 452 |     """
 453 | 
 454 |     https_params = {
 455 |         "function": "ANALYTICS_SLIDING_WINDOW",
 456 |         "symbols": ",".join(symbols),
 457 |         "range": series_range,
 458 |         "ohlc": ohlc,
 459 |         "interval": interval,
 460 |         "window_size": window_size,
 461 |         "calculations": ",".join(calculations) if calculations else None,
 462 |         "apikey": API_KEY,
 463 |     }
 464 |     return await _make_api_request(https_params, "json")
 465 | 
 466 | 
 467 | #####
 468 | # Fundamental data APIs
 469 | #####
 470 | @instrument_tool("company_overview")
 471 | async def fetch_company_overview(symbol: str) -> dict[str, str]:
 472 |     """
 473 |     Fetch company overview data from the Alpha Vantage API.
 474 | 
 475 |     :argument: symbol (str): The stock symbol to fetch.
 476 | 
 477 |     :returns: The company overview data.
 478 |     """
 479 | 
 480 |     https_params = {
 481 |         "function": "OVERVIEW",
 482 |         "symbol": symbol,
 483 |         "apikey": API_KEY,
 484 |     }
 485 |     return await _make_api_request(https_params, "json")
 486 | 
 487 | 
 488 | @instrument_tool("etf_profile")
 489 | async def fetch_etf_profile(symbol: str) -> dict[str, str]:
 490 |     """
 491 |     Fetch ETC profile from Alpha Vantage API.
 492 | 
 493 |     :argument: symbol (str): The stock symbol to fetch.
 494 | 
 495 |     :returns: The company overview data.
 496 |     """
 497 | 
 498 |     https_params = {
 499 |         "function": "ETF_PROFILE",
 500 |         "symbol": symbol,
 501 |         "apikey": API_KEY,
 502 |     }
 503 |     return await _make_api_request(https_params, "json")
 504 | 
 505 | 
 506 | @instrument_tool("company_dividends")
 507 | async def company_dividends(symbol: str) -> dict[str, str]:
 508 |     """
 509 |     Fetch company dividends data from the Alpha Vantage API.
 510 | 
 511 |     :argument: symbol (str): The stock symbol to fetch.
 512 | 
 513 |     :returns: The company dividends data.
 514 |     """
 515 | 
 516 |     https_params = {
 517 |         "function": "DIVIDENDS",
 518 |         "symbol": symbol,
 519 |         "apikey": API_KEY,
 520 |     }
 521 |     return await _make_api_request(https_params, "json")
 522 | 
 523 | 
 524 | @instrument_tool("company_splits")
 525 | async def fetch_company_splits(symbol: str) -> dict[str, str]:
 526 |     """
 527 |     Fetch company splits data from the Alpha Vantage API.
 528 | 
 529 |     :argument: symbol (str): The stock symbol to fetch.
 530 | 
 531 |     :returns: The company splits data.
 532 |     """
 533 | 
 534 |     https_params = {
 535 |         "function": "SPLITS",
 536 |         "symbol": symbol,
 537 |         "apikey": API_KEY,
 538 |     }
 539 |     return await _make_api_request(https_params, "json")
 540 | 
 541 | 
 542 | @instrument_tool("income_statement")
 543 | async def fetch_income_statement(symbol: str) -> dict[str, str]:
 544 |     """
 545 |     Fetch company income statement data from the Alpha Vantage API.
 546 | 
 547 |     :argument: symbol (str): The stock symbol to fetch.
 548 | 
 549 |     :returns: The company income statement data.
 550 |     """
 551 | 
 552 |     https_params = {
 553 |         "function": "INCOME_STATEMENT",
 554 |         "symbol": symbol,
 555 |         "apikey": API_KEY,
 556 |     }
 557 |     return await _make_api_request(https_params, "json")
 558 | 
 559 | 
 560 | @instrument_tool("balance_sheet")
 561 | async def fetch_balance_sheet(symbol: str) -> dict[str, str]:
 562 |     """
 563 |     Fetch company balance sheet data from the Alpha Vantage API.
 564 | 
 565 |     :argument: symbol (str): The stock symbol to fetch.
 566 | 
 567 |     :returns: The company balance sheet data.
 568 |     """
 569 | 
 570 |     https_params = {
 571 |         "function": "BALANCE_SHEET",
 572 |         "symbol": symbol,
 573 |         "apikey": API_KEY,
 574 |     }
 575 |     return await _make_api_request(https_params, "json")
 576 | 
 577 | 
 578 | @instrument_tool("cash_flow")
 579 | async def fetch_cash_flow(symbol: str) -> dict[str, str]:
 580 |     """
 581 |     Fetch company cash flow data from the Alpha Vantage API.
 582 | 
 583 |     :argument: symbol (str): The stock symbol to fetch.
 584 | 
 585 |     :returns: The company cash flow data.
 586 |     """
 587 | 
 588 |     https_params = {
 589 |         "function": "CASH_FLOW",
 590 |         "symbol": symbol,
 591 |         "apikey": API_KEY,
 592 |     }
 593 |     async with httpx.AsyncClient() as client:
 594 |         response = await client.get(API_BASE_URL, params=https_params)
 595 |         response.raise_for_status()
 596 |         return response.json()
 597 | 
 598 | 
 599 | @instrument_tool("company_earnings")
 600 | async def fetch_earnings(symbol: str) -> dict[str, str]:
 601 |     """
 602 |     Fetch company earnings data from the Alpha Vantage API.
 603 | 
 604 |     :argument: symbol (str): The stock symbol to fetch.
 605 | 
 606 |     :returns: The company earnings data.
 607 |     """
 608 | 
 609 |     https_params = {
 610 |         "function": "EARNINGS",
 611 |         "symbol": symbol,
 612 |         "apikey": API_KEY,
 613 |     }
 614 |     return await _make_api_request(https_params, "json")
 615 | 
 616 | 
 617 | @instrument_tool("earnings_call_transcript")
 618 | async def fetch_earnings_call_transcript(symbol: str, quarter: str) -> dict[str, str]:
 619 |     """
 620 |     This API returns the earnings call transcript for a given company in a specific quarter, covering over 15 years
 621 |     of history and enriched with LLM-based sentiment signals.
 622 | 
 623 |     :param symbol: The stock symbol to fetch.
 624 |     :param quarter: The quarter for which to fetch the earnings call transcript in the format YYYYQM.
 625 | 
 626 |     :return: The earnings call transcript data.
 627 |     """
 628 |     https_params = {
 629 |         "function": "EARNINGS_CALL_TRANSCRIPT",
 630 |         "symbol": symbol,
 631 |         "quarter": quarter,
 632 |         "apikey": API_KEY,
 633 |     }
 634 |     return await _make_api_request(https_params, "json")
 635 | 
 636 | 
 637 | @instrument_tool("listing_status")
 638 | async def fetch_listing_status(
 639 |     date: str = None, state: str = "active"
 640 | ) -> dict[str, str]:
 641 |     """
 642 |     Fetch company listing status data from the Alpha Vantage API.
 643 | 
 644 |     :argument: date (str): The date of the listing status (default: None).
 645 |     :argument: state (str): The listing status state (default: "active").
 646 | 
 647 |     :returns: The company listing status data.
 648 |     """
 649 | 
 650 |     https_params = {
 651 |         "function": "LISTING_STATUS",
 652 |         "date": date,
 653 |         "state": state,
 654 |         "apikey": API_KEY,
 655 |     }
 656 |     return await _make_api_request(https_params, "json")
 657 | 
 658 | 
 659 | @instrument_tool("earnings_calendar")
 660 | async def fetch_earnings_calendar(symbol: str, horizon: str = "3month") -> str:
 661 |     """
 662 |     Fetch companies earnings calendar data from the Alpha Vantage API.
 663 | 
 664 |     :argument: symbol (str): The stock symbol to fetch.
 665 |     :argument: horizon (str): The earning calendar horizon (default: "3month").
 666 | 
 667 |     :returns: The company earning calendar data using CSV format
 668 |     """
 669 | 
 670 |     https_params = {
 671 |         "function": "EARNINGS_CALENDAR",
 672 |         "horizon": horizon,
 673 |         "apikey": API_KEY,
 674 |     }
 675 |     if symbol:
 676 |         https_params["symbol"] = symbol
 677 | 
 678 |     return await _make_api_request(https_params, "csv")
 679 | 
 680 | 
 681 | @instrument_tool("ipo_calendar")
 682 | async def fetch_ipo_calendar() -> str:
 683 |     """
 684 |     Fetch IPO calendar data from the Alpha Vantage API.
 685 | 
 686 |     :returns: The IPO calendar data.
 687 |     """
 688 | 
 689 |     https_params = {
 690 |         "function": "IPO_CALENDAR",
 691 |         "apikey": API_KEY,
 692 |     }
 693 | 
 694 |     return await _make_api_request(https_params, "csv")
 695 | 
 696 | 
 697 | #####
 698 | # Forex data APIs
 699 | #####
 700 | 
 701 | 
 702 | @instrument_tool("exchange_rate")
 703 | async def fetch_exchange_rate(
 704 |     from_currency: str, to_currency: str
 705 | ) -> dict[str, str] | str:
 706 |     """
 707 |     Fetch exchange rate data from the Alpha Vantage API.
 708 | 
 709 |     :argument: from_currency (str): The source currency.
 710 |     :argument: to_currency (str): The destination currency.
 711 | 
 712 |     :returns: The exchange rate data.
 713 |     """
 714 | 
 715 |     https_params = {
 716 |         "function": "CURRENCY_EXCHANGE_RATE",
 717 |         "from_currency": from_currency,
 718 |         "to_currency": to_currency,
 719 |         "apikey": API_KEY,
 720 |     }
 721 | 
 722 |     return await _make_api_request(https_params, "json")
 723 | 
 724 | 
 725 | @instrument_tool("fx_intraday")
 726 | async def fetch_fx_intraday(
 727 |     from_symbol: str,
 728 |     to_symbol: str,
 729 |     interval: str = None,
 730 |     outputsize: str = "compact",
 731 |     datatype: str = "json",
 732 | ) -> dict[str, str] | str:
 733 |     """
 734 |     Fetch intraday forex data from the Alpha Vantage API.
 735 | 
 736 |     :argument: from_symbol (str): The source currency.
 737 |     :argument: to_symbol (str): The destination currency.
 738 |     :argument: interval (str): The time interval for the data (default: None).
 739 |     :argument: outputsize (str): The output size for the data (default: "compact").
 740 |     :argument: datatype (str): The response data type (default: "json").
 741 | 
 742 |     :returns: The intraday forex data.
 743 |     """
 744 | 
 745 |     https_params = {
 746 |         "function": "FX_INTRADAY",
 747 |         "from_symbol": from_symbol,
 748 |         "to_symbol": to_symbol,
 749 |         "interval": interval,
 750 |         "datatype": datatype,
 751 |         "outputsize": outputsize,
 752 |         "apikey": API_KEY,
 753 |     }
 754 | 
 755 |     return await _make_api_request(https_params, datatype)
 756 | 
 757 | 
 758 | @instrument_tool("fx_daily")
 759 | async def fetch_fx_daily(
 760 |     from_symbol: str,
 761 |     to_symbol: str,
 762 |     datatype: str = "json",
 763 |     outputsize: str = "compact",
 764 | ) -> dict[str, str] | str:
 765 |     """
 766 |     Fetch daily forex data from the Alpha Vantage API.
 767 | 
 768 |     :argument: from_symbol (str): The source currency.
 769 |     :argument: to_symbol (str): The destination currency.
 770 |     :argument: datatype (str): The response data type (default: "json").
 771 |     :argument: outputsize (str): The output size for the data (default: "compact").
 772 | 
 773 |     :returns: The daily forex data.
 774 |     """
 775 | 
 776 |     https_params = {
 777 |         "function": "FX_DAILY",
 778 |         "from_symbol": from_symbol,
 779 |         "to_symbol": to_symbol,
 780 |         "datatype": datatype,
 781 |         "outputsize": outputsize,
 782 |         "apikey": API_KEY,
 783 |     }
 784 |     return await _make_api_request(https_params, datatype)
 785 | 
 786 | 
 787 | @instrument_tool("fx_weekly")
 788 | async def fetch_fx_weekly(
 789 |     from_symbol: str, to_symbol: str, datatype: str = "json"
 790 | ) -> dict[str, str] | str:
 791 |     """
 792 |     Fetch weekly forex data from the Alpha Vantage API.
 793 | 
 794 |     :argument: from_symbol (str): The source currency.
 795 |     :argument: to_symbol (str): The destination currency.
 796 |     :argument: datatype (str): The response data type (default: "json").
 797 | 
 798 |     :returns: The weekly forex data.
 799 |     """
 800 | 
 801 |     https_params = {
 802 |         "function": "FX_WEEKLY",
 803 |         "from_symbol": from_symbol,
 804 |         "to_symbol": to_symbol,
 805 |         "datatype": datatype,
 806 |         "apikey": API_KEY,
 807 |     }
 808 |     return await _make_api_request(https_params, datatype)
 809 | 
 810 | 
 811 | @instrument_tool("fx_monthly")
 812 | async def fetch_fx_monthly(
 813 |     from_symbol: str, to_symbol: str, datatype: str = "json"
 814 | ) -> dict[str, str] | str:
 815 |     """
 816 |     Fetch monthly forex data from the Alpha Vantage API.
 817 | 
 818 |     :argument: from_symbol (str): The source currency.
 819 |     :argument: to_symbol (str): The destination currency.
 820 |     :argument: datatype (str): The response data type (default: "json").
 821 | 
 822 |     :returns: The monthly forex data.
 823 |     """
 824 | 
 825 |     https_params = {
 826 |         "function": "FX_MONTHLY",
 827 |         "from_symbol": from_symbol,
 828 |         "to_symbol": to_symbol,
 829 |         "datatype": datatype,
 830 |         "apikey": API_KEY,
 831 |     }
 832 |     return await _make_api_request(https_params, datatype)
 833 | 
 834 | 
 835 | #####
 836 | # Crypto data APIs
 837 | #####
 838 | 
 839 | 
 840 | @instrument_tool("crypto_intraday")
 841 | async def fetch_digital_currency_intraday(
 842 |     symbol: str,
 843 |     market: str,
 844 |     interval: str = None,
 845 |     datatype: str = "json",
 846 |     outputsize: str = "compact",
 847 | ) -> dict[str, str] | str:
 848 |     """
 849 |     Fetch intraday digital currency data from the Alpha Vantage API.
 850 | 
 851 |     :argument: symbol (str): The digital currency symbol to fetch.
 852 |     :argument: market (str): The market symbol to fetch.
 853 |     :argument: interval (str): The time interval for the data (default: "5min").
 854 |     :argument: datatype (str): The response data type (default: "json").
 855 | 
 856 |     :returns: The intraday digital currency data.
 857 |     """
 858 | 
 859 |     https_params = {
 860 |         "function": "CRYPTO_INTRADAY",
 861 |         "symbol": symbol,
 862 |         "market": market,
 863 |         "interval": interval,
 864 |         "datatype": datatype,
 865 |         "outputsize": outputsize,
 866 |         "apikey": API_KEY,
 867 |     }
 868 |     return await _make_api_request(https_params, datatype)
 869 | 
 870 | 
 871 | @instrument_tool("digital_currency_daily")
 872 | async def fetch_digital_currency_daily(symbol: str, market: str) -> str:
 873 |     """
 874 |     Fetch daily digital currency data from the Alpha Vantage API.
 875 | 
 876 |     :argument: symbol (str): The digital currency symbol to fetch.
 877 |     :argument: market (str): The market symbol to fetch.
 878 |     :argument: datatype (str): The response data type (default: "json").
 879 | 
 880 |     :returns: The daily digital currency data.
 881 |     """
 882 | 
 883 |     https_params = {
 884 |         "function": "DIGITAL_CURRENCY_DAILY",
 885 |         "symbol": symbol,
 886 |         "market": market,
 887 |         "apikey": API_KEY,
 888 |     }
 889 |     return await _make_api_request(https_params, "csv")
 890 | 
 891 | 
 892 | @instrument_tool("digital_currency_weekly")
 893 | async def fetch_digital_currency_weekly(symbol: str, market: str) -> str:
 894 |     """
 895 |     Fetch weekly digital currency data from the Alpha Vantage API.
 896 | 
 897 |     :argument: symbol (str): The digital currency symbol to fetch.
 898 |     :argument: market (str): The market symbol to fetch.
 899 |     :argument: datatype (str): The response data type (default: "json").
 900 | 
 901 |     :returns: The weekly digital currency data.
 902 |     """
 903 | 
 904 |     https_params = {
 905 |         "function": "DIGITAL_CURRENCY_WEEKLY",
 906 |         "symbol": symbol,
 907 |         "market": market,
 908 |         "apikey": API_KEY,
 909 |     }
 910 |     return await _make_api_request(https_params, "csv")
 911 | 
 912 | 
 913 | @instrument_tool("digital_currency_monthly")
 914 | async def fetch_digital_currency_monthly(symbol: str, market: str) -> str:
 915 |     """
 916 |     Fetch monthly digital currency data from the Alpha Vantage API.
 917 | 
 918 |     :argument: symbol (str): The digital currency symbol to fetch.
 919 |     :argument: market (str): The market symbol to fetch.
 920 |     :argument: datatype (str): The response data type (default: "json").
 921 | 
 922 |     :returns: The monthly digital currency data.
 923 |     """
 924 | 
 925 |     https_params = {
 926 |         "function": "DIGITAL_CURRENCY_MONTHLY",
 927 |         "symbol": symbol,
 928 |         "market": market,
 929 |         "apikey": API_KEY,
 930 |     }
 931 |     return await _make_api_request(https_params, "csv")
 932 | 
 933 | 
 934 | #####
 935 | # Commodities data APIs
 936 | #####
 937 | 
 938 | 
 939 | @instrument_tool("wti_crude_oil")
 940 | async def fetch_wti_crude(
 941 |     interval: str = "monthly", datatype: str = "json"
 942 | ) -> dict[str, str] | str:
 943 |     """
 944 |     Fetch crude oil (WTI) data from the Alpha Vantage API.
 945 | 
 946 |     :argument: interval (str): The time interval for the data (default: "monthly").
 947 |     :argument: datatype (str): The response data type (default: "json").
 948 | 
 949 |     :returns: The intraday crude oil (WTI) data.
 950 |     """
 951 | 
 952 |     https_params = {
 953 |         "function": "WTI",
 954 |         "interval": interval,
 955 |         "datatype": datatype,
 956 |         "apikey": API_KEY,
 957 |     }
 958 | 
 959 |     return await _make_api_request(https_params, datatype)
 960 | 
 961 | 
 962 | @instrument_tool("brent_crude_oil")
 963 | async def fetch_brent_crude(
 964 |     interval: str = "monthly", datatype: str = "json"
 965 | ) -> dict[str, str] | str:
 966 |     """
 967 |     Fetch Brent crude oil data from the Alpha Vantage API.
 968 | 
 969 |     :argument: interval (str): The time interval for the data (default: "monthly").
 970 |     :argument: datatype (str): The response data type (default: "json").
 971 | 
 972 |     :returns: The intraday Brent crude oil data.
 973 |     """
 974 | 
 975 |     https_params = {
 976 |         "function": "BRENT",
 977 |         "interval": interval,
 978 |         "datatype": datatype,
 979 |         "apikey": API_KEY,
 980 |     }
 981 | 
 982 |     return await _make_api_request(https_params, datatype)
 983 | 
 984 | 
 985 | @instrument_tool("natural_gas")
 986 | async def fetch_natural_gas(
 987 |     interval: str = "monthly", datatype: str = "json"
 988 | ) -> dict[str, str] | str:
 989 |     """
 990 |     Fetch Henry Hub natural gas data from the Alpha Vantage API.
 991 | 
 992 |     :argument: interval (str): The time interval for the data (default: "monthly").
 993 |     :argument: datatype (str): The response data type (default: "json").
 994 | 
 995 |     :returns: The intraday natural gas data.
 996 |     """
 997 | 
 998 |     https_params = {
 999 |         "function": "NATURAL_GAS",
1000 |         "interval": interval,
1001 |         "datatype": datatype,
1002 |         "apikey": API_KEY,
1003 |     }
1004 | 
1005 |     return await _make_api_request(https_params, datatype)
1006 | 
1007 | 
1008 | @instrument_tool("copper")
1009 | async def fetch_copper(
1010 |     interval: str = "monthly", datatype: str = "json"
1011 | ) -> dict[str, str] | str:
1012 |     """
1013 |     Fetch global copper data from the Alpha Vantage API.
1014 | 
1015 |     :argument: interval (str): The time interval for the data (default: "monthly").
1016 |     :argument: datatype (str): The response data type (default: "json").
1017 | 
1018 |     :returns: The intraday copper data.
1019 |     """
1020 | 
1021 |     https_params = {
1022 |         "function": "COPPER",
1023 |         "interval": interval,
1024 |         "datatype": datatype,
1025 |         "apikey": API_KEY,
1026 |     }
1027 | 
1028 |     return await _make_api_request(https_params, datatype)
1029 | 
1030 | 
1031 | @instrument_tool("aluminum")
1032 | async def fetch_aluminum(
1033 |     interval: str = "monthly", datatype: str = "json"
1034 | ) -> dict[str, str] | str:
1035 |     """
1036 |     Fetch global aluminum data from the Alpha Vantage API.
1037 | 
1038 |     :argument: interval (str): The time interval for the data (default: "monthly").
1039 |     :argument: datatype (str): The response data type (default: "json").
1040 | 
1041 |     :returns: The intraday aluminum data.
1042 |     """
1043 | 
1044 |     https_params = {
1045 |         "function": "ALUMINUM",
1046 |         "interval": interval,
1047 |         "datatype": datatype,
1048 |         "apikey": API_KEY,
1049 |     }
1050 | 
1051 |     return await _make_api_request(https_params, datatype)
1052 | 
1053 | 
1054 | @instrument_tool("wheat")
1055 | async def fetch_wheat(
1056 |     interval: str = "monthly", datatype: str = "json"
1057 | ) -> dict[str, str] | str:
1058 |     """
1059 |     Fetch global wheat data from the Alpha Vantage API.
1060 | 
1061 |     :argument: interval (str): The time interval for the data (default: "monthly").
1062 |     :argument: datatype (str): The response data type (default: "json").
1063 | 
1064 |     :returns: The intraday wheat data.
1065 |     """
1066 | 
1067 |     https_params = {
1068 |         "function": "WHEAT",
1069 |         "interval": interval,
1070 |         "datatype": datatype,
1071 |         "apikey": API_KEY,
1072 |     }
1073 | 
1074 |     return await _make_api_request(https_params, datatype)
1075 | 
1076 | 
1077 | @instrument_tool("corn")
1078 | async def fetch_corn(
1079 |     interval: str = "monthly", datatype: str = "json"
1080 | ) -> dict[str, str] | str:
1081 |     """
1082 |     Fetch global corn data from the Alpha Vantage API.
1083 | 
1084 |     :argument: interval (str): The time interval for the data (default: "monthly").
1085 |     :argument: datatype (str): The response data type (default: "json").
1086 | 
1087 |     :returns: The intraday corn data.
1088 |     """
1089 | 
1090 |     https_params = {
1091 |         "function": "CORN",
1092 |         "interval": interval,
1093 |         "datatype": datatype,
1094 |         "apikey": API_KEY,
1095 |     }
1096 | 
1097 |     return await _make_api_request(https_params, datatype)
1098 | 
1099 | 
1100 | @instrument_tool("cotton")
1101 | async def fetch_cotton(
1102 |     interval: str = "monthly", datatype: str = "json"
1103 | ) -> dict[str, str] | str:
1104 |     """
1105 |     Fetch global cotton data from the Alpha Vantage API.
1106 | 
1107 |     :argument: interval (str): The time interval for the data (default: "monthly").
1108 |     :argument: datatype (str): The response data type (default: "json").
1109 | 
1110 |     :returns: The intraday cotton data.
1111 |     """
1112 | 
1113 |     https_params = {
1114 |         "function": "COTTON",
1115 |         "interval": interval,
1116 |         "datatype": datatype,
1117 |         "apikey": API_KEY,
1118 |     }
1119 | 
1120 |     return await _make_api_request(https_params, datatype)
1121 | 
1122 | 
1123 | @instrument_tool("sugar")
1124 | async def fetch_sugar(
1125 |     interval: str = "monthly", datatype: str = "json"
1126 | ) -> dict[str, str] | str:
1127 |     """
1128 |     Fetch global sugar data from the Alpha Vantage API.
1129 | 
1130 |     :argument: interval (str): The time interval for the data (default: "monthly").
1131 |     :argument: datatype (str): The response data type (default: "json").
1132 | 
1133 |     :returns: The intraday sugar data.
1134 |     """
1135 | 
1136 |     https_params = {
1137 |         "function": "SUGAR",
1138 |         "interval": interval,
1139 |         "datatype": datatype,
1140 |         "apikey": API_KEY,
1141 |     }
1142 | 
1143 |     return await _make_api_request(https_params, datatype)
1144 | 
1145 | 
1146 | @instrument_tool("coffee")
1147 | async def fetch_coffee(
1148 |     interval: str = "monthly", datatype: str = "json"
1149 | ) -> dict[str, str] | str:
1150 |     """
1151 |     Fetch global coffee data from the Alpha Vantage API.
1152 | 
1153 |     :argument: interval (str): The time interval for the data (default: "monthly").
1154 |     :argument: datatype (str): The response data type (default: "json").
1155 | 
1156 |     :returns: The intraday coffee data.
1157 |     """
1158 | 
1159 |     https_params = {
1160 |         "function": "COFFEE",
1161 |         "interval": interval,
1162 |         "datatype": datatype,
1163 |         "apikey": API_KEY,
1164 |     }
1165 | 
1166 |     return await _make_api_request(https_params, datatype)
1167 | 
1168 | 
1169 | @instrument_tool("all_commodities")
1170 | async def fetch_all_commodities(
1171 |     interval: str = "monthly", datatype: str = "json"
1172 | ) -> dict[str, str] | str:
1173 |     """
1174 |     Fetch global commodities data from the Alpha Vantage API.
1175 | 
1176 |     :argument: interval (str): The time interval for the data (default: "monthly").
1177 |     :argument: datatype (str): The response data type (default: "json").
1178 | 
1179 |     :returns: Global commodities data.
1180 |     """
1181 | 
1182 |     https_params = {
1183 |         "function": "ALL_COMMODITIES",
1184 |         "interval": interval,
1185 |         "datatype": datatype,
1186 |         "apikey": API_KEY,
1187 |     }
1188 | 
1189 |     return await _make_api_request(https_params, datatype)
1190 | 
1191 | 
1192 | #####
1193 | # Economic data APIs
1194 | #####
1195 | 
1196 | 
1197 | @instrument_tool("real_gdp")
1198 | async def fetch_real_gdp(
1199 |     interval: str = "monthly", datatype: str = "json"
1200 | ) -> dict[str, str] | str:
1201 |     """
1202 |     Fetch real GDP data from the Alpha Vantage API.
1203 | 
1204 |     :argument: interval (str): The time interval for the data (default: "monthly").
1205 |     :argument: datatype (str): The response data type (default: "json").
1206 | 
1207 |     :returns: The real GDP data.
1208 |     """
1209 | 
1210 |     https_params = {
1211 |         "function": "REAL_GDP",
1212 |         "interval": interval,
1213 |         "datatype": datatype,
1214 |         "apikey": API_KEY,
1215 |     }
1216 | 
1217 |     return await _make_api_request(https_params, datatype)
1218 | 
1219 | 
1220 | @instrument_tool("real_gdp_per_capita")
1221 | async def fetch_real_gdp_per_capita(datatype: str = "json") -> dict[str, str] | str:
1222 |     """
1223 |     Fetch real GDP per capita data from the Alpha Vantage API.
1224 | 
1225 |     :argument: interval (str): The time interval for the data (default: "monthly").
1226 |     :argument: datatype (str): The response data type (default: "json").
1227 | 
1228 |     :returns: The real GDP per capita data.
1229 |     """
1230 | 
1231 |     https_params = {
1232 |         "function": "REAL_GDP_PER_CAPITA",
1233 |         "datatype": datatype,
1234 |         "apikey": API_KEY,
1235 |     }
1236 | 
1237 |     return await _make_api_request(https_params, datatype)
1238 | 
1239 | 
1240 | @instrument_tool("treasury_yield")
1241 | async def fetch_treasury_yield(
1242 |     interval: str = "monthly", maturity: str = "10year", datatype: str = "json"
1243 | ) -> dict[str, str] | str:
1244 |     """
1245 |     Fetch treasure yield data from the Alpha Vantage API.
1246 | 
1247 |     :argument: interval (str): The time interval for the data (default: "monthly").
1248 |     :argument: maturity (str): The maturity period for the data (default: "monthly").
1249 |     :argument: datatype (str): The response data type (default: "json").
1250 | 
1251 |     :returns: The treasure yield data.
1252 |     """
1253 | 
1254 |     https_params = {
1255 |         "function": "TREASURY_YIELD",
1256 |         "interval": interval,
1257 |         "maturity": maturity,
1258 |         "datatype": datatype,
1259 |         "apikey": API_KEY,
1260 |     }
1261 | 
1262 |     return await _make_api_request(https_params, datatype)
1263 | 
1264 | 
1265 | @instrument_tool("federal_funds_rate")
1266 | async def fetch_federal_funds_rate(
1267 |     interval: str = "monthly", datatype: str = "json"
1268 | ) -> dict[str, str] | str:
1269 |     """
1270 |     Fetch federal funds rate data from the Alpha Vantage API.
1271 | 
1272 |     :argument: interval (str): The time interval for the data (default: "monthly").
1273 |     :argument: datatype (str): The response data type (default: "json").
1274 | 
1275 |     :returns: The federal funds rate data.
1276 |     """
1277 | 
1278 |     https_params = {
1279 |         "function": "FEDERAL_FUNDS_RATE",
1280 |         "interval": interval,
1281 |         "datatype": datatype,
1282 |         "apikey": API_KEY,
1283 |     }
1284 | 
1285 |     return await _make_api_request(https_params, datatype)
1286 | 
1287 | 
1288 | @instrument_tool("cpi")
1289 | async def fetch_cpi(
1290 |     interval: str = "monthly", datatype: str = "json"
1291 | ) -> dict[str, str] | str:
1292 |     """
1293 |     Fetch consumer price index (CPI) data from the Alpha Vantage API.
1294 | 
1295 |     :argument: interval (str): The time interval for the data (default: "monthly").
1296 |     :argument: datatype (str): The response data type (default: "json").
1297 | 
1298 |     :returns: The consumer price index (CPI) data.
1299 |     """
1300 | 
1301 |     https_params = {
1302 |         "function": "CPI",
1303 |         "interval": interval,
1304 |         "datatype": datatype,
1305 |         "apikey": API_KEY,
1306 |     }
1307 | 
1308 |     return await _make_api_request(https_params, datatype)
1309 | 
1310 | 
1311 | @instrument_tool("inflation")
1312 | async def fetch_inflation(datatype: str = "json") -> dict[str, str] | str:
1313 |     """
1314 |     Fetch inflation data from the Alpha Vantage API.
1315 | 
1316 |     :argument: datatype (str): The response data type (default: "json").
1317 | 
1318 |     :returns: The inflation data.
1319 |     """
1320 | 
1321 |     https_params = {
1322 |         "function": "INFLATION",
1323 |         "datatype": datatype,
1324 |         "apikey": API_KEY,
1325 |     }
1326 | 
1327 |     return await _make_api_request(https_params, datatype)
1328 | 
1329 | 
1330 | @instrument_tool("retail_sales")
1331 | async def fetch_retail_sales(datatype: str = "json") -> dict[str, str] | str:
1332 |     """
1333 |     Fetch retail sales data from the Alpha Vantage API.
1334 | 
1335 |     :argument: datatype (str): The response data type (default: "json").
1336 | 
1337 |     :returns: The retail sales data.
1338 |     """
1339 | 
1340 |     https_params = {
1341 |         "function": "RETAIL_SALES",
1342 |         "datatype": datatype,
1343 |         "apikey": API_KEY,
1344 |     }
1345 | 
1346 |     return await _make_api_request(https_params, datatype)
1347 | 
1348 | 
1349 | @instrument_tool("durables")
1350 | async def fetch_durables(datatype: str = "json") -> dict[str, str] | str:
1351 |     """
1352 |     Fetch durable goods data from the Alpha Vantage API.
1353 | 
1354 |     :argument: datatype (str): The response data type (default: "json").
1355 | 
1356 |     :returns: The durable goods data.
1357 |     """
1358 | 
1359 |     https_params = {
1360 |         "function": "DURABLES",
1361 |         "datatype": datatype,
1362 |         "apikey": API_KEY,
1363 |     }
1364 | 
1365 |     return await _make_api_request(https_params, datatype)
1366 | 
1367 | 
1368 | @instrument_tool("unemployment")
1369 | async def fetch_unemployment(datatype: str = "json") -> dict[str, str] | str:
1370 |     """
1371 |     Fetch unemployment data from the Alpha Vantage API.
1372 | 
1373 |     :argument: datatype (str): The response data type (default: "json").
1374 | 
1375 |     :returns: The unemployment data.
1376 |     """
1377 | 
1378 |     https_params = {
1379 |         "function": "UNEMPLOYMENT",
1380 |         "datatype": datatype,
1381 |         "apikey": API_KEY,
1382 |     }
1383 | 
1384 |     return await _make_api_request(https_params, datatype)
1385 | 
1386 | 
1387 | @instrument_tool("nonfarm_payroll")
1388 | async def fetch_nonfarm_payrolls(datatype: str = "json") -> dict[str, str] | str:
1389 |     """
1390 |     Fetch nonfarm payrolls data from the Alpha Vantage API.
1391 | 
1392 |     :argument: datatype (str): The response data type (default: "json").
1393 | 
1394 |     :returns: The nonfarm payrolls' data.
1395 |     """
1396 | 
1397 |     https_params = {
1398 |         "function": "NONFARM_PAYROLL",
1399 |         "datatype": datatype,
1400 |         "apikey": API_KEY,
1401 |     }
1402 | 
1403 |     return await _make_api_request(https_params, datatype)
1404 | 
1405 | 
1406 | #####
1407 | # Technical indicators APIs
1408 | #####
1409 | 
1410 | 
1411 | @instrument_tool("sma")
1412 | async def fetch_sma(
1413 |     symbol: str,
1414 |     interval: str = None,
1415 |     month: str = None,
1416 |     time_period: int = None,
1417 |     series_type: str = None,
1418 |     datatype: str = "json",
1419 |     max_data_points: int = 100,
1420 | ) -> dict[str, str] | str:
1421 |     """
1422 |     Fetch simple moving average (SMA) data from the Alpha Vantage API.
1423 | 
1424 |     :argument: symbol (str): The stock symbol to fetch.
1425 |     :argument: interval (str): The time interval for the data.
1426 |     :argument: month (str): The month for the data.
1427 |     :argument: time_period (int): The time period for the data.
1428 |     :argument: series_type (str): The series type for the data.
1429 |     :argument: datatype (str): The response data type (default: "json").
1430 |     :argument: max_data_points (int): Maximum number of data points to return (default: 100).
1431 | 
1432 |     :returns: The simple moving average (SMA) data.
1433 |     """
1434 | 
1435 |     https_params = {
1436 |         "function": "SMA",
1437 |         "symbol": symbol,
1438 |         "interval": interval,
1439 |         "month": month,
1440 |         "time_period": time_period,
1441 |         "series_type": series_type,
1442 |         "datatype": datatype,
1443 |         "apikey": API_KEY,
1444 |     }
1445 | 
1446 |     async with httpx.AsyncClient() as client:
1447 |         response = await client.get(API_BASE_URL, params=https_params)
1448 |         response.raise_for_status()
1449 | 
1450 |         if datatype == "csv":
1451 |             return response.text
1452 | 
1453 |         # For JSON responses, apply response limiting to prevent token issues
1454 |         full_response = response.json()
1455 | 
1456 |         # Import response limiting utilities
1457 |         from .response_utils import limit_time_series_response, should_limit_response
1458 | 
1459 |         # Check if response should be limited
1460 |         if should_limit_response(full_response):
1461 |             return limit_time_series_response(full_response, max_data_points)
1462 | 
1463 |         return full_response
1464 | 
1465 | 
1466 | @instrument_tool("ema")
1467 | async def fetch_ema(
1468 |     symbol: str,
1469 |     interval: str = None,
1470 |     month: str = None,
1471 |     time_period: int = None,
1472 |     series_type: str = None,
1473 |     datatype: str = "json",
1474 | ) -> dict[str, str] | str:
1475 |     """
1476 |     Fetch exponential moving average (EMA) data from the Alpha Vantage API.
1477 | 
1478 |     :argument: symbol (str): The stock symbol to fetch.
1479 |     :argument: interval (str): The time interval for the data.
1480 |     :argument: month (str): The month for the data.
1481 |     :argument: time_period (int): The time period for the data.
1482 |     :argument: series_type (str): The series type for the data.
1483 |     :argument: datatype (str): The response data type (default: "json").
1484 | 
1485 |     :returns: The exponential moving average (EMA) data.
1486 |     """
1487 | 
1488 |     https_params = {
1489 |         "function": "EMA",
1490 |         "symbol": symbol,
1491 |         "interval": interval,
1492 |         "month": month,
1493 |         "time_period": time_period,
1494 |         "series_type": series_type,
1495 |         "datatype": datatype,
1496 |         "apikey": API_KEY,
1497 |     }
1498 | 
1499 |     return await _make_api_request(https_params, datatype)
1500 | 
1501 | 
1502 | @instrument_tool("wma")
1503 | async def fetch_wma(
1504 |     symbol: str,
1505 |     interval: str = None,
1506 |     month: str = None,
1507 |     time_period: int = None,
1508 |     series_type: str = None,
1509 |     datatype: str = "json",
1510 | ) -> dict[str, str] | str:
1511 |     """
1512 |     Fetch weighted moving average (WMA) data from the Alpha Vantage API.
1513 | 
1514 |     :argument: symbol (str): The stock symbol to fetch.
1515 |     :argument: interval (str): The time interval for the data.
1516 |     :argument: month (str): The month for the data.
1517 |     :argument: time_period (int): The time period for the data.
1518 |     :argument: series_type (str): The series type for the data.
1519 |     :argument: datatype (str): The response data type (default: "json").
1520 | 
1521 |     :returns: The weighted moving average (WMA) data.
1522 |     """
1523 | 
1524 |     https_params = {
1525 |         "function": "WMA",
1526 |         "symbol": symbol,
1527 |         "interval": interval,
1528 |         "month": month,
1529 |         "time_period": time_period,
1530 |         "series_type": series_type,
1531 |         "datatype": datatype,
1532 |         "apikey": API_KEY,
1533 |     }
1534 | 
1535 |     return await _make_api_request(https_params, datatype)
1536 | 
1537 | 
1538 | @instrument_tool("dema")
1539 | async def fetch_dema(
1540 |     symbol: str,
1541 |     interval: str = None,
1542 |     month: str = None,
1543 |     time_period: int = None,
1544 |     series_type: str = None,
1545 |     datatype: str = "json",
1546 | ) -> dict[str, str] | str:
1547 |     """
1548 |     Fetch double exponential moving average (DEMA) data from the Alpha Vantage API.
1549 | 
1550 |     :argument: symbol (str): The stock symbol to fetch.
1551 |     :argument: interval (str): The time interval for the data.
1552 |     :argument: month (str): The month for the data.
1553 |     :argument: time_period (int): The time period for the data.
1554 |     :argument: series_type (str): The series type for the data.
1555 |     :argument: datatype (str): The response data type (default: "json").
1556 | 
1557 |     :returns: The double exponential moving average (DEMA) data.
1558 |     """
1559 | 
1560 |     https_params = {
1561 |         "function": "DEMA",
1562 |         "symbol": symbol,
1563 |         "interval": interval,
1564 |         "month": month,
1565 |         "time_period": time_period,
1566 |         "series_type": series_type,
1567 |         "datatype": datatype,
1568 |         "apikey": API_KEY,
1569 |     }
1570 | 
1571 |     return await _make_api_request(https_params, datatype)
1572 | 
1573 | 
1574 | @instrument_tool("tema")
1575 | async def fetch_tema(
1576 |     symbol: str,
1577 |     interval: str = None,
1578 |     month: str = None,
1579 |     time_period: int = None,
1580 |     series_type: str = None,
1581 |     datatype: str = "json",
1582 | ) -> dict[str, str] | str:
1583 |     """
1584 |     Fetch triple exponential moving average (TEMA) data from the Alpha Vantage API.
1585 | 
1586 |     :argument: symbol (str): The stock symbol to fetch.
1587 |     :argument: interval (str): The time interval for the data.
1588 |     :argument: month (str): The month for the data.
1589 |     :argument: time_period (int): The time period for the data.
1590 |     :argument: series_type (str): The series type for the data.
1591 |     :argument: datatype (str): The response data type (default: "json").
1592 | 
1593 |     :returns: The triple exponential moving average (TEMA) data.
1594 |     """
1595 | 
1596 |     https_params = {
1597 |         "function": "TEMA",
1598 |         "symbol": symbol,
1599 |         "interval": interval,
1600 |         "month": month,
1601 |         "time_period": time_period,
1602 |         "series_type": series_type,
1603 |         "datatype": datatype,
1604 |         "apikey": API_KEY,
1605 |     }
1606 | 
1607 |     return await _make_api_request(https_params, datatype)
1608 | 
1609 | 
1610 | @instrument_tool("trima")
1611 | async def fetch_trima(
1612 |     symbol: str,
1613 |     interval: str = None,
1614 |     month: str = None,
1615 |     time_period: int = None,
1616 |     series_type: str = None,
1617 |     datatype: str = "json",
1618 | ) -> dict[str, str] | str:
1619 |     """
1620 |     Fetch triangular moving average (TRIMA) data from the Alpha Vantage API.
1621 | 
1622 |     :argument: symbol (str): The stock symbol to fetch.
1623 |     :argument: interval (str): The time interval for the data.
1624 |     :argument: month (str): The month for the data.
1625 |     :argument: time_period (int): The time period for the data.
1626 |     :argument: series_type (str): The series type for the data.
1627 |     :argument: datatype (str): The response data type (default: "json").
1628 | 
1629 |     :returns: The triangular moving average (TRIMA) data.
1630 |     """
1631 | 
1632 |     https_params = {
1633 |         "function": "TRIMA",
1634 |         "symbol": symbol,
1635 |         "interval": interval,
1636 |         "month": month,
1637 |         "time_period": time_period,
1638 |         "series_type": series_type,
1639 |         "datatype": datatype,
1640 |         "apikey": API_KEY,
1641 |     }
1642 | 
1643 |     return await _make_api_request(https_params, datatype)
1644 | 
1645 | 
1646 | @instrument_tool("kama")
1647 | async def fetch_kama(
1648 |     symbol: str,
1649 |     interval: str = None,
1650 |     month: str = None,
1651 |     time_period: int = None,
1652 |     series_type: str = None,
1653 |     datatype: str = "json",
1654 | ) -> dict[str, str] | str:
1655 |     """
1656 |     Fetch Kaufman adaptive moving average (KAMA) data from the Alpha Vantage API.
1657 | 
1658 |     :argument: symbol (str): The stock symbol to fetch.
1659 |     :argument: interval (str): The time interval for the data.
1660 |     :argument: month (str): The month for the data.
1661 |     :argument: time_period (int): The time period for the data.
1662 |     :argument: series_type (str): The series type for the data.
1663 |     :argument: datatype (str): The response data type (default: "json").
1664 | 
1665 |     :returns: The Kaufman adaptive moving average (KAMA) data.
1666 |     """
1667 | 
1668 |     https_params = {
1669 |         "function": "KAMA",
1670 |         "symbol": symbol,
1671 |         "interval": interval,
1672 |         "month": month,
1673 |         "time_period": time_period,
1674 |         "series_type": series_type,
1675 |         "datatype": datatype,
1676 |         "apikey": API_KEY,
1677 |     }
1678 | 
1679 |     return await _make_api_request(https_params, datatype)
1680 | 
1681 | 
1682 | @instrument_tool("mama")
1683 | async def fetch_mama(
1684 |     symbol: str,
1685 |     interval: str = None,
1686 |     month: str = None,
1687 |     series_type: str = None,
1688 |     fastlimit: float = 0.01,
1689 |     slowlimit: float = 0.01,
1690 |     datatype: str = "json",
1691 | ) -> dict[str, str] | str:
1692 |     """
1693 |     Fetch MESA adaptive moving average (MAMA) data from the Alpha Vantage API.
1694 | 
1695 |     :argument: symbol (str): The stock symbol to fetch.
1696 |     :argument: interval (str): The time interval for the data.
1697 |     :argument: month (str): The month for the data.
1698 |     :argument: series_type (str): The series type for the data.
1699 |     :argument: fastlimit (float): The fast limit for the data.
1700 |     :argument: slowlimit (float): The slow limit for the data.
1701 |     :argument: datatype (str): The response data type (default: "json").
1702 | 
1703 |     :returns: The MESA adaptive moving average (MAMA) data.
1704 |     """
1705 | 
1706 |     https_params = {
1707 |         "function": "MAMA",
1708 |         "symbol": symbol,
1709 |         "interval": interval,
1710 |         "month": month,
1711 |         "series_type": series_type,
1712 |         "fastlimit": fastlimit,
1713 |         "slowlimit": slowlimit,
1714 |         "datatype": datatype,
1715 |         "apikey": API_KEY,
1716 |     }
1717 | 
1718 |     return await _make_api_request(https_params, datatype)
1719 | 
1720 | 
1721 | @instrument_tool("vwap")
1722 | async def fetch_vwap(
1723 |     symbol: str,
1724 |     interval: str = None,
1725 |     month: str = None,
1726 |     datatype: str = "json",
1727 | ) -> dict[str, str] | str:
1728 |     """
1729 |     Fetch volume weighted average price (VWAP) data from the Alpha Vantage API.
1730 | 
1731 |     :argument: symbol (str): The stock symbol to fetch.
1732 |     :argument: interval (str): The time interval for the data.
1733 |     :argument: month (str): The month for the data.
1734 |     :argument: datatype (str): The response data type (default: "json").
1735 | 
1736 |     :returns: The volume weighted average price (VWAP) data.
1737 |     """
1738 | 
1739 |     https_params = {
1740 |         "function": "VWAP",
1741 |         "symbol": symbol,
1742 |         "interval": interval,
1743 |         "month": month,
1744 |         "datatype": datatype,
1745 |         "apikey": API_KEY,
1746 |     }
1747 | 
1748 |     return await _make_api_request(https_params, datatype)
1749 | 
1750 | 
1751 | @instrument_tool("t3")
1752 | async def fetch_t3(
1753 |     symbol: str,
1754 |     interval: str = None,
1755 |     month: str = None,
1756 |     time_period: int = None,
1757 |     series_type: str = None,
1758 |     datatype: str = "json",
1759 | ) -> dict[str, str] | str:
1760 |     """
1761 |     Fetch triple exponential moving average (T3) data from the Alpha Vantage API.
1762 | 
1763 |     :argument: symbol (str): The stock symbol to fetch.
1764 |     :argument: interval (str): The time interval for the data.
1765 |     :argument: month (str): The month for the data.
1766 |     :argument: time_period (int): The time period for the data.
1767 |     :argument: series_type (str): The series type for the data.
1768 |     :argument: datatype (str): The response data type (default: "json").
1769 | 
1770 |     :returns: The triple exponential moving average (T3) data.
1771 |     """
1772 | 
1773 |     https_params = {
1774 |         "function": "T3",
1775 |         "symbol": symbol,
1776 |         "interval": interval,
1777 |         "month": month,
1778 |         "time_period": time_period,
1779 |         "series_type": series_type,
1780 |         "datatype": datatype,
1781 |         "apikey": API_KEY,
1782 |     }
1783 | 
1784 |     return await _make_api_request(https_params, datatype)
1785 | 
1786 | 
1787 | @instrument_tool("macd")
1788 | async def fetch_macd(
1789 |     symbol: str,
1790 |     interval: str = None,
1791 |     month: str = None,
1792 |     series_type: str = None,
1793 |     fastperiod: int = 12,
1794 |     slowperiod: int = 26,
1795 |     signalperiod: int = 9,
1796 |     datatype: str = "json",
1797 | ) -> dict[str, str] | str:
1798 |     """
1799 |     Fetch moving average convergence divergence (MACD) data from the Alpha Vantage API.
1800 | 
1801 |     :argument: symbol (str): The stock symbol to fetch.
1802 |     :argument: interval (str): The time interval for the data.
1803 |     :argument: month (str): The month for the data.
1804 |     :argument: series_type (str): The series type for the data.
1805 |     :argument: fastperiod (int): The fast period for the data.
1806 |     :argument: slowperiod (int): The slow period for the data.
1807 |     :argument: signalperiod (int): The signal period for the data.
1808 |     :argument: datatype (str): The response data type (default: "json").
1809 | 
1810 |     :returns: The moving average convergence divergence (MACD) data.
1811 |     """
1812 | 
1813 |     https_params = {
1814 |         "function": "MACD",
1815 |         "symbol": symbol,
1816 |         "interval": interval,
1817 |         "month": month,
1818 |         "series_type": series_type,
1819 |         "fastperiod": fastperiod,
1820 |         "slowperiod": slowperiod,
1821 |         "signalperiod": signalperiod,
1822 |         "datatype": datatype,
1823 |         "apikey": API_KEY,
1824 |     }
1825 | 
1826 |     return await _make_api_request(https_params, datatype)
1827 | 
1828 | 
1829 | @instrument_tool("macdext")
1830 | async def fetch_macdext(
1831 |     symbol: str,
1832 |     interval: str = None,
1833 |     month: str = None,
1834 |     series_type: str = None,
1835 |     fastperiod: int = 12,
1836 |     slowperiod: int = 26,
1837 |     signalperiod: int = 9,
1838 |     fastmatype: int = 0,
1839 |     slowmatype: int = 0,
1840 |     signalmatype: int = 0,
1841 |     datatype: str = "json",
1842 | ) -> dict[str, str] | str:
1843 |     """
1844 |     Fetch moving average convergence divergence with controllable moving average type (MACDEXT) data from the Alpha Vantage API.
1845 | 
1846 |     :argument: symbol (str): The stock symbol to fetch.
1847 |     :argument: interval (str): The time interval for the data.
1848 |     :argument: month (str): The month for the data.
1849 |     :argument: series_type (str): The series type for the data.
1850 |     :argument: fastperiod (int): The fast period for the data.
1851 |     :argument: slowperiod (int): The slow period for the data.
1852 |     :argument: signalperiod (int): The signal period for the data.
1853 |     :argument: fastmatype (int): The fast moving average type for the data.
1854 |     :argument: slowmatype (int): The slow moving average type for the data.
1855 |     :argument: signalmatype (int): The signal moving average type for the data.
1856 |     :argument: datatype (str): The response data type (default: "json").
1857 | 
1858 |     :returns: The moving average convergence divergence with controllable moving average type (MACDEXT) data.
1859 |     """
1860 | 
1861 |     https_params = {
1862 |         "function": "MACDEXT",
1863 |         "symbol": symbol,
1864 |         "interval": interval,
1865 |         "month": month,
1866 |         "series_type": series_type,
1867 |         "fastperiod": fastperiod,
1868 |         "slowperiod": slowperiod,
1869 |         "signalperiod": signalperiod,
1870 |         "fastmatype": fastmatype,
1871 |         "slowmatype": slowmatype,
1872 |         "signalmatype": signalmatype,
1873 |         "datatype": datatype,
1874 |         "apikey": API_KEY,
1875 |     }
1876 | 
1877 |     return await _make_api_request(https_params, datatype)
1878 | 
1879 | 
1880 | @instrument_tool("stoch")
1881 | async def fetch_stoch(
1882 |     symbol: str,
1883 |     interval: str = None,
1884 |     month: str = None,
1885 |     fastkperiod: int = 5,
1886 |     slowkperiod: int = 3,
1887 |     slowdperiod: int = 3,
1888 |     slowkmatype: int = 0,
1889 |     slowdmatype: int = 0,
1890 |     datatype: str = "json",
1891 | ) -> dict[str, str] | str:
1892 |     """
1893 |     Fetch stochastic oscillator (STOCH) data from the Alpha Vantage API.
1894 | 
1895 |     :argument: symbol (str): The stock symbol to fetch.
1896 |     :argument: interval (str): The time interval for the data.
1897 |     :argument: month (str): The month for the data.
1898 |     :argument: fastkperiod (int): The fast K period for the data.
1899 |     :argument: slowkperiod (int): The slow K period for the data.
1900 |     :argument: slowdperiod (int): The slow D period for the data.
1901 |     :argument: slowkmatype (int): The slow K moving average type for the data.
1902 |     :argument: slowdmatype (int): The slow D moving average type for the data.
1903 |     :argument: datatype (str): The response data type (default: "json").
1904 | 
1905 |     :returns: The stochastic oscillator (STOCH) data.
1906 |     """
1907 | 
1908 |     https_params = {
1909 |         "function": "STOCH",
1910 |         "symbol": symbol,
1911 |         "interval": interval,
1912 |         "month": month,
1913 |         "fastkperiod": fastkperiod,
1914 |         "slowkperiod": slowkperiod,
1915 |         "slowdperiod": slowdperiod,
1916 |         "slowkmatype": slowkmatype,
1917 |         "slowdmatype": slowdmatype,
1918 |         "datatype": datatype,
1919 |         "apikey": API_KEY,
1920 |     }
1921 | 
1922 |     return await _make_api_request(https_params, datatype)
1923 | 
1924 | 
1925 | @instrument_tool("stochf")
1926 | async def fetch_stochf(
1927 |     symbol: str,
1928 |     interval: str = None,
1929 |     month: str = None,
1930 |     fastkperiod: int = 5,
1931 |     fastdperiod: int = 3,
1932 |     fastdmatype: int = 0,
1933 |     datatype: str = "json",
1934 | ) -> dict[str, str] | str:
1935 |     """
1936 |     Fetch stochastic oscillator fast (STOCHF) data from the Alpha Vantage API.
1937 | 
1938 |     :argument: symbol (str): The stock symbol to fetch.
1939 |     :argument: interval (str): The time interval for the data.
1940 |     :argument: month (str): The month for the data.
1941 |     :argument: fastkperiod (int): The fast K period for the data.
1942 |     :argument: fastdperiod (int): The fast D period for the data.
1943 |     :argument: fastdmatype (int): The fast D moving average type for the data.
1944 |     :argument: datatype (str): The response data type (default: "json").
1945 | 
1946 |     :returns: The stochastic oscillator fast (STOCHF) data.
1947 |     """
1948 | 
1949 |     https_params = {
1950 |         "function": "STOCHF",
1951 |         "symbol": symbol,
1952 |         "interval": interval,
1953 |         "month": month,
1954 |         "fastkperiod": fastkperiod,
1955 |         "fastdperiod": fastdperiod,
1956 |         "fastdmatype": fastdmatype,
1957 |         "datatype": datatype,
1958 |         "apikey": API_KEY,
1959 |     }
1960 | 
1961 |     return await _make_api_request(https_params, datatype)
1962 | 
1963 | 
1964 | @instrument_tool("rsi")
1965 | async def fetch_rsi(
1966 |     symbol: str,
1967 |     interval: str = None,
1968 |     month: str = None,
1969 |     time_period: int = 14,
1970 |     series_type: str = None,
1971 |     datatype: str = "json",
1972 | ) -> dict[str, str] | str:
1973 |     """
1974 |     Fetch relative strength index (RSI) data from the Alpha Vantage API.
1975 | 
1976 |     :argument: symbol (str): The stock symbol to fetch.
1977 |     :argument: interval (str): The time interval for the data.
1978 |     :argument: month (str): The month for the data.
1979 |     :argument: time_period (int): The time period for the data.
1980 |     :argument: series_type (str): The series type for the data.
1981 |     :argument: datatype (str): The response data type (default: "json").
1982 | 
1983 |     :returns: The relative strength index (RSI) data.
1984 |     """
1985 | 
1986 |     https_params = {
1987 |         "function": "RSI",
1988 |         "symbol": symbol,
1989 |         "interval": interval,
1990 |         "month": month,
1991 |         "time_period": time_period,
1992 |         "series_type": series_type,
1993 |         "datatype": datatype,
1994 |         "apikey": API_KEY,
1995 |     }
1996 | 
1997 |     return await _make_api_request(https_params, datatype)
1998 | 
1999 | 
2000 | @instrument_tool("stochrsi")
2001 | async def fetch_stochrsi(
2002 |     symbol: str,
2003 |     interval: str = None,
2004 |     month: str = None,
2005 |     time_period: int = 14,
2006 |     series_type: str = None,
2007 |     fastkperiod: int = 5,
2008 |     fastdperiod: int = 3,
2009 |     fastdmatype: int = 0,
2010 |     datatype: str = "json",
2011 | ) -> dict[str, str] | str:
2012 |     """
2013 |     Fetch stochastic relative strength index (STOCHRSI) data from the Alpha Vantage API.
2014 | 
2015 |     :argument: symbol (str): The stock symbol to fetch.
2016 |     :argument: interval (str): The time interval for the data.
2017 |     :argument: month (str): The month for the data.
2018 |     :argument: time_period (int): The time period for the data.
2019 |     :argument: series_type (str): The series type for the data.
2020 |     :argument: fastkperiod (int): The fast K period for the data.
2021 |     :argument: fastdperiod (int): The fast D period for the data.
2022 |     :argument: fastdmatype (int): The fast D moving average type for the data.
2023 |     :argument: datatype (str): The response data type (default: "json").
2024 | 
2025 |     :returns: The stochastic relative strength index (STOCHRSI) data.
2026 |     """
2027 | 
2028 |     https_params = {
2029 |         "function": "STOCHRSI",
2030 |         "symbol": symbol,
2031 |         "interval": interval,
2032 |         "month": month,
2033 |         "time_period": time_period,
2034 |         "series_type": series_type,
2035 |         "fastkperiod": fastkperiod,
2036 |         "fastdperiod": fastdperiod,
2037 |         "fastdmatype": fastdmatype,
2038 |         "datatype": datatype,
2039 |         "apikey": API_KEY,
2040 |     }
2041 | 
2042 |     return await _make_api_request(https_params, datatype)
2043 | 
2044 | 
2045 | @instrument_tool("willr")
2046 | async def fetch_willr(
2047 |     symbol: str,
2048 |     interval: str = None,
2049 |     month: str = None,
2050 |     time_period: int = 14,
2051 |     datatype: str = "json",
2052 | ) -> dict[str, str] | str:
2053 |     """
2054 |     Fetch Williams' %R (WILLR) data from the Alpha Vantage API.
2055 | 
2056 |     :argument: symbol (str): The stock symbol to fetch.
2057 |     :argument: interval (str): The time interval for the data.
2058 |     :argument: month (str): The month for the data.
2059 |     :argument: time_period (int): The time period for the data.
2060 |     :argument: datatype (str): The response data type (default: "json").
2061 | 
2062 |     :returns: Williams' %R (WILLR) data.
2063 |     """
2064 | 
2065 |     https_params = {
2066 |         "function": "WILLR",
2067 |         "symbol": symbol,
2068 |         "interval": interval,
2069 |         "month": month,
2070 |         "time_period": time_period,
2071 |         "datatype": datatype,
2072 |         "apikey": API_KEY,
2073 |     }
2074 | 
2075 |     return await _make_api_request(https_params, datatype)
2076 | 
2077 | 
2078 | @instrument_tool("adx")
2079 | async def fetch_adx(
2080 |     symbol: str,
2081 |     interval: str = None,
2082 |     month: str = None,
2083 |     time_period: int = 14,
2084 |     datatype: str = "json",
2085 | ) -> dict[str, str] | str:
2086 |     """
2087 |     Fetch average directional movement index (ADX) data from the Alpha Vantage API.
2088 | 
2089 |     :argument: symbol (str): The stock symbol to fetch.
2090 |     :argument: interval (str): The time interval for the data.
2091 |     :argument: month (str): The month for the data.
2092 |     :argument: time_period (int): The time period for the data.
2093 |     :argument: datatype (str): The response data type (default: "json").
2094 | 
2095 |     :returns: Average directional movement index (ADX) data.
2096 |     """
2097 | 
2098 |     https_params = {
2099 |         "function": "ADX",
2100 |         "symbol": symbol,
2101 |         "interval": interval,
2102 |         "month": month,
2103 |         "time_period": time_period,
2104 |         "datatype": datatype,
2105 |         "apikey": API_KEY,
2106 |     }
2107 | 
2108 |     return await _make_api_request(https_params, datatype)
2109 | 
2110 | 
2111 | @instrument_tool("adxr")
2112 | async def fetch_adxr(
2113 |     symbol: str,
2114 |     interval: str = None,
2115 |     month: str = None,
2116 |     time_period: int = 14,
2117 |     datatype: str = "json",
2118 | ) -> dict[str, str] | str:
2119 |     """
2120 |     Fetch average directional movement index rating (ADXR) data from the Alpha Vantage API.
2121 | 
2122 |     :argument: symbol (str): The stock symbol to fetch.
2123 |     :argument: interval (str): The time interval for the data.
2124 |     :argument: month (str): The month for the data.
2125 |     :argument: time_period (int): The time period for the data.
2126 |     :argument: datatype (str): The response data type (default: "json").
2127 | 
2128 |     :returns: Average directional movement index rating (ADXR) data.
2129 |     """
2130 | 
2131 |     https_params = {
2132 |         "function": "ADXR",
2133 |         "symbol": symbol,
2134 |         "interval": interval,
2135 |         "month": month,
2136 |         "time_period": time_period,
2137 |         "datatype": datatype,
2138 |         "apikey": API_KEY,
2139 |     }
2140 | 
2141 |     return await _make_api_request(https_params, datatype)
2142 | 
2143 | 
2144 | @instrument_tool("apo")
2145 | async def fetch_apo(
2146 |     symbol: str,
2147 |     interval: str = None,
2148 |     month: str = None,
2149 |     series_type: str = None,
2150 |     fastperiod: int = 12,
2151 |     slowperiod: int = 26,
2152 |     matype: int = 0,
2153 |     datatype: str = "json",
2154 | ) -> dict[str, str] | str:
2155 |     """
2156 |     Fetch absolute price oscillator (APO) data from the Alpha Vantage API.
2157 | 
2158 |     :argument: symbol (str): The stock symbol to fetch.
2159 |     :argument: interval (str): The time interval for the data.
2160 |     :argument: month (str): The month for the data.
2161 |     :argument: series_type (str): The series type for the data.
2162 |     :argument: fastperiod (int): The fast period for the data.
2163 |     :argument: slowperiod (int): The slow period for the data.
2164 |     :argument: matype (int): The moving average type for the data.
2165 |     :argument: datatype (str): The response data type (default: "json").
2166 | 
2167 |     :returns: Absolute price oscillator (APO) data.
2168 |     """
2169 | 
2170 |     https_params = {
2171 |         "function": "APO",
2172 |         "symbol": symbol,
2173 |         "interval": interval,
2174 |         "month": month,
2175 |         "series_type": series_type,
2176 |         "fastperiod": fastperiod,
2177 |         "slowperiod": slowperiod,
2178 |         "matype": matype,
2179 |         "datatype": datatype,
2180 |         "apikey": API_KEY,
2181 |     }
2182 | 
2183 |     return await _make_api_request(https_params, datatype)
2184 | 
2185 | 
2186 | @instrument_tool("ppo")
2187 | async def fetch_ppo(
2188 |     symbol: str,
2189 |     interval: str = None,
2190 |     month: str = None,
2191 |     series_type: str = None,
2192 |     fastperiod: int = 12,
2193 |     slowperiod: int = 26,
2194 |     matype: int = 0,
2195 |     datatype: str = "json",
2196 | ) -> dict[str, str] | str:
2197 |     """
2198 |     Fetch percentage price oscillator (PPO) data from the Alpha Vantage API.
2199 | 
2200 |     :argument: symbol (str): The stock symbol to fetch.
2201 |     :argument: interval (str): The time interval for the data.
2202 |     :argument: month (str): The month for the data.
2203 |     :argument: series_type (str): The series type for the data.
2204 |     :argument: fastperiod (int): The fast period for the data.
2205 |     :argument: slowperiod (int): The slow period for the data.
2206 |     :argument: matype (int): The moving average type for the data.
2207 |     :argument: datatype (str): The response data type (default: "json").
2208 | 
2209 |     :returns: Percentage price oscillator (PPO) data.
2210 |     """
2211 | 
2212 |     https_params = {
2213 |         "function": "PPO",
2214 |         "symbol": symbol,
2215 |         "interval": interval,
2216 |         "month": month,
2217 |         "series_type": series_type,
2218 |         "fastperiod": fastperiod,
2219 |         "slowperiod": slowperiod,
2220 |         "matype": matype,
2221 |         "datatype": datatype,
2222 |         "apikey": API_KEY,
2223 |     }
2224 | 
2225 |     return await _make_api_request(https_params, datatype)
2226 | 
2227 | 
2228 | @instrument_tool("mom")
2229 | async def fetch_mom(
2230 |     symbol: str,
2231 |     interval: str = None,
2232 |     month: str = None,
2233 |     time_period: int = 10,
2234 |     series_type: str = None,
2235 |     datatype: str = "json",
2236 | ) -> dict[str, str] | str:
2237 |     """
2238 |     Fetch momentum (MOM) data from the Alpha Vantage API.
2239 | 
2240 |     :argument: symbol (str): The stock symbol to fetch.
2241 |     :argument: interval (str): The time interval for the data.
2242 |     :argument: month (str): The month for the data.
2243 |     :argument: time_period (int): The time period for the data.
2244 |     :argument: series_type (str): The series type for the data.
2245 |     :argument: datatype (str): The response data type (default: "json").
2246 | 
2247 |     :returns: Momentum (MOM) data.
2248 |     """
2249 | 
2250 |     https_params = {
2251 |         "function": "MOM",
2252 |         "symbol": symbol,
2253 |         "interval": interval,
2254 |         "month": month,
2255 |         "time_period": time_period,
2256 |         "series_type": series_type,
2257 |         "datatype": datatype,
2258 |         "apikey": API_KEY,
2259 |     }
2260 | 
2261 |     return await _make_api_request(https_params, datatype)
2262 | 
2263 | 
2264 | @instrument_tool("bop")
2265 | async def fetch_bop(
2266 |     symbol: str,
2267 |     interval: str = None,
2268 |     month: str = None,
2269 |     datatype: str = "json",
2270 | ) -> dict[str, str] | str:
2271 |     """
2272 |     Fetch balance of power (BOP) data from the Alpha Vantage API.
2273 | 
2274 |     :argument: symbol (str): The stock symbol to fetch.
2275 |     :argument: interval (str): The time interval for the data.
2276 |     :argument: month (str): The month for the data.
2277 |     :argument: datatype (str): The response data type (default: "json").
2278 | 
2279 |     :returns: Balance of power (BOP) data.
2280 |     """
2281 | 
2282 |     https_params = {
2283 |         "function": "BOP",
2284 |         "symbol": symbol,
2285 |         "interval": interval,
2286 |         "month": month,
2287 |         "datatype": datatype,
2288 |         "apikey": API_KEY,
2289 |     }
2290 | 
2291 |     return await _make_api_request(https_params, datatype)
2292 | 
2293 | 
2294 | @instrument_tool("cci")
2295 | async def fetch_cci(
2296 |     symbol: str,
2297 |     interval: str = None,
2298 |     month: str = None,
2299 |     time_period: int = 20,
2300 |     datatype: str = "json",
2301 | ) -> dict[str, str] | str:
2302 |     """
2303 |     Fetch commodity channel index (CCI) data from the Alpha Vantage API.
2304 | 
2305 |     :argument: symbol (str): The stock symbol to fetch.
2306 |     :argument: interval (str): The time interval for the data.
2307 |     :argument: month (str): The month for the data.
2308 |     :argument: time_period (int): The time period for the data.
2309 |     :argument: datatype (str): The response data type (default: "json").
2310 | 
2311 |     :returns: Commodity channel index (CCI) data.
2312 |     """
2313 | 
2314 |     https_params = {
2315 |         "function": "CCI",
2316 |         "symbol": symbol,
2317 |         "interval": interval,
2318 |         "month": month,
2319 |         "time_period": time_period,
2320 |         "datatype": datatype,
2321 |         "apikey": API_KEY,
2322 |     }
2323 | 
2324 |     return await _make_api_request(https_params, datatype)
2325 | 
2326 | 
2327 | @instrument_tool("cmo")
2328 | async def fetch_cmo(
2329 |     symbol: str,
2330 |     interval: str = None,
2331 |     month: str = None,
2332 |     time_period: int = 14,
2333 |     series_type: str = None,
2334 |     datatype: str = "json",
2335 | ) -> dict[str, str] | str:
2336 |     """
2337 |     Fetch Chande momentum oscillator (CMO) data from the Alpha Vantage API.
2338 | 
2339 |     :argument: symbol (str): The stock symbol to fetch.
2340 |     :argument: interval (str): The time interval for the data.
2341 |     :argument: month (str): The month for the data.
2342 |     :argument: time_period (int): The time period for the data.
2343 |     :argument: series_type (str): The series type for the data.
2344 |     :argument: datatype (str): The response data type (default: "json").
2345 | 
2346 |     :returns: Chande momentum oscillator (CMO) data.
2347 |     """
2348 | 
2349 |     https_params = {
2350 |         "function": "CMO",
2351 |         "symbol": symbol,
2352 |         "interval": interval,
2353 |         "month": month,
2354 |         "time_period": time_period,
2355 |         "series_type": series_type,
2356 |         "datatype": datatype,
2357 |         "apikey": API_KEY,
2358 |     }
2359 | 
2360 |     return await _make_api_request(https_params, datatype)
2361 | 
2362 | 
2363 | @instrument_tool("roc")
2364 | async def fetch_roc(
2365 |     symbol: str,
2366 |     interval: str = None,
2367 |     month: str = None,
2368 |     time_period: int = 10,
2369 |     series_type: str = None,
2370 |     datatype: str = "json",
2371 | ) -> dict[str, str] | str:
2372 |     """
2373 |     Fetch rate of change (ROC) data from the Alpha Vantage API.
2374 | 
2375 |     :argument: symbol (str): The stock symbol to fetch.
2376 |     :argument: interval (str): The time interval for the data.
2377 |     :argument: month (str): The month for the data.
2378 |     :argument: time_period (int): The time period for the data.
2379 |     :argument: series_type (str): The series type for the data.
2380 |     :argument: datatype (str): The response data type (default: "json").
2381 | 
2382 |     :returns: Rate of change (ROC) data.
2383 |     """
2384 | 
2385 |     https_params = {
2386 |         "function": "ROC",
2387 |         "symbol": symbol,
2388 |         "interval": interval,
2389 |         "month": month,
2390 |         "time_period": time_period,
2391 |         "series_type": series_type,
2392 |         "datatype": datatype,
2393 |         "apikey": API_KEY,
2394 |     }
2395 | 
2396 |     return await _make_api_request(https_params, datatype)
2397 | 
2398 | 
2399 | @instrument_tool("rocr")
2400 | async def fetch_rocr(
2401 |     symbol: str,
2402 |     interval: str = None,
2403 |     month: str = None,
2404 |     time_period: int = 10,
2405 |     series_type: str = None,
2406 |     datatype: str = "json",
2407 | ) -> dict[str, str] | str:
2408 |     """
2409 |     Fetch rate of change ratio (ROCR) data from the Alpha Vantage API.
2410 | 
2411 |     :argument: symbol (str): The stock symbol to fetch.
2412 |     :argument: interval (str): The time interval for the data.
2413 |     :argument: month (str): The month for the data.
2414 |     :argument: time_period (int): The time period for the data.
2415 |     :argument: series_type (str): The series type for the data.
2416 |     :argument: datatype (str): The response data type (default: "json").
2417 | 
2418 |     :returns: Rate of change ratio (ROCR) data.
2419 |     """
2420 | 
2421 |     https_params = {
2422 |         "function": "ROCR",
2423 |         "symbol": symbol,
2424 |         "interval": interval,
2425 |         "month": month,
2426 |         "time_period": time_period,
2427 |         "series_type": series_type,
2428 |         "datatype": datatype,
2429 |         "apikey": API_KEY,
2430 |     }
2431 | 
2432 |     return await _make_api_request(https_params, datatype)
2433 | 
2434 | 
2435 | @instrument_tool("aroon")
2436 | async def fetch_aroon(
2437 |     symbol: str,
2438 |     interval: str = None,
2439 |     month: str = None,
2440 |     time_period: int = 14,
2441 |     datatype: str = "json",
2442 | ) -> dict[str, str] | str:
2443 |     """
2444 |     Fetch aroon (AROON) data from the Alpha Vantage API.
2445 | 
2446 |     :argument: symbol (str): The stock symbol to fetch.
2447 |     :argument: interval (str): The time interval for the data.
2448 |     :argument: month (str): The month for the data.
2449 |     :argument: time_period (int): The time period for the data.
2450 |     :argument: datatype (str): The response data type (default: "json").
2451 | 
2452 |     :returns: Aroon (AROON) data.
2453 |     """
2454 | 
2455 |     https_params = {
2456 |         "function": "AROON",
2457 |         "symbol": symbol,
2458 |         "interval": interval,
2459 |         "month": month,
2460 |         "time_period": time_period,
2461 |         "datatype": datatype,
2462 |         "apikey": API_KEY,
2463 |     }
2464 | 
2465 |     return await _make_api_request(https_params, datatype)
2466 | 
2467 | 
2468 | @instrument_tool("aroonosc")
2469 | async def fetch_aroonosc(
2470 |     symbol: str,
2471 |     interval: str = None,
2472 |     month: str = None,
2473 |     time_period: int = 14,
2474 |     datatype: str = "json",
2475 | ) -> dict[str, str] | str:
2476 |     """
2477 |     Fetch aroon oscillator (AROONOSC) data from the Alpha Vantage API.
2478 | 
2479 |     :argument: symbol (str): The stock symbol to fetch.
2480 |     :argument: interval (str): The time interval for the data.
2481 |     :argument: month (str): The month for the data.
2482 |     :argument: time_period (int): The time period for the data.
2483 |     :argument: datatype (str): The response data type (default: "json").
2484 | 
2485 |     :returns: Aroon oscillator (AROONOSC) data.
2486 |     """
2487 | 
2488 |     https_params = {
2489 |         "function": "AROONOSC",
2490 |         "symbol": symbol,
2491 |         "interval": interval,
2492 |         "month": month,
2493 |         "time_period": time_period,
2494 |         "datatype": datatype,
2495 |         "apikey": API_KEY,
2496 |     }
2497 | 
2498 |     return await _make_api_request(https_params, datatype)
2499 | 
2500 | 
2501 | @instrument_tool("mfi")
2502 | async def fetch_mfi(
2503 |     symbol: str,
2504 |     interval: str = None,
2505 |     month: str = None,
2506 |     time_period: int = 14,
2507 |     datatype: str = "json",
2508 | ) -> dict[str, str] | str:
2509 |     """
2510 |     Fetch money flow index (MFI) data from the Alpha Vantage API.
2511 | 
2512 |     :argument: symbol (str): The stock symbol to fetch.
2513 |     :argument: interval (str): The time interval for the data.
2514 |     :argument: month (str): The month for the data.
2515 |     :argument: time_period (int): The time period for the data.
2516 |     :argument: datatype (str): The response data type (default: "json").
2517 | 
2518 |     :returns: Money flow index (MFI) data.
2519 |     """
2520 | 
2521 |     https_params = {
2522 |         "function": "MFI",
2523 |         "symbol": symbol,
2524 |         "interval": interval,
2525 |         "month": month,
2526 |         "time_period": time_period,
2527 |         "datatype": datatype,
2528 |         "apikey": API_KEY,
2529 |     }
2530 | 
2531 |     return await _make_api_request(https_params, datatype)
2532 | 
2533 | 
2534 | @instrument_tool("trix")
2535 | async def fetch_trix(
2536 |     symbol: str,
2537 |     interval: str = None,
2538 |     month: str = None,
2539 |     time_period: int = 30,
2540 |     series_type: str = None,
2541 |     datatype: str = "json",
2542 | ) -> dict[str, str] | str:
2543 |     """
2544 |     Fetch triple exponential average (TRIX) data from the Alpha Vantage API.
2545 | 
2546 |     :argument: symbol (str): The stock symbol to fetch.
2547 |     :argument: interval (str): The time interval for the data.
2548 |     :argument: month (str): The month for the data.
2549 |     :argument: time_period (int): The time period for the data.
2550 |     :argument: series_type (str): The series type for the data.
2551 |     :argument: datatype (str): The response data type (default: "json").
2552 | 
2553 |     :returns: Triple exponential average (TRIX) data.
2554 |     """
2555 | 
2556 |     https_params = {
2557 |         "function": "TRIX",
2558 |         "symbol": symbol,
2559 |         "interval": interval,
2560 |         "month": month,
2561 |         "time_period": time_period,
2562 |         "series_type": series_type,
2563 |         "datatype": datatype,
2564 |         "apikey": API_KEY,
2565 |     }
2566 | 
2567 |     return await _make_api_request(https_params, datatype)
2568 | 
2569 | 
2570 | @instrument_tool("ultosc")
2571 | async def fetch_ultosc(
2572 |     symbol: str,
2573 |     interval: str = None,
2574 |     month: str = None,
2575 |     timeperiod1: int = 7,
2576 |     timeperiod2: int = 14,
2577 |     timeperiod3: int = 28,
2578 |     datatype: str = "json",
2579 | ) -> dict[str, str] | str:
2580 |     """
2581 |     Fetch ultimate oscillator (ULTOSC) data from the Alpha Vantage API.
2582 | 
2583 |     :argument: symbol (str): The stock symbol to fetch.
2584 |     :argument: interval (str): The time interval for the data.
2585 |     :argument: month (str): The month for the data.
2586 |     :argument: timeperiod1 (int): The time period for the first calculation.
2587 |     :argument: timeperiod2 (int): The time period for the second calculation.
2588 |     :argument: timeperiod3 (int): The time period for the third calculation.
2589 |     :argument: datatype (str): The response data type (default: "json").
2590 | 
2591 |     :returns: Ultimate oscillator (ULTOSC) data.
2592 |     """
2593 | 
2594 |     https_params = {
2595 |         "function": "ULTOSC",
2596 |         "symbol": symbol,
2597 |         "interval": interval,
2598 |         "month": month,
2599 |         "timeperiod1": timeperiod1,
2600 |         "timeperiod2": timeperiod2,
2601 |         "timeperiod3": timeperiod3,
2602 |         "datatype": datatype,
2603 |         "apikey": API_KEY,
2604 |     }
2605 | 
2606 |     return await _make_api_request(https_params, datatype)
2607 | 
2608 | 
2609 | @instrument_tool("dx")
2610 | async def fetch_dx(
2611 |     symbol: str,
2612 |     interval: str = None,
2613 |     month: str = None,
2614 |     time_period: int = 14,
2615 |     datatype: str = "json",
2616 | ) -> dict[str, str] | str:
2617 |     """
2618 |     Fetch directional movement index (DX) data from the Alpha Vantage API.
2619 | 
2620 |     :argument: symbol (str): The stock symbol to fetch.
2621 |     :argument: interval (str): The time interval for the data.
2622 |     :argument: month (str): The month for the data.
2623 |     :argument: time_period (int): The time period for the data.
2624 |     :argument: datatype (str): The response data type (default: "json").
2625 | 
2626 |     :returns: Directional movement index (DX) data.
2627 |     """
2628 | 
2629 |     https_params = {
2630 |         "function": "DX",
2631 |         "symbol": symbol,
2632 |         "interval": interval,
2633 |         "month": month,
2634 |         "time_period": time_period,
2635 |         "datatype": datatype,
2636 |         "apikey": API_KEY,
2637 |     }
2638 | 
2639 |     return await _make_api_request(https_params, datatype)
2640 | 
2641 | 
2642 | @instrument_tool("minus_di")
2643 | async def fetch_minus_di(
2644 |     symbol: str,
2645 |     interval: str = None,
2646 |     month: str = None,
2647 |     time_period: int = 14,
2648 |     datatype: str = "json",
2649 | ) -> dict[str, str] | str:
2650 |     """
2651 |     Fetch minus directional indicator (MINUS_DI) data from the Alpha Vantage API.
2652 | 
2653 |     :argument: symbol (str): The stock symbol to fetch.
2654 |     :argument: interval (str): The time interval for the data.
2655 |     :argument: month (str): The month for the data.
2656 |     :argument: time_period (int): The time period for the data.
2657 |     :argument: datatype (str): The response data type (default: "json").
2658 | 
2659 |     :returns: Minus directional indicator (MINUS_DI) data.
2660 |     """
2661 | 
2662 |     https_params = {
2663 |         "function": "MINUS_DI",
2664 |         "symbol": symbol,
2665 |         "interval": interval,
2666 |         "month": month,
2667 |         "time_period": time_period,
2668 |         "datatype": datatype,
2669 |         "apikey": API_KEY,
2670 |     }
2671 | 
2672 |     return await _make_api_request(https_params, datatype)
2673 | 
2674 | 
2675 | @instrument_tool("plus_di")
2676 | async def fetch_plus_di(
2677 |     symbol: str,
2678 |     interval: str = None,
2679 |     month: str = None,
2680 |     time_period: int = 14,
2681 |     datatype: str = "json",
2682 | ) -> dict[str, str] | str:
2683 |     """
2684 |     Fetch plus directional indicator (PLUS_DI) data from the Alpha Vantage API.
2685 | 
2686 |     :argument: symbol (str): The stock symbol to fetch.
2687 |     :argument: interval (str): The time interval for the data.
2688 |     :argument: month (str): The month for the data.
2689 |     :argument: time_period (int): The time period for the data.
2690 |     :argument: datatype (str): The response data type (default: "json").
2691 | 
2692 |     :returns: Plus directional indicator (PLUS_DI) data.
2693 |     """
2694 | 
2695 |     https_params = {
2696 |         "function": "PLUS_DI",
2697 |         "symbol": symbol,
2698 |         "interval": interval,
2699 |         "month": month,
2700 |         "time_period": time_period,
2701 |         "datatype": datatype,
2702 |         "apikey": API_KEY,
2703 |     }
2704 | 
2705 |     return await _make_api_request(https_params, datatype)
2706 | 
2707 | 
2708 | @instrument_tool("minus_dm")
2709 | async def fetch_minus_dm(
2710 |     symbol: str,
2711 |     interval: str = None,
2712 |     month: str = None,
2713 |     time_period: int = 14,
2714 |     datatype: str = "json",
2715 | ) -> dict[str, str] | str:
2716 |     """
2717 |     Fetch minus directional movement (MINUS_DM) data from the Alpha Vantage API.
2718 | 
2719 |     :argument: symbol (str): The stock symbol to fetch.
2720 |     :argument: interval (str): The time interval for the data.
2721 |     :argument: month (str): The month for the data.
2722 |     :argument: time_period (int): The time period for the data.
2723 |     :argument: datatype (str): The response data type (default: "json").
2724 | 
2725 |     :returns: Minus directional movement (MINUS_DM) data.
2726 |     """
2727 | 
2728 |     https_params = {
2729 |         "function": "MINUS_DM",
2730 |         "symbol": symbol,
2731 |         "interval": interval,
2732 |         "month": month,
2733 |         "time_period": time_period,
2734 |         "datatype": datatype,
2735 |         "apikey": API_KEY,
2736 |     }
2737 | 
2738 |     return await _make_api_request(https_params, datatype)
2739 | 
2740 | 
2741 | @instrument_tool("plus_dm")
2742 | async def fetch_plus_dm(
2743 |     symbol: str,
2744 |     interval: str = None,
2745 |     month: str = None,
2746 |     time_period: int = 14,
2747 |     datatype: str = "json",
2748 | ) -> dict[str, str] | str:
2749 |     """
2750 |     Fetch plus directional movement (PLUS_DM) data from the Alpha Vantage API.
2751 | 
2752 |     :argument: symbol (str): The stock symbol to fetch.
2753 |     :argument: interval (str): The time interval for the data.
2754 |     :argument: month (str): The month for the data.
2755 |     :argument: time_period (int): The time period for the data.
2756 |     :argument: datatype (str): The response data type (default: "json").
2757 | 
2758 |     :returns: Plus directional movement (PLUS_DM) data.
2759 |     """
2760 | 
2761 |     https_params = {
2762 |         "function": "PLUS_DM",
2763 |         "symbol": symbol,
2764 |         "interval": interval,
2765 |         "month": month,
2766 |         "time_period": time_period,
2767 |         "datatype": datatype,
2768 |         "apikey": API_KEY,
2769 |     }
2770 | 
2771 |     return await _make_api_request(https_params, datatype)
2772 | 
2773 | 
2774 | @instrument_tool("bbands")
2775 | async def fetch_bbands(
2776 |     symbol: str,
2777 |     interval: str = None,
2778 |     month: str = None,
2779 |     time_period: int = 5,
2780 |     series_type: str = "close",
2781 |     nbdevup: int = 2,
2782 |     nbdevdn: int = 2,
2783 |     matype: int = 0,
2784 |     datatype: str = "json",
2785 | ) -> dict[str, str] | str:
2786 |     """
2787 |     Fetch bollinger bands (BBANDS) data from the Alpha Vantage API.
2788 | 
2789 |     :argument: symbol (str): The stock symbol to fetch.
2790 |     :argument: interval (str): The time interval for the data.
2791 |     :argument: month (str): The month for the data.
2792 |     :argument: time_period (int): The time period for the data.
2793 |     :argument: series_type (str): The series type for the data.
2794 |     :argument: nbdevup (int): The standard deviation multiplier for the upper band.
2795 |     :argument: nbdevdn (int): The standard deviation multiplier for the lower band.
2796 |     :argument: matype (int): The moving average type for the data.
2797 |     :argument: datatype (str): The response data type (default: "json").
2798 | 
2799 |     :returns: Bollinger bands (BBANDS) data.
2800 |     """
2801 | 
2802 |     https_params = {
2803 |         "function": "BBANDS",
2804 |         "symbol": symbol,
2805 |         "interval": interval,
2806 |         "month": month,
2807 |         "time_period": time_period,
2808 |         "series_type": series_type,
2809 |         "nbdevup": nbdevup,
2810 |         "nbdevdn": nbdevdn,
2811 |         "matype": matype,
2812 |         "datatype": datatype,
2813 |         "apikey": API_KEY,
2814 |     }
2815 | 
2816 |     return await _make_api_request(https_params, datatype)
2817 | 
2818 | 
2819 | @instrument_tool("midpoint")
2820 | async def fetch_midpoint(
2821 |     symbol: str,
2822 |     interval: str = None,
2823 |     month: str = None,
2824 |     time_period: int = 14,
2825 |     series_type: str = "close",
2826 |     datatype: str = "json",
2827 | ) -> dict[str, str] | str:
2828 |     """
2829 |     Fetch midpoint (MIDPOINT) data from the Alpha Vantage API.
2830 | 
2831 |     :argument: symbol (str): The stock symbol to fetch.
2832 |     :argument: interval (str): The time interval for the data.
2833 |     :argument: month (str): The month for the data.
2834 |     :argument: time_period (int): The time period for the data.
2835 |     :argument: series_type (str): The series type for the data.
2836 |     :argument: datatype (str): The response data type (default: "json").
2837 | 
2838 |     :returns: Midpoint (MIDPOINT) data.
2839 |     """
2840 | 
2841 |     https_params = {
2842 |         "function": "MIDPOINT",
2843 |         "symbol": symbol,
2844 |         "interval": interval,
2845 |         "month": month,
2846 |         "time_period": time_period,
2847 |         "series_type": series_type,
2848 |         "datatype": datatype,
2849 |         "apikey": API_KEY,
2850 |     }
2851 | 
2852 |     return await _make_api_request(https_params, datatype)
2853 | 
2854 | 
2855 | @instrument_tool("midprice")
2856 | async def fetch_midprice(
2857 |     symbol: str,
2858 |     interval: str = None,
2859 |     month: str = None,
2860 |     time_period: int = 14,
2861 |     datatype: str = "json",
2862 | ) -> dict[str, str] | str:
2863 |     """
2864 |     Fetch midprice (MIDPRICE) data from the Alpha Vantage API.
2865 | 
2866 |     :argument: symbol (str): The stock symbol to fetch.
2867 |     :argument: interval (str): The time interval for the data.
2868 |     :argument: month (str): The month for the data.
2869 |     :argument: time_period (int): The time period for the data.
2870 |     :argument: datatype (str): The response data type (default: "json").
2871 | 
2872 |     :returns: Midprice (MIDPRICE) data.
2873 |     """
2874 | 
2875 |     https_params = {
2876 |         "function": "MIDPRICE",
2877 |         "symbol": symbol,
2878 |         "interval": interval,
2879 |         "month": month,
2880 |         "time_period": time_period,
2881 |         "datatype": datatype,
2882 |         "apikey": API_KEY,
2883 |     }
2884 | 
2885 |     return await _make_api_request(https_params, datatype)
2886 | 
2887 | 
2888 | @instrument_tool("sar")
2889 | async def fetch_sar(
2890 |     symbol: str,
2891 |     interval: str = None,
2892 |     month: str = None,
2893 |     acceleration: float = 0.02,
2894 |     maximum: float = 0.2,
2895 |     datatype: str = "json",
2896 | ) -> dict[str, str] | str:
2897 |     """
2898 |     Fetch parabolic SAR (SAR) data from the Alpha Vantage API.
2899 | 
2900 |     :argument: symbol (str): The stock symbol to fetch.
2901 |     :argument: interval (str): The time interval for the data.
2902 |     :argument: month (str): The month for the data.
2903 |     :argument: acceleration (float): The acceleration factor for the data.
2904 |     :argument: maximum (float): The maximum factor for the data.
2905 |     :argument: datatype (str): The response data type (default: "json").
2906 | 
2907 |     :returns: Parabolic SAR (SAR) data.
2908 |     """
2909 | 
2910 |     https_params = {
2911 |         "function": "SAR",
2912 |         "symbol": symbol,
2913 |         "interval": interval,
2914 |         "month": month,
2915 |         "acceleration": acceleration,
2916 |         "maximum": maximum,
2917 |         "datatype": datatype,
2918 |         "apikey": API_KEY,
2919 |     }
2920 | 
2921 |     return await _make_api_request(https_params, datatype)
2922 | 
2923 | 
2924 | @instrument_tool("trange")
2925 | async def fetch_trange(
2926 |     symbol: str,
2927 |     interval: str = None,
2928 |     month: str = None,
2929 |     datatype: str = "json",
2930 | ) -> dict[str, str] | str:
2931 |     """
2932 |     Fetch true range (TRANGE) data from the Alpha Vantage API.
2933 | 
2934 |     :argument: symbol (str): The stock symbol to fetch.
2935 |     :argument: interval (str): The time interval for the data.
2936 |     :argument: month (str): The month for the data.
2937 |     :argument: datatype (str): The response data type (default: "json").
2938 | 
2939 |     :returns: True range (TRANGE) data.
2940 |     """
2941 | 
2942 |     https_params = {
2943 |         "function": "TRANGE",
2944 |         "symbol": symbol,
2945 |         "interval": interval,
2946 |         "month": month,
2947 |         "datatype": datatype,
2948 |         "apikey": API_KEY,
2949 |     }
2950 | 
2951 |     return await _make_api_request(https_params, datatype)
2952 | 
2953 | 
2954 | @instrument_tool("atr")
2955 | async def fetch_atr(
2956 |     symbol: str,
2957 |     interval: str = None,
2958 |     month: str = None,
2959 |     time_period: int = 14,
2960 |     datatype: str = "json",
2961 | ) -> dict[str, str] | str:
2962 |     """
2963 |     Fetch average true range (ATR) data from the Alpha Vantage API.
2964 | 
2965 |     :argument: symbol (str): The stock symbol to fetch.
2966 |     :argument: interval (str): The time interval for the data.
2967 |     :argument: month (str): The month for the data.
2968 |     :argument: time_period (int): The time period for the data.
2969 |     :argument: datatype (str): The response data type (default: "json").
2970 | 
2971 |     :returns: Average true range (ATR) data.
2972 |     """
2973 | 
2974 |     https_params = {
2975 |         "function": "ATR",
2976 |         "symbol": symbol,
2977 |         "interval": interval,
2978 |         "month": month,
2979 |         "time_period": time_period,
2980 |         "datatype": datatype,
2981 |         "apikey": API_KEY,
2982 |     }
2983 | 
2984 |     return await _make_api_request(https_params, datatype)
2985 | 
2986 | 
2987 | @instrument_tool("natr")
2988 | async def fetch_natr(
2989 |     symbol: str,
2990 |     interval: str = None,
2991 |     month: str = None,
2992 |     time_period: int = 14,
2993 |     datatype: str = "json",
2994 | ) -> dict[str, str] | str:
2995 |     """
2996 |     Fetch normalized average true range (NATR) data from the Alpha Vantage API.
2997 | 
2998 |     :argument: symbol (str): The stock symbol to fetch.
2999 |     :argument: interval (str): The time interval for the data.
3000 |     :argument: month (str): The month for the data.
3001 |     :argument: time_period (int): The time period for the data.
3002 |     :argument: datatype (str): The response data type (default: "json").
3003 | 
3004 |     :returns: Normalized average true range (NATR) data.
3005 |     """
3006 | 
3007 |     https_params = {
3008 |         "function": "NATR",
3009 |         "symbol": symbol,
3010 |         "interval": interval,
3011 |         "month": month,
3012 |         "time_period": time_period,
3013 |         "datatype": datatype,
3014 |         "apikey": API_KEY,
3015 |     }
3016 | 
3017 |     return await _make_api_request(https_params, datatype)
3018 | 
3019 | 
3020 | @instrument_tool("ad")
3021 | async def fetch_ad(
3022 |     symbol: str,
3023 |     interval: str = None,
3024 |     month: str = None,
3025 |     datatype: str = "json",
3026 | ) -> dict[str, str] | str:
3027 |     """
3028 |     Fetch accumulation/distribution (AD) data from the Alpha Vantage API.
3029 | 
3030 |     :argument: symbol (str): The stock symbol to fetch.
3031 |     :argument: interval (str): The time interval for the data.
3032 |     :argument: month (str): The month for the data.
3033 |     :argument: datatype (str): The response data type (default: "json").
3034 | 
3035 |     :returns: Accumulation/distribution (AD) data.
3036 |     """
3037 | 
3038 |     https_params = {
3039 |         "function": "AD",
3040 |         "symbol": symbol,
3041 |         "interval": interval,
3042 |         "month": month,
3043 |         "datatype": datatype,
3044 |         "apikey": API_KEY,
3045 |     }
3046 | 
3047 |     return await _make_api_request(https_params, datatype)
3048 | 
3049 | 
3050 | @instrument_tool("adosc")
3051 | async def fetch_adosc(
3052 |     symbol: str,
3053 |     interval: str = None,
3054 |     month: str = None,
3055 |     fastperiod: int = 3,
3056 |     slowperiod: int = 10,
3057 |     datatype: str = "json",
3058 | ) -> dict[str, str] | str:
3059 |     """
3060 |     Fetch accumulation/distribution oscillator (ADOSC) data from the Alpha Vantage API.
3061 | 
3062 |     :argument: symbol (str): The stock symbol to fetch.
3063 |     :argument: interval (str): The time interval for the data.
3064 |     :argument: month (str): The month for the data.
3065 |     :argument: fastperiod (int): The fast period for the data.
3066 |     :argument: slowperiod (int): The slow period for the data.
3067 |     :argument: datatype (str): The response data type (default: "json").
3068 | 
3069 |     :returns: Accumulation/distribution oscillator (ADOSC) data.
3070 |     """
3071 | 
3072 |     https_params = {
3073 |         "function": "ADOSC",
3074 |         "symbol": symbol,
3075 |         "interval": interval,
3076 |         "month": month,
3077 |         "fastperiod": fastperiod,
3078 |         "slowperiod": slowperiod,
3079 |         "datatype": datatype,
3080 |         "apikey": API_KEY,
3081 |     }
3082 | 
3083 |     return await _make_api_request(https_params, datatype)
3084 | 
3085 | 
3086 | @instrument_tool("obv")
3087 | async def fetch_obv(
3088 |     symbol: str,
3089 |     interval: str = None,
3090 |     month: str = None,
3091 |     datatype: str = "json",
3092 | ) -> dict[str, str] | str:
3093 |     """
3094 |     Fetch on balance volume (OBV) data from the Alpha Vantage API.
3095 | 
3096 |     :argument: symbol (str): The stock symbol to fetch.
3097 |     :argument: interval (str): The time interval for the data.
3098 |     :argument: month (str): The month for the data.
3099 |     :argument: datatype (str): The response data type (default: "json").
3100 | 
3101 |     :returns: On balance volume (OBV) data.
3102 |     """
3103 | 
3104 |     https_params = {
3105 |         "function": "OBV",
3106 |         "symbol": symbol,
3107 |         "interval": interval,
3108 |         "month": month,
3109 |         "datatype": datatype,
3110 |         "apikey": API_KEY,
3111 |     }
3112 | 
3113 |     return await _make_api_request(https_params, datatype)
3114 | 
3115 | 
3116 | @instrument_tool("ht_trendline")
3117 | async def fetch_ht_trendline(
3118 |     symbol: str,
3119 |     interval: str = None,
3120 |     month: str = None,
3121 |     series_type: str = "close",
3122 |     datatype: str = "json",
3123 | ) -> dict[str, str] | str:
3124 |     """
3125 |     Fetch Hilbert transform - instantaneous trendline (HT_TRENDLINE) data from the Alpha Vantage API.
3126 | 
3127 |     :argument: symbol (str): The stock symbol to fetch.
3128 |     :argument: interval (str): The time interval for the data.
3129 |     :argument: month (str): The month for the data.
3130 |     :argument: series_type (str): The series type for the data.
3131 |     :argument: datatype (str): The response data type (default: "json").
3132 | 
3133 |     :returns: Hilbert transform - instantaneous trendline (HT_TRENDLINE) data.
3134 |     """
3135 | 
3136 |     https_params = {
3137 |         "function": "HT_TRENDLINE",
3138 |         "symbol": symbol,
3139 |         "interval": interval,
3140 |         "month": month,
3141 |         "series_type": series_type,
3142 |         "datatype": datatype,
3143 |         "apikey": API_KEY,
3144 |     }
3145 | 
3146 |     return await _make_api_request(https_params, datatype)
3147 | 
3148 | 
3149 | @instrument_tool("ht_sine")
3150 | async def fetch_ht_sine(
3151 |     symbol: str,
3152 |     interval: str = None,
3153 |     month: str = None,
3154 |     series_type: str = "close",
3155 |     datatype: str = "json",
3156 | ) -> dict[str, str] | str:
3157 |     """
3158 |     Fetch Hilbert transform - sine wave (HT_SINE) data from the Alpha Vantage API.
3159 | 
3160 |     :argument: symbol (str): The stock symbol to fetch.
3161 |     :argument: interval (str): The time interval for the data.
3162 |     :argument: month (str): The month for the data.
3163 |     :argument: series_type (str): The series type for the data.
3164 |     :argument: datatype (str): The response data type (default: "json").
3165 | 
3166 |     :returns: Hilbert transform - sine wave (HT_SINE) data.
3167 |     """
3168 | 
3169 |     https_params = {
3170 |         "function": "HT_SINE",
3171 |         "symbol": symbol,
3172 |         "interval": interval,
3173 |         "month": month,
3174 |         "series_type": series_type,
3175 |         "datatype": datatype,
3176 |         "apikey": API_KEY,
3177 |     }
3178 | 
3179 |     return await _make_api_request(https_params, datatype)
3180 | 
3181 | 
3182 | @instrument_tool("ht_trendmode")
3183 | async def fetch_ht_trendmode(
3184 |     symbol: str,
3185 |     interval: str = None,
3186 |     month: str = None,
3187 |     datatype: str = "json",
3188 | ) -> dict[str, str] | str:
3189 |     """
3190 |     Fetch Hilbert transform - trend vs cycle mode (HT_TRENDMODE) data from the Alpha Vantage API.
3191 | 
3192 |     :argument: symbol (str): The stock symbol to fetch.
3193 |     :argument: interval (str): The time interval for the data.
3194 |     :argument: month (str): The month for the data.
3195 |     :argument: datatype (str): The response data type (default: "json").
3196 | 
3197 |     :returns: Hilbert transform - trend vs cycle mode (HT_TRENDMODE) data.
3198 |     """
3199 | 
3200 |     https_params = {
3201 |         "function": "HT_TRENDMODE",
3202 |         "symbol": symbol,
3203 |         "interval": interval,
3204 |         "month": month,
3205 |         "datatype": datatype,
3206 |         "apikey": API_KEY,
3207 |     }
3208 | 
3209 |     return await _make_api_request(https_params, datatype)
3210 | 
3211 | 
3212 | @instrument_tool("ht_dcperiod")
3213 | async def fetch_ht_dcperiod(
3214 |     symbol: str,
3215 |     interval: str = None,
3216 |     month: str = None,
3217 |     series_type: str = None,
3218 |     datatype: str = "json",
3219 | ) -> dict[str, str] | str:
3220 |     """
3221 |     Fetch Hil bert transform - dominant cycle period (HT_DCPERIOD) data from the Alpha Vantage API.
3222 | 
3223 |     :argument: symbol (str): The stock symbol to fetch.
3224 |     :argument: interval (str): The time interval for the data.
3225 |     :argument: month (str): The month for the data.
3226 |     :argument: series_type (str): The series type for the data.
3227 |     :argument: datatype (str): The response data type (default: "json").
3228 | 
3229 |     :returns: Hilbert transform - dominant cycle period (HT_DCPERIOD) data.
3230 |     """
3231 | 
3232 |     https_params = {
3233 |         "function": "HT_DCPERIOD",
3234 |         "symbol": symbol,
3235 |         "interval": interval,
3236 |         "month": month,
3237 |         "series_type": series_type,
3238 |         "datatype": datatype,
3239 |         "apikey": API_KEY,
3240 |     }
3241 | 
3242 |     return await _make_api_request(https_params, datatype)
3243 | 
3244 | 
3245 | @instrument_tool("ht_dcphase")
3246 | async def fetch_ht_dcphase(
3247 |     symbol: str,
3248 |     interval: str = None,
3249 |     month: str = None,
3250 |     series_type: str = None,
3251 |     datatype: str = "json",
3252 | ) -> dict[str, str] | str:
3253 |     """
3254 |     Fetch Hilbert transform - dominant cycle phase (HT_DCPHASE) data from the Alpha Vantage API.
3255 | 
3256 |     :argument: symbol (str): The stock symbol to fetch.
3257 |     :argument: interval (str): The time interval for the data.
3258 |     :argument: month (str): The month for the data.
3259 |     :argument: series_type (str): The series type for the data.
3260 |     :argument: datatype (str): The response data type (default: "json").
3261 | 
3262 |     :returns: Hilbert transform - dominant cycle phase (HT_DCPHASE) data.
3263 |     """
3264 | 
3265 |     https_params = {
3266 |         "function": "HT_DCPHASE",
3267 |         "symbol": symbol,
3268 |         "interval": interval,
3269 |         "month": month,
3270 |         "series_type": series_type,
3271 |         "datatype": datatype,
3272 |         "apikey": API_KEY,
3273 |     }
3274 | 
3275 |     return await _make_api_request(https_params, datatype)
3276 | 
3277 | 
3278 | @instrument_tool("ht_phasor")
3279 | async def fetch_ht_phasor(
3280 |     symbol: str,
3281 |     interval: str = None,
3282 |     month: str = None,
3283 |     series_type: str = "close",
3284 |     datatype: str = "json",
3285 | ) -> dict[str, str] | str:
3286 |     """
3287 |     Fetch Hilbert transform - phasor components (HT_PHASOR) data from the Alpha Vantage API.
3288 | 
3289 |     :argument: symbol (str): The stock symbol to fetch.
3290 |     :argument: interval (str): The time interval for the data.
3291 |     :argument: month (str): The month for the data.
3292 |     :argument: series_type (str): The series type for the data.
3293 |     :argument: datatype (str): The response data type (default: "json").
3294 | 
3295 |     :returns: Hilbert transform - phasor components (HT_PHASOR) data.
3296 |     """
3297 | 
3298 |     https_params = {
3299 |         "function": "HT_PHASOR",
3300 |         "symbol": symbol,
3301 |         "interval": interval,
3302 |         "month": month,
3303 |         "series_type": series_type,
3304 |         "datatype": datatype,
3305 |         "apikey": API_KEY,
3306 |     }
3307 | 
3308 |     return await _make_api_request(https_params, datatype)
3309 | 
```
Page 4/4FirstPrevNextLast