alpaca-broker-market-data-kfku

Alpaca券商行情数据专用技能,帮助AI Agent高效完成与Alpaca券商行情数据相关的任务。

安装方式

先用 Prompt 核对来源与依赖。也可下载安装包。

用 AI 助手安装

复制提示词,让助手先核对固定版本和依赖。

查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "alpaca-broker-market-data-kfku":https://skillpi.com/zh/skills/deepskill-32e6c02e06213f1ce76f5c163b3f1edbe61a02f794e83c054dbe5843e17a8603。安装前核对上游来源和版本:https://skillhub.cn/skills/user_3c6cb52e/alpaca-broker-market-data-kfku。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。

来源与配置

skillhub.cn

配置方式待核实

请查看原始来源中的适用工具、依赖和权限要求。

安装实测待补充

Alpaca券商行情数据专用技能,帮助AI Agent高效完成与Alpaca券商行情数据相关的任务。

0 下载

介绍来源: third_party · user_3c6cb52e · 1.0.0 参考来源

SkillPi 解读

能完成的任务
翻译待完成,请参阅来源文档。
适合谁
来源文档未说明。
输入和输出
来源文档未说明。
软件、账号及付费要求
来源文档未说明。
限制与区别
来源文档未说明。
实测状态
未测试

文件浏览

在原站浏览文件 ↗

原始 SKILL.md

打开原文 ↗
Frontmatter
name: Alpaca券商行情数据
slug: alpaca-broker-market-data
version: 1.0.0
displayName: Alpaca券商行情数据
description: >
  Alpaca券商行情数据专用技能,帮助AI Agent高效完成相关任务。
summary: "Pull and stream US stock market data from Alpaca — REST snapshots/bars/trades/quotes, historical bars with timeframes and feeds (IEX vs SIP), the assets master list, market clock & calendar, news, and..."
license: MIT
category: 量化交易
framework:
  - Claude Code
  - Codex
  - Hermes Agent
  - OpenClaw
  - QClaw
  - WorkBuddy
platform: multi-platform
homepage: https://github.com/1991513ccie-png
repository: https://github.com/1991513ccie-png

Alpaca Market Data API — Stocks (REST + WebSocket)

Real-time and historical US equity data. Unlike the Broker endpoints, market data lives on its own host with its own auth, and the real-time feed is WebSocket, not SSE.

Read alpaca-broker-integration first. Assets/clock/calendar live on the Trading API host; everything else here is the Market Data API host.

Reference

  • Guides: https://docs.alpaca.markets/docs/historical-stock-data, https://docs.alpaca.markets/docs/streaming-market-data
  • Live schema: alpaca-docs MCP → list-endpoints title "Market Data API"

0. Hosts & auth

Surface Host
Market data REST https://data.alpaca.markets (sandbox data.sandbox.alpaca.markets)
Market data WebSocket wss://stream.data.alpaca.markets/{version}/{feed}
Assets / clock / calendar https://api.alpaca.markets (Trading API) — paper: paper-api.alpaca.markets

Auth: headers APCA-API-KEY-ID / APCA-API-SECRET-KEY (Broker partners may use Broker Basic auth in broker context).

1. REST endpoints

Path Purpose
GET /v2/stocks/snapshots?symbols=… · GET /v2/stocks/{symbol}/snapshot Snapshot (latest trade/quote + bars)
GET /v2/stocks/bars?symbols=… · GET /v2/stocks/{symbol}/bars Historical OHLCV bars
GET /v2/stocks/bars/latest · …/{symbol}/bars/latest Latest bar(s)
GET /v2/stocks/trades[/latest] · GET /v2/stocks/quotes[/latest] Historical / latest trades & quotes
GET /v2/stocks/auctions Opening/closing auctions
GET /v2/stocks/meta/conditions/{trade\|quote} · /meta/exchanges Code lookups
GET /v1beta1/news?symbols=… News (max limit 50)
GET /v1beta1/screener/stocks/most-actives · /screener/{stocks\|crypto}/movers Screeners
GET /v2/assets (Trading API host) · GET /v1/assets (Broker API host) Asset master / tradability
GET /v2/clock · GET /v2/calendar (Trading API host) Market hours

Clock/calendar/assets paths are host-dependent — verified live against the sandbox:

Path Trading API host (api.alpaca.markets) Broker API host (broker-api.*)
/v1/clock — 200
/v2/clock 200 200
/v1/calendar — 200
/v2/calendar 200 404
/v1/assets — 200
/v2/assets 200 404

