alpaca-broker-integration-uzdp

Alpaca 券商系统集成专用技能,帮助 AI Agent 高效完成与 Alpaca 券商系统集成相关的任务。

安装方式

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

用 AI 助手安装

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

查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "alpaca-broker-integration-uzdp":https://skillpi.com/zh/skills/deepskill-64299a388b46e50d94592c0782a648d66c370672ce32e56df453b7c7bbe1631b。安装前核对上游来源和版本:https://skillhub.cn/skills/user_3c6cb52e/alpaca-broker-integration-uzdp。来源不一致时停止并说明差异。核对通过后,用 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-integration
version: 1.0.0
displayName: Alpaca券商系统集成
description: >
  Alpaca券商系统集成专用技能,帮助AI Agent高效完成相关任务。
summary: "Entry point for integrating with the Alpaca Broker API (plus Market Data and Trading APIs) in any programming language. Use when a developer wants to build on Alpaca — open brokerage accounts, run KYC..."
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 Integration Assistant

You are an expert on the Alpaca APIs. Help developers integrate with Alpaca in any programming language. Generate working code, explain protocols, and debug integration issues.

This is the router / overview skill. It covers the things that are true across all of Alpaca's APIs — the API families, base URLs, auth, consumption styles, and wire conventions — and points you to a focused sub-skill for each domain. Read this first, then jump to the specific skill for the task.

Most of the hard-won value in these skills is in the lessons-learned sub-skills (reconciliation, rate limits, money precision, SSE reliability). Alpaca's reference docs tell you what the endpoints are; these skills tell you what breaks in production and why.


Reference Documentation

  • Docs home: https://docs.alpaca.markets/
  • API reference: https://docs.alpaca.markets/reference/
  • Machine-readable index: https://docs.alpaca.markets/llms.txt and https://docs.alpaca.markets/llms-full.txt
  • OpenAPI specs (4): Authentication API, Broker API, Market Data API, Trading API

Live schema lookups: if the alpaca-docs MCP server is connected, prefer it over guessing — list-specs, list-endpoints, get-endpoint (exact request/response schemas + servers), and search / fetch (guide pages). Always confirm an exact payload against the spec before generating code that posts money or orders.


1. The four API families

Family What it's for Who uses it
Broker API Open & manage brokerage accounts on behalf of your end users (KYC, funding, journals, trading-for-accounts, documents, events). You are the broker-of-record's tech partner; you custody many sub-accounts under your firm. Apps that onboard their own users and hold their assets (neobrokers, fintechs).
Trading API Trade a single account that belongs to the API-key holder. Individual algo traders, bots.
Market Data API Real-time + historical prices, bars, quotes, trades, news, corporate actions, screener. REST and WebSocket. Everyone.
Authentication API OAuth 2.0 flows for letting third parties act on an Alpaca account. OAuth integrations.

Decide first which family you're on — it changes the base URL, the auth, and the URL shape of every call. The most common confusion: Broker API places orders at /v1/trading/accounts/{account_id}/orders (the account is in the path because you act for a user), whereas the standalone Trading API places orders at /v2/orders (implicitly your own account).

These skills focus primarily on the Broker API, because that's where the lifecycle is hardest: onboarding, funding rails, journals, and event reconciliation.


2. Base URLs

Family Production Sandbox / Paper
Broker API https://broker-api.alpaca.markets https://broker-api.sandbox.alpaca.markets
Trading API https://api.alpaca.markets https://paper-api.alpaca.markets (paper)
Market Data (REST) https://data.alpaca.markets (same host; sandbox data is limited)
Market Data (WebSocket) wss://stream.data.alpaca.markets wss://stream.data.sandbox.alpaca.markets

Always start in sandbox. Switch by environment variable, never by code path — a single ENV flag that selects the base URL is the pattern that survives. Sandbox accounts can be funded with fake money and auto-approved, so you can exercise the full lifecycle without real KYC or cash.


3. Authentication

Auth differs by API family — this trips people up constantly.

Broker API → HTTP Basic

Authorization: Basic base64("<API_KEY_ID>:<API_SECRET_KEY>")

The same Basic credential authenticates Broker REST, Broker SSE event streams, and trading-on-behalf-of-accounts. Build the base64 token once at startup; don't recompute per request.

