重要前提
安装AI Skills的关键前提是:必须科学上网,且开启TUN模式,这一点至关重要,直接决定安装能否顺利完成,在此郑重提醒三遍:科学上网,科学上网,科学上网。查看完整安装教程 →
alphavantage-api by adaptationio/skrillz
npx skills add https://github.com/adaptationio/skrillz --skill alphavantage-api提供股票、外汇、加密货币、技术指标、基本面数据、经济指标和 AI 驱动的新闻情绪分析的金融数据 API。
# 环境变量(推荐)
export ALPHAVANTAGE_API_KEY="your_api_key"
# 或在 .env 文件中
ALPHAVANTAGE_API_KEY=your_api_key
import requests
import os
API_KEY = os.getenv("ALPHAVANTAGE_API_KEY")
BASE_URL = "https://www.alphavantage.co/query"
def get_quote(symbol: str) -> dict:
"""获取标的的实时报价。"""
response = requests.get(BASE_URL, params={
"function": "GLOBAL_QUOTE",
"symbol": symbol,
"apikey": API_KEY
})
return response.json().get("Global Quote", {})
# 示例
quote = get_quote("AAPL")
print(f"AAPL: ${quote['05. price']} ({quote['10. change percent']})")
from alpha_vantage.timeseries import TimeSeries
from alpha_vantage.techindicators import TechIndicators
# 时间序列数据
ts = TimeSeries(key=API_KEY, output_format='pandas')
data, meta = ts.get_daily(symbol='AAPL', outputsize='compact')
# 技术指标
ti = TechIndicators(key=API_KEY, output_format='pandas')
rsi, meta = ti.get_rsi(symbol='AAPL', interval='daily', time_period=14)
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
| 函数 | 描述 | 免费 |
|---|---|---|
TIME_SERIES_INTRADAY | 1-60 分钟间隔 | ✅ |
TIME_SERIES_DAILY | 每日 OHLCV | ✅ |
TIME_SERIES_DAILY_ADJUSTED | 包含拆股/股息 | ⚠️ 高级版 |
TIME_SERIES_WEEKLY | 每周 OHLCV | ✅ |
TIME_SERIES_MONTHLY | 每月 OHLCV | ✅ |
GLOBAL_QUOTE | 最新报价 | ✅ |
SYMBOL_SEARCH | 搜索标的 | ✅ |
| 函数 | 描述 | 免费 |
|---|---|---|
OVERVIEW | 公司概览 | ✅ |
INCOME_STATEMENT | 损益表 | ✅ |
BALANCE_SHEET | 资产负债表 | ✅ |
CASH_FLOW | 现金流量表 | ✅ |
EARNINGS | 收益历史 | ✅ |
EARNINGS_CALENDAR | 即将发布的收益 | ✅ |
IPO_CALENDAR | 即将进行的 IPO | ✅ |
| 函数 | 描述 | 免费 |
|---|---|---|
CURRENCY_EXCHANGE_RATE | 实时汇率 | ✅ |
FX_INTRADAY | 日内外汇 | ✅ |
FX_DAILY | 每日外汇 | ✅ |
FX_WEEKLY | 每周外汇 | ✅ |
FX_MONTHLY | 每月外汇 | ✅ |
| 函数 | 描述 | 免费 |
|---|---|---|
CURRENCY_EXCHANGE_RATE | 加密货币汇率 | ✅ |
DIGITAL_CURRENCY_DAILY | 每日加密货币 | ✅ |
DIGITAL_CURRENCY_WEEKLY | 每周加密货币 | ✅ |
DIGITAL_CURRENCY_MONTHLY | 每月加密货币 | ✅ |
| 类别 | 指标 |
|---|---|
| 趋势 | SMA, EMA, WMA, DEMA, TEMA, KAMA, MAMA, T3, TRIMA |
| 动量 | RSI, MACD, STOCH, WILLR, ADX, CCI, MFI, ROC, AROON, MOM |
| 波动率 | BBANDS, ATR, NATR, TRANGE |
| 成交量 | OBV, AD, ADOSC |
| 希尔伯特 | HT_TRENDLINE, HT_SINE, HT_PHASOR, 等 |
| 函数 | 描述 | 免费 |
|---|---|---|
REAL_GDP | 美国 GDP | ✅ |
CPI | 消费者价格指数 | ✅ |
INFLATION | 通货膨胀率 | ✅ |
UNEMPLOYMENT | 失业率 | ✅ |
FEDERAL_FUNDS_RATE | 联邦基金利率 | ✅ |
TREASURY_YIELD | 国债收益率 | ✅ |
| 函数 | 描述 | 免费 |
|---|---|---|
NEWS_SENTIMENT | AI 情绪分析 | ✅ |
TOP_GAINERS_LOSERS | 市场变动者 | ✅ |
INSIDER_TRANSACTIONS | 内幕交易 | ⚠️ 高级版 |
ANALYTICS_FIXED_WINDOW | 分析 | ⚠️ 高级版 |
| 层级 | 每日 | 每分钟 | 价格 |
|---|---|---|---|
| 免费版 | 25 | 5 | $0 |
| 高级版 | 无限制 | 75-1,200 | $49.99-$249.99/月 |
重要提示: 速率限制是基于 IP 地址的,而不是基于密钥。
def get_daily_data(symbol: str, full: bool = False) -> dict:
"""获取每日 OHLCV 数据。"""
response = requests.get(BASE_URL, params={
"function": "TIME_SERIES_DAILY",
"symbol": symbol,
"outputsize": "full" if full else "compact",
"apikey": API_KEY
})
return response.json().get("Time Series (Daily)", {})
# 示例
data = get_daily_data("AAPL")
latest = list(data.items())[0]
print(f"{latest[0]}: 收盘价 ${latest[1]['4. close']}")
def get_rsi(symbol: str, period: int = 14) -> dict:
"""获取 RSI 指标值。"""
response = requests.get(BASE_URL, params={
"function": "RSI",
"symbol": symbol,
"interval": "daily",
"time_period": period,
"series_type": "close",
"apikey": API_KEY
})
return response.json().get("Technical Analysis: RSI", {})
# 示例
rsi = get_rsi("AAPL")
latest_rsi = list(rsi.values())[0]["RSI"]
print(f"AAPL RSI(14): {latest_rsi}")
def get_company_overview(symbol: str) -> dict:
"""获取全面的公司信息。"""
response = requests.get(BASE_URL, params={
"function": "OVERVIEW",
"symbol": symbol,
"apikey": API_KEY
})
data = response.json()
return {
"name": data.get("Name"),
"description": data.get("Description"),
"sector": data.get("Sector"),
"industry": data.get("Industry"),
"market_cap": data.get("MarketCapitalization"),
"pe_ratio": data.get("PERatio"),
"dividend_yield": data.get("DividendYield"),
"eps": data.get("EPS"),
"52_week_high": data.get("52WeekHigh"),
"52_week_low": data.get("52WeekLow"),
"beta": data.get("Beta")
}
def get_forex_rate(from_currency: str, to_currency: str) -> dict:
"""获取货币汇率。"""
response = requests.get(BASE_URL, params={
"function": "CURRENCY_EXCHANGE_RATE",
"from_currency": from_currency,
"to_currency": to_currency,
"apikey": API_KEY
})
return response.json().get("Realtime Currency Exchange Rate", {})
# 示例
rate = get_forex_rate("USD", "EUR")
print(f"USD/EUR: {rate['5. Exchange Rate']}")
def get_crypto_price(symbol: str, market: str = "USD") -> dict:
"""获取加密货币价格。"""
response = requests.get(BASE_URL, params={
"function": "CURRENCY_EXCHANGE_RATE",
"from_currency": symbol,
"to_currency": market,
"apikey": API_KEY
})
data = response.json().get("Realtime Currency Exchange Rate", {})
return {
"symbol": symbol,
"price": data.get("5. Exchange Rate"),
"last_updated": data.get("6. Last Refreshed")
}
# 示例
btc = get_crypto_price("BTC")
print(f"BTC: ${float(btc['price']):,.2f}")
def get_news_sentiment(tickers: str = None, topics: str = None) -> list:
"""获取 AI 驱动的新闻情绪分析。"""
params = {
"function": "NEWS_SENTIMENT",
"apikey": API_KEY
}
if tickers:
params["tickers"] = tickers
if topics:
params["topics"] = topics
response = requests.get(BASE_URL, params=params)
return response.json().get("feed", [])
# 示例
news = get_news_sentiment(tickers="AAPL")
for article in news[:3]:
sentiment = article.get("overall_sentiment_label", "N/A")
print(f"{article['title'][:50]}... [{sentiment}]")
def get_economic_indicator(indicator: str) -> dict:
"""获取美国经济指标数据。"""
response = requests.get(BASE_URL, params={
"function": indicator,
"apikey": API_KEY
})
return response.json()
# 示例
gdp = get_economic_indicator("REAL_GDP")
cpi = get_economic_indicator("CPI")
unemployment = get_economic_indicator("UNEMPLOYMENT")
fed_rate = get_economic_indicator("FEDERAL_FUNDS_RATE")
def get_earnings_calendar(horizon: str = "3month") -> list:
"""获取即将发布的收益公告。"""
import csv
from io import StringIO
response = requests.get(BASE_URL, params={
"function": "EARNINGS_CALENDAR",
"horizon": horizon, # 3month, 6month, 12month
"apikey": API_KEY
})
# 返回 CSV 格式
reader = csv.DictReader(StringIO(response.text))
return list(reader)
# 示例
earnings = get_earnings_calendar()
for e in earnings[:5]:
print(f"{e['symbol']}: {e['reportDate']}")
def safe_api_call(params: dict) -> dict:
"""进行带有错误处理的 API 调用。"""
params["apikey"] = API_KEY
try:
response = requests.get(BASE_URL, params=params)
data = response.json()
# 检查速率限制
if "Note" in data:
print(f"速率限制: {data['Note']}")
return {}
# 检查错误信息
if "Error Message" in data:
print(f"API 错误: {data['Error Message']}")
return {}
# 检查信息消息(通常是速率限制)
if "Information" in data:
print(f"信息: {data['Information']}")
return {}
return data
except Exception as e:
print(f"请求错误: {e}")
return {}
# 官方 Python 封装
pip install alpha_vantage pandas
# 支持异步
pip install aiohttp
from alpha_vantage.timeseries import TimeSeries
from alpha_vantage.techindicators import TechIndicators
import pandas as pd
# 使用 pandas 输出初始化
ts = TimeSeries(key=API_KEY, output_format='pandas')
ti = TechIndicators(key=API_KEY, output_format='pandas')
# 获取每日数据
data, meta = ts.get_daily(symbol='AAPL', outputsize='compact')
# 获取指标
sma, _ = ti.get_sma(symbol='AAPL', interval='daily', time_period=20)
rsi, _ = ti.get_rsi(symbol='AAPL', interval='daily', time_period=14)
# 合并
analysis = data.join([sma, rsi])
finnhub-api - 实时报价和新闻twelvedata-api - 更多指标,更好的速率限制fmp-api - 专注于基本面分析每周安装量
42
代码仓库
GitHub 星标数
5
首次出现
2026年1月24日
安全审计
安装于
gemini-cli33
github-copilot31
openclaw31
opencode31
cursor30
codex29
Financial data API providing stocks, forex, crypto, technical indicators, fundamental data, economic indicators, and AI-powered news sentiment analysis.
# Environment variable (recommended)
export ALPHAVANTAGE_API_KEY="your_api_key"
# Or in .env file
ALPHAVANTAGE_API_KEY=your_api_key
import requests
import os
API_KEY = os.getenv("ALPHAVANTAGE_API_KEY")
BASE_URL = "https://www.alphavantage.co/query"
def get_quote(symbol: str) -> dict:
"""Get real-time quote for a symbol."""
response = requests.get(BASE_URL, params={
"function": "GLOBAL_QUOTE",
"symbol": symbol,
"apikey": API_KEY
})
return response.json().get("Global Quote", {})
# Example
quote = get_quote("AAPL")
print(f"AAPL: ${quote['05. price']} ({quote['10. change percent']})")
from alpha_vantage.timeseries import TimeSeries
from alpha_vantage.techindicators import TechIndicators
# Time series data
ts = TimeSeries(key=API_KEY, output_format='pandas')
data, meta = ts.get_daily(symbol='AAPL', outputsize='compact')
# Technical indicators
ti = TechIndicators(key=API_KEY, output_format='pandas')
rsi, meta = ti.get_rsi(symbol='AAPL', interval='daily', time_period=14)
| Function | Description | Free |
|---|---|---|
TIME_SERIES_INTRADAY | 1-60min intervals | ✅ |
TIME_SERIES_DAILY | Daily OHLCV | ✅ |
TIME_SERIES_DAILY_ADJUSTED | With splits/dividends | ⚠️ Premium |
TIME_SERIES_WEEKLY | Weekly OHLCV | ✅ |
TIME_SERIES_MONTHLY | Monthly OHLCV |
| Function | Description | Free |
|---|---|---|
OVERVIEW | Company overview | ✅ |
INCOME_STATEMENT | Income statements | ✅ |
BALANCE_SHEET | Balance sheets | ✅ |
CASH_FLOW | Cash flow statements | ✅ |
EARNINGS | Earnings history | ✅ |
| Function | Description | Free |
|---|---|---|
CURRENCY_EXCHANGE_RATE | Real-time rate | ✅ |
FX_INTRADAY | Intraday forex | ✅ |
FX_DAILY | Daily forex | ✅ |
FX_WEEKLY | Weekly forex | ✅ |
FX_MONTHLY | Monthly forex | ✅ |
| Function | Description | Free |
|---|---|---|
CURRENCY_EXCHANGE_RATE | Crypto rate | ✅ |
DIGITAL_CURRENCY_DAILY | Daily crypto | ✅ |
DIGITAL_CURRENCY_WEEKLY | Weekly crypto | ✅ |
DIGITAL_CURRENCY_MONTHLY | Monthly crypto | ✅ |
| Category | Indicators |
|---|---|
| Trend | SMA, EMA, WMA, DEMA, TEMA, KAMA, MAMA, T3, TRIMA |
| Momentum | RSI, MACD, STOCH, WILLR, ADX, CCI, MFI, ROC, AROON, MOM |
| Volatility | BBANDS, ATR, NATR, TRANGE |
| Volume | OBV, AD, ADOSC |
| Hilbert | HT_TRENDLINE, HT_SINE, HT_PHASOR, etc. |
| Function | Description | Free |
|---|---|---|
REAL_GDP | US GDP | ✅ |
CPI | Consumer Price Index | ✅ |
INFLATION | Inflation rate | ✅ |
UNEMPLOYMENT | Unemployment rate | ✅ |
FEDERAL_FUNDS_RATE | Fed funds rate | ✅ |
| Function | Description | Free |
|---|---|---|
NEWS_SENTIMENT | AI sentiment analysis | ✅ |
TOP_GAINERS_LOSERS | Market movers | ✅ |
INSIDER_TRANSACTIONS | Insider trades | ⚠️ Premium |
ANALYTICS_FIXED_WINDOW | Analytics | ⚠️ Premium |
| Tier | Daily | Per Minute | Price |
|---|---|---|---|
| Free | 25 | 5 | $0 |
| Premium | Unlimited | 75-1,200 | $49.99-$249.99/mo |
Important: Rate limits are IP-based, not key-based.
def get_daily_data(symbol: str, full: bool = False) -> dict:
"""Get daily OHLCV data."""
response = requests.get(BASE_URL, params={
"function": "TIME_SERIES_DAILY",
"symbol": symbol,
"outputsize": "full" if full else "compact",
"apikey": API_KEY
})
return response.json().get("Time Series (Daily)", {})
# Example
data = get_daily_data("AAPL")
latest = list(data.items())[0]
print(f"{latest[0]}: Close ${latest[1]['4. close']}")
def get_rsi(symbol: str, period: int = 14) -> dict:
"""Get RSI indicator values."""
response = requests.get(BASE_URL, params={
"function": "RSI",
"symbol": symbol,
"interval": "daily",
"time_period": period,
"series_type": "close",
"apikey": API_KEY
})
return response.json().get("Technical Analysis: RSI", {})
# Example
rsi = get_rsi("AAPL")
latest_rsi = list(rsi.values())[0]["RSI"]
print(f"AAPL RSI(14): {latest_rsi}")
def get_company_overview(symbol: str) -> dict:
"""Get comprehensive company information."""
response = requests.get(BASE_URL, params={
"function": "OVERVIEW",
"symbol": symbol,
"apikey": API_KEY
})
data = response.json()
return {
"name": data.get("Name"),
"description": data.get("Description"),
"sector": data.get("Sector"),
"industry": data.get("Industry"),
"market_cap": data.get("MarketCapitalization"),
"pe_ratio": data.get("PERatio"),
"dividend_yield": data.get("DividendYield"),
"eps": data.get("EPS"),
"52_week_high": data.get("52WeekHigh"),
"52_week_low": data.get("52WeekLow"),
"beta": data.get("Beta")
}
def get_forex_rate(from_currency: str, to_currency: str) -> dict:
"""Get currency exchange rate."""
response = requests.get(BASE_URL, params={
"function": "CURRENCY_EXCHANGE_RATE",
"from_currency": from_currency,
"to_currency": to_currency,
"apikey": API_KEY
})
return response.json().get("Realtime Currency Exchange Rate", {})
# Example
rate = get_forex_rate("USD", "EUR")
print(f"USD/EUR: {rate['5. Exchange Rate']}")
def get_crypto_price(symbol: str, market: str = "USD") -> dict:
"""Get cryptocurrency price."""
response = requests.get(BASE_URL, params={
"function": "CURRENCY_EXCHANGE_RATE",
"from_currency": symbol,
"to_currency": market,
"apikey": API_KEY
})
data = response.json().get("Realtime Currency Exchange Rate", {})
return {
"symbol": symbol,
"price": data.get("5. Exchange Rate"),
"last_updated": data.get("6. Last Refreshed")
}
# Example
btc = get_crypto_price("BTC")
print(f"BTC: ${float(btc['price']):,.2f}")
def get_news_sentiment(tickers: str = None, topics: str = None) -> list:
"""Get AI-powered news sentiment analysis."""
params = {
"function": "NEWS_SENTIMENT",
"apikey": API_KEY
}
if tickers:
params["tickers"] = tickers
if topics:
params["topics"] = topics
response = requests.get(BASE_URL, params=params)
return response.json().get("feed", [])
# Example
news = get_news_sentiment(tickers="AAPL")
for article in news[:3]:
sentiment = article.get("overall_sentiment_label", "N/A")
print(f"{article['title'][:50]}... [{sentiment}]")
def get_economic_indicator(indicator: str) -> dict:
"""Get US economic indicator data."""
response = requests.get(BASE_URL, params={
"function": indicator,
"apikey": API_KEY
})
return response.json()
# Examples
gdp = get_economic_indicator("REAL_GDP")
cpi = get_economic_indicator("CPI")
unemployment = get_economic_indicator("UNEMPLOYMENT")
fed_rate = get_economic_indicator("FEDERAL_FUNDS_RATE")
def get_earnings_calendar(horizon: str = "3month") -> list:
"""Get upcoming earnings releases."""
import csv
from io import StringIO
response = requests.get(BASE_URL, params={
"function": "EARNINGS_CALENDAR",
"horizon": horizon, # 3month, 6month, 12month
"apikey": API_KEY
})
# Returns CSV format
reader = csv.DictReader(StringIO(response.text))
return list(reader)
# Example
earnings = get_earnings_calendar()
for e in earnings[:5]:
print(f"{e['symbol']}: {e['reportDate']}")
def safe_api_call(params: dict) -> dict:
"""Make API call with error handling."""
params["apikey"] = API_KEY
try:
response = requests.get(BASE_URL, params=params)
data = response.json()
# Check for rate limit
if "Note" in data:
print(f"Rate limit: {data['Note']}")
return {}
# Check for error message
if "Error Message" in data:
print(f"API Error: {data['Error Message']}")
return {}
# Check for information message (often rate limit)
if "Information" in data:
print(f"Info: {data['Information']}")
return {}
return data
except Exception as e:
print(f"Request error: {e}")
return {}
# Official Python wrapper
pip install alpha_vantage pandas
# For async support
pip install aiohttp
from alpha_vantage.timeseries import TimeSeries
from alpha_vantage.techindicators import TechIndicators
import pandas as pd
# Initialize with pandas output
ts = TimeSeries(key=API_KEY, output_format='pandas')
ti = TechIndicators(key=API_KEY, output_format='pandas')
# Get daily data
data, meta = ts.get_daily(symbol='AAPL', outputsize='compact')
# Get indicators
sma, _ = ti.get_sma(symbol='AAPL', interval='daily', time_period=20)
rsi, _ = ti.get_rsi(symbol='AAPL', interval='daily', time_period=14)
# Combine
analysis = data.join([sma, rsi])
finnhub-api - Real-time quotes and newstwelvedata-api - More indicators, better rate limitsfmp-api - Fundamental analysis focusWeekly Installs
42
Repository
GitHub Stars
5
First Seen
Jan 24, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykWarn
Installed on
gemini-cli33
github-copilot31
openclaw31
opencode31
cursor30
codex29
SoulTrace 人格评估 API - 基于五色心理模型的贝叶斯自适应测试
56,700 周安装
| ✅ |
GLOBAL_QUOTE | Latest quote | ✅ |
SYMBOL_SEARCH | Search symbols | ✅ |
EARNINGS_CALENDAR | Upcoming earnings | ✅ |
IPO_CALENDAR | Upcoming IPOs | ✅ |
TREASURY_YIELD |
| Treasury yields |
| ✅ |