So: on the Trading/Market-Data API host use /v2/clock, /v2/calendar, /v2/assets. On the Broker API host use /v1/clock, /v1/calendar, /v1/assets (/v1/clock and /v2/clock both work there; /v2/calendar and /v2/assets 404). A Broker-API integration hitting /v1/clock is correct, not stale.

2. Bars — params

Param Notes
timeframe [1-59]Min/T, [1-23]Hour/H, 1Day/D, 1Week/W, [1,2,3,4,6,12]Month/M. Case-sensitive. e.g. 1Min, 5Min, 1Hour, 1Day
start / end RFC3339 or YYYY-MM-DD, inclusive
limit default 1000, max 10000 — counts data points across all symbols, not per symbol
page_token pagination cursor (from next_page_token)
adjustment raw (default), split, dividend, spin-off, all — comma-combinable
feed see §3
sort asc (default) / desc
asof YYYY-MM-DD for symbol/name-change mapping; - skips mapping

Pagination lesson: results are sorted by symbol, then timestamp. A multi-symbol request that hits limit may return only the first symbol(s) — you must follow next_page_token until empty to get them all. Don't assume one page = all symbols.

3. Feeds (entitlement matters)

  • iex — single exchange (~2.5% of volume). The only feed available without a paid subscription. Good for dev/testing.
  • sip — consolidated, all exchanges (100% volume). Requires a paid data plan.
  • delayed_sip — SIP delayed 15 min (latest/snapshot endpoints).
  • otc, boats (Blue Ocean overnight ATS), overnight (Alpaca-derived, cheaper).

Lessons:

  • Pick iex explicitly if you're on the free tier — some endpoints default to sip, which then 403s without entitlement. (A common surprise: "why is my historical request failing?" → defaulted to SIP.)
  • Without real-time access, start/end windows withhold the most recent 15 minutes.
  • Trade/quote sizes are in shares as of 2025-11-03 (were round lots before).

4. Object shapes (compact keys)

Snapshot per symbol: latestTrade, latestQuote, minuteBar, dailyBar, prevDailyBar. Multi-symbol response is a map { "AAPL": {…} }.

  • Bar: t time, o open, h high, l low, c close, v volume, n trade count, vw VWAP.
  • Trade: t time, p price, s size, x exchange, c conditions, z tape, i id.
  • Quote: bp/bs/bx bid price/size/exchange, ap/as/ax ask price/size/exchange, c conditions, z tape. (price 0 = no active bid/ask.)

5. WebSocket protocol

URL: wss://stream.data.alpaca.markets/{version}/{feed} — e.g. v2/iex, v2/sip, v2/delayed_sip, v1beta1/boats, v1beta1/overnight, or v2/test (always-on, use symbol FAKEPACA).

Connect flow:

  1. Connect → [{"T":"success","msg":"connected"}]
  2. Auth within 10s: {"action":"auth","key":"…","secret":"…"} → [{"T":"success","msg":"authenticated"}]
  3. Subscribe: {"action":"subscribe","trades":["AAPL"],"quotes":["AMD"],"bars":["*"]} → server echoes full subscription state. * = all symbols. unsubscribe removes.

Message types (every message is a JSON array; T discriminates): t trade, q quote, b minute bar, d daily bar, u updated bar, s trading status (halt/resume), l LULD, c correction, x cancel/error, i imbalance; control: success, error, subscription. Subscribing to trades auto-adds corrections + cancelErrors.