Market Data API → key/secret headers (or Basic in broker context)

APCA-API-KEY-ID: <API_KEY_ID>
APCA-API-SECRET-KEY: <API_SECRET_KEY>

For the WebSocket data stream, you don't use headers — you send an auth message after connecting:

{"action": "auth", "key": "<API_KEY_ID>", "secret": "<API_SECRET_KEY>"}

Broker API partners can usually authenticate market-data calls with their Broker Basic credentials too. Pick one scheme per data client and be consistent; mixing them is a frequent source of 401s.

Trading API → key/secret headers

Same APCA-API-* headers as market data.

Authentication API → OAuth 2.0 Bearer

For OAuth integrations, exchange the code for a token and send Authorization: Bearer <token>.


4. Three consumption styles

Alpaca gives you three transports. Use the right one for the job — and know that they have different auth and different reliability characteristics.

Style Transport Use for Skill
REST HTTPS request/response Everything transactional: create account, fund, journal, place order, query state. the domain skills
SSE text/event-stream over a long-lived HTTPS GET Broker lifecycle events: account status, journals, transfers, trades, non-trade activities. Replayable via cursors. alpaca-broker-sse-events
WebSocket wss:// Real-time market data (trades/quotes/bars). alpaca-broker-market-data

Key distinction: Broker events come over SSE (simple HTTP, Basic auth, replayable with since/since_id). Market data comes over WebSocket (subscribe model, auth message, ping/pong). They are different endpoints with different auth — don't conflate them.


5. Wire conventions (true across the platform)

These apply everywhere and are the source of most subtle bugs:

  • Numbers are strings. Prices, quantities, notional, and money amounts come back as JSON strings ("100.50", "1.5"). Parse into a decimal type, never a binary float. See alpaca-broker-money-precision.
  • IDs: account_id, order_id, journal_id, transfer_id are UUIDs. Activity IDs and newer event IDs are ULIDs — lexicographically sortable, which matters for event ordering and replay cursors.
  • Idempotency: pass your own client_order_id on orders so retries don't double-fill. Records you create from events should be keyed on the Alpaca ID with upsert/skip-duplicate semantics. See alpaca-broker-reconciliation-idempotency.
  • Pagination: list endpoints page forward with a token. Market-data bars return next_page_token in the body; activities return a page token via the X-Next-Page-Token response header. Loop until the token is empty.
  • Rate limits: responses carry X-RateLimit-Limit, X-RateLimit-Remaining, and X-RateLimit-Reset (unix seconds). On HTTP 429, wait until reset before retrying. See alpaca-broker-rate-limits-resilience.
  • Timestamps: RFC3339 (e.g. 2026-01-02T15:04:05Z). SSE since/until accept RFC3339, but + in a timezone offset must be URL-encoded as %2B.
  • Status ≠ done. Almost every write (account, journal, transfer, order) is asynchronous and moves through a state machine. A 200 means "accepted," not "settled." Always reconcile on the terminal status, which arrives later via event or poll.

6. Sandbox-first workflow

When helping someone start from zero, walk them through this order:

  1. Pick sandbox URLs via an ENV switch.
  2. Authenticate with Basic (Broker) — verify with GET /v1/accounts (list).
  3. Create an account with full KYC payload → alpaca-broker-account-onboarding.
  4. Wait for ACTIVE status (via SSE account-status events or polling) before any money/trade op.
  5. Fund it (sandbox lets you simulate deposits) → alpaca-broker-funding-transfers.
  6. Move cash where it's needed with journals → alpaca-broker-journals.
  7. Place an order → alpaca-broker-trading-orders.
  8. Subscribe to events to track fills/transfers in real time → alpaca-broker-sse-events.
  9. Add a reconciliation pass before going live → alpaca-broker-reconciliation-idempotency.

7. Skill map — where to go next

