alpaca-trading

Implements Alpaca Trading API workflows for orders, positions, and account management.

1|2|Updated Nov 25, 2017
One-click install
npx skills add https://github.com/asarchami/dotfiles --skill alpaca-trading-asarchami
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: alpaca-trading
Source: https://github.com/asarchami/dotfiles/tree/main/dot_config/opencode/skills/alpaca/trading
Command: npx skills add https://github.com/asarchami/dotfiles --skill alpaca-trading-asarchami

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Building automated trading systems against the Alpaca Trading API requires handling order lifecycle states, rate limits, authentication differences between paper and live environments, and WebSocket event streams, which is error-prone without structured guidance. ## Core Features & Use Cases - Order Management: Submit, replace, and cancel market, limit, stop, trailing stop, bracket, OTO, and OCO orders with correct time-in-force and order class parameters. - Account & Position Operations: Query account status, buying power, open positions, and close positions individually or in bulk. - Real-Time Streaming: Authenticate and subscribe to trade_updates and account_updates channels over the Alpaca WebSocket feed. - Use Case: You are writing a Go trading bot that submits bracket orders with take-profit and stop-loss legs, retries on 429 rate limits using the Retry-After header, and validates strategies against the paper trading endpoint before going live. ## Quick Start Use the alpaca-trading skill to submit a bracket buy order for 10 shares of AAPL with a take-profit and stop-loss against the paper trading API.

Frequently Asked Questions about alpaca-trading

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

FAQPage Schema
How do I submit a bracket order with the Alpaca Trading API?

Submit a bracket order by POSTing to /v2/orders with order_class set to bracket and including take_profit and stop_loss objects with limit_price and stop_price. The primary order executes first, then the take-profit and stop-loss legs activate as an OCO pair.

How to handle Alpaca API rate limits in a trading bot?

Alpaca's basic plan allows 200 requests per minute and returns HTTP 429 when exceeded. Read the Retry-After header from the 429 response and apply exponential backoff, adding the retry delay plus an increment per attempt before resending.

Does Alpaca paper trading use the same API as live trading?

Paper trading uses the same endpoints and behavior as live trading but with the base URL paper-api.alpaca.markets instead of api.alpaca.markets. Paper and live credentials are separate and cannot be mixed, and paper accounts come pre-funded with $100k.

Can I buy fractional shares through the Alpaca API?

Yes, fractional trading is supported for over 2,000 US equities using market orders only. Specify a notional dollar amount instead of qty in the order request, and check the fractionable field on the asset to confirm eligibility.

Why does my Alpaca order request return HTTP 422?

HTTP 422 indicates a validation error in the order request, such as an invalid time_in_force value, missing limit_price for limit orders, or incompatible parameters. Inspect the response body for the specific field-level error details.

How do I receive real-time order updates from Alpaca?

Connect to wss://stream.data.alpaca.markets/v2/trading and send an auth message with your API key and secret. Then subscribe to the trade_updates channel for order status changes and account_updates for account value changes.