WebSocket lessons:

  • One concurrent connection per key on most plans — a 2nd connection → {"code":406,"connection limit exceeded"}. Centralize the stream in one process and fan out to your own clients (don't open a socket per user).
  • Authenticate within 10s or get dropped (404).
  • Other error codes: 401 not auth'd, 402 auth failed, 405 symbol limit, 407 slow client, 409 insufficient subscription (feed not entitled), 410 invalid action for feed.
  • Messages are batched — always iterate the array; don't assume one frame = one event.
  • Handle u (updated bar) and c/x (corrections/cancels): a streamed bar/trade can be revised after the fact.

6. Assets, clock, calendar

Use the host-appropriate path (see the table in §1): /v2/... on the Trading API host, /v1/... on the Broker API host.

  • Assets (GET /v2/assets on Trading host · GET /v1/assets and /v1/assets/{symbol} on Broker host) — tradability metadata: tradable, fractionable, marginable, shortable, borrow_status (replaces deprecated easy_to_borrow), status (active/inactive), class (us_equity/us_option/crypto/ipo), exchange, attributes[] (e.g. has_options, overnight_tradable). Filter by status, asset_class, exchange. Cache this — it changes slowly; query it before trading to confirm tradable/fractionable (see alpaca-broker-trading-orders).
  • Clock (/v2/clock on Trading host · /v1/clock on Broker host) — is_open, next_open, next_close, timestamp. Use this to gate market-hours logic instead of hardcoding 9:30–16:00 ET.
  • Calendar (/v2/calendar on Trading host · /v1/calendar on Broker host — note there is no /v2/calendar on the Broker host) — per-day open/close (HH:MM), session_open/session_close (HHMM, extended hours), settlement_date. Use the calendar for holidays — a naive "weekdays only" check runs jobs on market holidays (harmless but wasteful) and miscomputes "previous trading day."

7. Caching strategy (cost & rate-limit lesson)

Market data is the highest-volume, highest-cost surface. Production lesson:

  1. Persist historical bars in your own store keyed by (symbol, timeframe, timestamp) with upsert/skip-duplicate, and serve charts from there — only fetch the gap from Alpaca.
  2. Cache snapshots/quotes in a short-TTL cache (TTL tuned to market-open vs closed).
  3. Run one bulk backfill job for searchable symbols on a schedule rather than fetching per user request.
  4. Always follow next_page_token and watch X-RateLimit-Remaining (see alpaca-broker-rate-limits-resilience).

Related skills: tradability before ordering → alpaca-broker-trading-orders; rate limits/pagination → alpaca-broker-rate-limits-resilience; the broker event stream (SSE, different from this WS) → alpaca-broker-sse-events.

当前收录版本

1.0.0

核对来源版本 ↗

安全与评测信息

质量评测

满分100 · 来自 SkillPi LAB 实验室的评测报告。

场景价值92/100

亮点

  • 提供 Alpaca 行情数据的完整接入方案,覆盖 REST 与 WebSocket 双通道
  • 深入讲解 Feed 类型(iex/sip)、分页陷阱、资产/时钟/日历的 host 差异等实战细节
  • 面向量化交易高频刚需,显著提升数据获取效率与可靠性
触发精准95/100

亮点

  • 触发词精准聚焦 Alpaca 券商行情数据,边界清晰不易误触
  • description 与正文多次强化关键词,确保 Agent 准确识别意图
结构规范94/100

待提升项

  • description 重复 原报告严重程度:轻微

    顶层 frontmatter 与 skill_body 内部均包含 description,内容重复

    改进建议:建议合并至一处,避免冗余

  • 缺少显式 When to Use 章节 原报告严重程度:轻微

    文档隐含使用场景但未设独立章节标题

    改进建议:增加 'When to Use' 或 '适用场景' 章节以提升可读性

  • 文档较长 原报告严重程度:轻微

    skill_body 内容详实但篇幅较长,可能影响快速查阅

    改进建议:考虑增加目录锚点或拆分子章节

亮点

  • 结构清晰,分模块讲解 Hosts、REST、WebSocket、Feeds 等核心概念
  • 含端到端示例(如 WebSocket 连接与订阅流程)
  • frontmatter 完整,版本与分类明确
执行可靠91/100

亮点

  • 工具来源明确(Alpaca 官方 API 文档链接)
  • 参数说明详尽,覆盖 timeframe、feed、分页、认证等关键项
  • 覆盖主要异常场景(如连接超限、认证失败、分页截断)并提供应对建议
证据可验 (前四项均值)93/100

取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。

正文静态检测

100 / 100 · skillpi-20261123-no-r3-v1

正文未命中当前规则。

分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。

权限与使用前检查

根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。

  • 账号、密钥或授权

    使用专用、最小权限账号,不把密钥粘贴到公开内容或命令日志;核对接收数据的服务与租户。

    主文档提及 · 第 43 行
文档引用的域名或地址

这些地址可能用于文档链接或示例,不是已批准的联网清单。使用前核对实际目的地及发送的数据。

  • api.alpaca.markets
  • data.alpaca.markets
  • docs.alpaca.markets
  • github.com

本站展示提示不会授予权限。涉及文件改动、密钥、外部发送或费用时,仍由你使用的工具按需确认。

安全评级与访问范围

safe · 静态证据核验,不代表运行安全保证。

来源文档未说明。

使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。