If the task is about… Use skill
Creating accounts, KYC, CIP, document upload, agreements, account status, W-8BEN alpaca-broker-account-onboarding
ACH / wire / funding-wallet rails, deposits, withdrawals, transfer status, the omnibus/float-account model alpaca-broker-funding-transfers
Moving cash (JNLC) or shares (JNLS) between accounts, batch & reverse-batch, journal lifecycle alpaca-broker-journals
Placing/canceling orders, qty vs notional, fractional shares, order lifecycle, positions, recurring buys alpaca-broker-trading-orders
Snapshots, bars, quotes, assets, news, market clock/calendar, feeds (IEX/SIP), WebSocket price streams alpaca-broker-market-data
Consuming Broker SSE event streams reliably (reconnect, heartbeats, replay cursors) alpaca-broker-sse-events
Keeping local state correct: missed-event recovery, polling rails without webhooks, idempotency, status guards alpaca-broker-reconciliation-idempotency
Backoff, 429 handling, rate-limit headers, concurrency limits, batch sizing alpaca-broker-rate-limits-resilience
Handling money correctly: decimals vs floats, numbers-as-strings, truncation/rounding alpaca-broker-money-precision

8. Integration guidance (applies regardless of language)

  1. One base-URL switch, environment-driven. Never hardcode prod URLs in a code branch.
  2. Build auth once. Cache the Basic token / header set at client construction.
  3. Treat every write as async. Model the state machine; act on terminal states, not on the 2xx.
  4. Persist Alpaca's IDs. Store account_id, order_id, journal_id, transfer_id on your local records — they are your only correlation key for events and reconciliation.
  5. Decimals, not floats, for anything monetary. Parse the string fields into a decimal type.
  6. Reconcile, don't trust the stream. SSE can drop events; design a polling/heal pass that re-syncs from Alpaca as source of truth (alpaca-broker-reconciliation-idempotency).
  7. Respect rate limits proactively. Watch X-RateLimit-Remaining, back off before you get throttled.
  8. Use client_order_id and Alpaca-ID-keyed upserts so retries and duplicate events are safe.

Language notes (transport only — Alpaca is HTTP/SSE/WS, so any stack works)

  • Python: httpx/requests (REST), httpx/aiohttp or an SSE client for events, websockets for data, decimal.Decimal for money.
  • TypeScript/Node: fetch (REST), an EventSource implementation for SSE (pass the Authorization header), ws for WebSocket, decimal-as-string or decimal.js.
  • Go: net/http (REST + SSE via a streaming bufio.Scanner), gorilla/websocket for data; be deliberate about money types (shopspring/decimal if precision matters).
  • Any language: SSE is just a long-lived HTTP GET that yields text/event-stream; if no SSE client exists, read the response body line-by-line and parse data: frames.

Alpaca also publishes official SDKs (alpaca-py, @alpacahq/alpaca-trade-api / typescript-sdk, Go community SDKs). Offer them when the user wants speed, but these skills teach the wire protocol so the knowledge transfers to any language or a custom client.

当前收录版本

1.0.0

核对来源版本 ↗

安全与评测信息

质量评测

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

场景价值85/100

亮点

  • 提供 Alpaca 券商 API 集成的全面指导,涵盖账户开户、资金转移、交易订单、市场数据等核心功能
  • 详细说明四种 API 家族的区别与适用场景,帮助用户准确选择接口
  • 强调沙箱优先工作流和端到端集成最佳实践,显著降低开发门槛
触发精准80/100

亮点

  • description 清晰说明了 Skill 的核心功能和使用场景
结构规范90/100

亮点

  • 文档结构清晰,分章节详细说明了 API 家族、基础 URL、认证、消费模式、线规、沙箱工作流、技能映射和集成指导
  • 包含端到端示例和最佳实践,frontmatter 完整
执行可靠85/100

亮点

  • 提供详细的 API 使用说明、认证方式、错误处理(如速率限制、SSE 可靠性)、资金精度处理等
  • 工具来源明确,参数正确,覆盖了主要异常情况
证据可验 (前四项均值)85/100

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

正文静态检测

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

正文未命中当前规则。

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

权限与使用前检查

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

文档引用的域名或地址

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

  • api.alpaca.markets
  • broker-api.alpaca.markets
  • broker-api.sandbox.alpaca.markets
  • data.alpaca.markets
  • docs.alpaca.markets
  • github.com
  • paper-api.alpaca.markets

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

安全评级与访问范围

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

来源文档未说明。

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