alpaca-broker-sse-events

Consume Alpaca Broker API lifecycle events over Server-Sent Events with replay cursors and idempotent processing.

4|Updated Aug 28, 2026
One-click install
npx skills add https://github.com/alan-d-smith/synthetix-alpha --skill alpaca-broker-sse-events-alan-d-smith
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: alpaca-broker-sse-events
Source: https://github.com/alan-d-smith/synthetix-alpha/tree/main/.agents/skills/alpaca-broker-sse-events
Command: npx skills add https://github.com/alan-d-smith/synthetix-alpha --skill alpaca-broker-sse-events-alan-d-smith

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Building a reliable consumer for Alpaca Broker API real-time event streams is error-prone: connections silently die, events are missed during downtime, and duplicate deliveries corrupt local state. This Skill provides the connection, replay-cursor, reconnection, and idempotency patterns needed to process account, journal, funding, trade, and non-trade-activity events without data loss. ## Core Features & Use Cases - Stream coverage: Documents all five SSE streams (account status, journals, funding/transfers, trades, non-trade activities) including their inconsistent v1/v2 paths and ULID versus integer event ID cursors. - Replay and recovery: Explains since/since_id/since_ulid cursors so a reconnecting consumer replays missed events instead of silently dropping them. - Reliability patterns: Covers heartbeat/silence detection, exponential backoff with a single-reconnect guard, and an idempotent processing pipeline keyed on event_id. - Use Case: You are building a backend that must update local order and transfer state the moment Alpaca fills an order or executes a journal. Use this Skill to implement an SSE consumer that survives deploys and network drops, deduplicates replays, and pairs with periodic reconciliation. ## Quick Start Use the alpaca-broker-sse-events skill to implement a resilient SSE consumer for Alpaca trade update events with reconnect and idempotent processing.

Frequently Asked Questions about alpaca-broker-sse-events

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I consume Alpaca Broker API events with Server-Sent Events?▼

Open a long-lived HTTP GET to a stream path such as /v2/events/trades with Basic auth and Accept: text/event-stream, then parse data: lines as JSON. Use a server-side SSE client that supports custom Authorization headers, since the browser EventSource API does not.

How do I avoid missing Alpaca events after a reconnect?▼

Persist the ID of the last successfully processed event and pass it as a since cursor on every reconnect: since_id on v2 streams, since_ulid or since_id on v1 streams. Without a cursor, Alpaca returns no history and you only receive live pushes.

What is the difference between Alpaca SSE events and the market data WebSocket?▼

SSE streams carry brokerage lifecycle events like account status, journals, transfers, and order updates over HTTP with Basic auth. The market data WebSocket is a separate transport with different auth and carries quotes and trades, not account lifecycle events.

Why does my generated API client hang on Alpaca SSE endpoints?▼

OpenAPI cannot fully model SSE, so codegen'd clients wait for a complete response that never arrives on a streaming endpoint. Use a real streaming HTTP or SSE client that reads the response body incrementally instead.

How do I handle duplicate Alpaca events from replay?▼

Process events idempotently: insert a raw snapshot keyed on event_id with skip-if-exists semantics, lock the target row when mutating state, and guard transitions by current status. Advance your stored cursor only after successful processing so crashes replay rather than skip events.

Is SSE alone enough to keep local state in sync with Alpaca?▼

No. Even a correct consumer can miss events during extended downtime or from unhandled types. Pair SSE with a periodic reconciliation pass that re-pulls authoritative state for activities, journals, and transfers and upserts it locally.