Agent skill

Alpaca Trading

by gauss314 in gauss314/skills

Trading API de Alpaca: órdenes, posiciones, cuenta. An agent skill from gauss314/skills.

MITAuto-check passedBusiness, Finance & HR

Install Alpaca Trading

skills CLI
$ npx skills add gauss314/skills --skill alpaca-trading -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install gauss314/skills alpaca-trading --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/gauss314/skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/alpaca-trading .claude/skills/alpaca-trading && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
alpaca-trading
GitHub stars
248
Token cost
~2.4k tokens
SKILL.md length
357 words
Files
4 (incl. scripts)
Skills in repo
32
Repo updated
First seen
Licence
MIT

At a glance

Trading API de Alpaca: órdenes, posiciones, cuenta. An agent skill from gauss314/skills.

  • Works in 3 steps: Ir a app.alpaca.markets → Crear cuenta (paper trading es gratis) → Ir a "API Keys" → Generate New Keys
  • Tasks that involve Trading and backtesting
  • SKILL.md covers Autenticación, Rate Limits, Account and Assets, plus 3 more sections
  • Runs Python scripts from its folder; calls python and pip; reaches paper-api.alpaca.markets and api.alpaca.markets; needs API_KEY and SECRET_KEY

What it does

Alpaca Trading is an agent skill from gauss314/skills. Trading API de Alpaca: órdenes, posiciones, cuenta. Paper trading y live trading de acciones, crypto y opciones.

Its SKILL.md is about 2.4k tokens, which your agent loads only when the skill is triggered. The skill folder holds 4 other files, including scripts (for example `scripts/check_account.py`, `scripts/check_positions.py` and `scripts/place_order.py`).

It sits in Business, Finance & HR, covering Trading and backtesting. It works with Alpaca. The repository describes itself as: Financial market data consumption skills for claude code and AI agents. The licence is MIT.

When your agent uses it

  • Tasks that involve Trading and backtesting

Example prompts

  • “/alpaca-trading”

Requirements

  • Python 3
  • A credential in API_KEY
  • A credential in SECRET_KEY

Workflow steps

3 steps, taken from the first numbered list in SKILL.md.

  1. Ir a app.alpaca.markets
  2. Crear cuenta (paper trading es gratis)
  3. Ir a "API Keys" → Generate New Keys

What it can do on your machine

Read from SKILL.md and the folder at commit 5156f81. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships 3 files in scripts/ (Python), which the agent can run.

    Shell commands in SKILL.md call:

    • python
    • pip

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Hosts in commands or code, which the agent is likely to contact:

    • paper-api.alpaca.markets
    • api.alpaca.markets

    Also links to:

    • docs.alpaca.markets

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names these keys or tokens, usually read from environment variables:

    • API_KEY
    • SECRET_KEY
    • APCA_API_KEY_ID
    • APCA_API_SECRET_KEY

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Alpaca Trading loads about 2.4k tokens when it runs. Until then it costs about 32 tokens; SKILL.md has 357 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~32
When it runs · the whole SKILL.md, loaded when a task matches
~2.4k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); the scripts in this folder are not scanned.

SKILL.md

The full file from gauss314/skills at commit 5156f81, republished under its MIT licence (© gauss314). 357 words, ~2,390 tokens.

Download SKILL.mdSave it as .claude/skills/alpaca-trading/SKILL.md (or your agent's skills folder). This skill also uses 3 other files; get the full folder from GitHub.
name
alpaca-trading
description
Trading API de Alpaca: órdenes, posiciones, cuenta. Paper trading y live trading de acciones, crypto y opciones.
license
MIT

Alpaca Trading — Trading API

API para trading de acciones, crypto y opciones. Soporta paper trading (gratis) y live trading.

Base URLs:

  • Paper: https://paper-api.alpaca.markets
  • Live: https://api.alpaca.markets
  • SDK: pip install alpaca-py

Docs: docs.alpaca.markets


Autenticación

Obtener API Keys
  1. Ir a app.alpaca.markets
  2. Crear cuenta (paper trading es gratis)
  3. Ir a "API Keys" → Generate New Keys
Configuración
python
import os
from alpaca.trading.client import TradingClient

# Para paper trading
API_KEY = os.getenv("APCA_API_KEY_ID")
SECRET_KEY = os.getenv("APCA_API_SECRET_KEY")
BASE_URL = "https://paper-api.alpaca.markets"  # Paper

# Para live trading
# BASE_URL = "https://api.alpaca.markets"

client = TradingClient(API_KEY, SECRET_KEY, paper=True)

⚠️ NUNCA hardcodear keys. Usar variables de entorno.


Rate Limits

APILímite
Orders200 requests/min
Account/Positions200 requests/min
Account Activities200 requests/min
Recomendaciones
  • Usar WebSocket para updates en tiempo real — más eficiente que polling
  • Cachear account/positions — no consultar constantemente
  • Implementar retry con exponential backoff para 429 errors

Account

Obtener Información de Cuenta
python
account = client.get_account()
print(f"Buying Power: ${account.buying_power}")
print(f"Cash: ${account.cash}")
print(f"Portfolio Value: ${account.portfolio_value}")
print(f"Status: {account.status}")
Configuración de Cuenta
python
from alpaca.trading.requests import AccountConfigurationsRequest

config_request = AccountConfigurationsRequest(
    trade_confirmation_email=True,
    susi_transfer_email=True
)
client.update_account_configuration(config_request)

Assets

Listar Todos los Assets
python
from alpaca.trading.requests import GetAssetsRequest
from alpaca.trading.enums import AssetClass, AssetStatus

request = GetAssetsRequest(
    asset_class=AssetClass.US_EQUITY,
    status=AssetStatus.ACTIVE
)

assets = client.get_all_assets(request)

# Filtrar symbols tradables
tradable = [a for a in assets if a.tradable]
print(f"Assets tradables: {len(tradable)}")
Obtener Asset Específico
python
asset = client.get_asset("AAPL")
print(f"AAPL tradable: {asset.tradable}")
print(f"AAPL class: {asset.asset_class}")

Orders

Tipos de Órdenes
TipoDescripción
marketEjecuta al precio actual
limitPrecio máximo (buy) o mínimo (sell)
stopActiva orden de mercado cuando alcanza stop_price
stop_limitCombina stop + limit
trailing_stopStop relativo al precio
Time in Force
TIFDescripción
daySolo para día actual
gtcGood Till Cancelled
opgOpen at market open
clsClose at market close
iocImmediate Or Cancel
fokFill Or Kill
Crear Orden de Market
python
from alpaca.trading.requests import MarketOrderRequest
from alpaca.trading.enums import OrderSide, TimeInForce

order_request = MarketOrderRequest(
    symbol="AAPL",
    qty=10,
    side=OrderSide.BUY,
    time_in_force=TimeInForce.DAY
)

order = client.submit_order(order_request)
print(f"Order ID: {order.id}")
print(f"Status: {order.status}")
Crear Orden Limit
python
from alpaca.trading.requests import LimitOrderRequest

order_request = LimitOrderRequest(
    symbol="AAPL",
    qty=10,
    side=OrderSide.BUY,
    limit_price=150.00,  # Máximo a pagar
    time_in_force=TimeInForce.GTC
)

order = client.submit_order(order_request)
Crear Orden Stop
python
from alpaca.trading.requests import StopOrderRequest

order_request = StopOrderRequest(
    symbol="AAPL",
    qty=10,
    side=OrderSide.SELL,
    stop_price=145.00,  # Vende cuando caiga a este precio
    time_in_force=TimeInForce.GTC
)
Obtener Órdenes
python
# Todas las órdenes abiertas
open_orders = client.get_orders(status="open")
print(f"Órdenes abiertas: {len(open_orders)}")

# Órdenes filladas hoy
from datetime import datetime
filled_orders = client.get_orders(
    status="fill",
    start=datetime(2024, 1, 15)
)

# Orden por ID
order = client.get_order_by_id(order_id)
Cancelar Órdenes
python
# Cancelar una orden
client.cancel_order(order_id)

# Cancelar todas las órdenes abiertas
client.cancel_orders()
Reemplazar Orden
python
from alpaca.trading.requests import ReplaceOrderRequest

replace_request = ReplaceOrderRequest(
    limit_price=155.00,  # Nuevo precio límite
    qty=15               # Nueva cantidad
)
client.replace_order(order_id, replace_request)

Positions

Obtener Posiciones Abiertas
python
positions = client.get_all_positions()

for pos in positions:
    print(f"{pos.symbol}: {pos.qty} shares")
    print(f"  Avg Entry: ${pos.avg_entry_price}")
    print(f"  Market Value: ${pos.market_value}")
    print(f"  P/L: ${pos.unrealized_pl}")
Obtener Posición Específica
python
position = client.get_position("AAPL")
print(f"AAPL: {position.qty} shares @ ${position.avg_entry_price}")
Cerrar Posición
python
# Cerrar toda la posición
client.close_position("AAPL")

# Cerrar posición parcialmente (qty=5)
client.close_position("AAPL", qty=5)
Cerrar Todas las Posiciones
python
client.close_all_positions()

Options Trading

Show full SKILL.md (142 more words)Show less
Trading Levels
LevelDescripción
0Sin trading de opciones
1Covered calls, cash-secured puts
2Buy/sell calls y puts
3Spreads
Obtener Option Contracts
python
from alpaca.trading.requests import GetOptionContractsRequest
from datetime import datetime, timedelta

request = GetOptionContractsRequest(
    underlying_symbols=["AAPL"],
    expiration_date_gte=datetime.now().strftime("%Y-%m-%d"),
    expiration_date_lte=(datetime.now() + timedelta(days=30)).strftime("%Y-%m-%d"),
    strike_price_gte=100,
    strike_price_lte=200,
    limit=100
)

contracts = client.get_option_contracts(request)
contract = contracts.option_contracts[0]

# Trade con contract ID
order_request = MarketOrderRequest(
    symbol=contract.id,  # Usar ID del contract
    qty=1,
    side=OrderSide.BUY,
    time_in_force=TimeInForce.DAY
)
Ejercitar Opción
python
# Ejercer una posición de opción
client.exercise_options(position_id)

Crypto Trading

Listar Symbols Disponibles
python
from alpaca.trading.enums import AssetClass

crypto_assets = client.get_all_assets(asset_class=AssetClass.CRYPTO)
crypto = [a for a in crypto_assets if a.tradable]
print(f"Crypto tradables: {[a.symbol for a in crypto[:10]]}")
Órdenes de Crypto
python
order_request = MarketOrderRequest(
    symbol="BTC/USD",
    qty=0.1,  # Fracciones permitidas
    side=OrderSide.BUY,
    time_in_force=TimeInForce.GTC
)
client.submit_order(order_request)

Market Hours

Obtener Clock
python
clock = client.get_clock()
print(f"Market open: {clock.is_open}")
print(f"Next open: {clock.next_open}")
print(f"Next close: {clock.next_close}")
Verificar si Mercado está Abierto
python
if clock.is_open:
    print("Mercado abierto - puedes tradear")
else:
    print("Mercado cerrado")

Portfolio History

python
from datetime import datetime

history = client.get_account_portfolio_history(
    date_start=datetime(2024, 1, 1),
    timeframe="1D"
)

print(f"Equity: {history.equity}")
print(f"Profit/Loss: {history.profit_loss}")

Watchlists

python
from alpaca.trading.requests import CreateWatchlistRequest

# Crear watchlist
watchlist = client.create_watchlist(
    CreateWatchlistRequest(name="Tech Stocks")
)

# Agregar símbolo
client.add_to_watchlist(watchlist.id, "AAPL")

# Obtener watchlists
watchlists = client.get_watchlists()

WebSocket Streaming

python
from alpaca.trading.stream import TradingStream

async def handle_trade_update(data):
    print(f"Update: {data}")

stream = TradingStream(API_KEY, SECRET_KEY, paper=True)

stream.subscribe_trade_updates(handle_trade_update)
stream.run()

Scripts de Ejemplo

Ver ./scripts/:

bash
# Ver cuenta
python ./scripts/check_account.py

# Ver posiciones
python ./scripts/check_positions.py

# Enviar orden de prueba
python ./scripts/place_order.py --symbol AAPL --qty 10 --side buy --type market

Errores Comunes

ErrorCausaSolución
403 ForbiddenKeys inválidasVerificar API keys
403Sin permisosHabilitar en dashboard
400 Bad RequestParámetros inválidosVer docs de orden
403 Trading HaltedTrading pausadoEsperar o verificar
403 No Buying PowerSin fondosDepositar dinero
422Symbol no tradableVerificar symbol
429 Too Many RequestsRate limitImplementar backoff

Comparación: Paper vs Live

AspectoPaperLive
URLpaper-api.alpaca.marketsapi.alpaca.markets
Dinero real❌ No✅ Sí
Órdenes reales❌ Simuladas✅ Reales
Datos de mercado✅ Reales✅ Reales
Para testing✅ Ideal❌ No

Siempre probar en paper primero.

© gauss314, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 3 other files (scripts) in skills/alpaca-trading of gauss314/skills.

  • SKILL.md
  • scripts/check_account.py
  • scripts/check_positions.py
  • scripts/place_order.py

Open the folder on GitHubat commit 5156f81

Compare with similar skills

Alpaca Trading next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Alpaca Trading compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Alpaca Trading this skillgauss314/skills248—~2.4kAutomated safety check: PassMIT
Alpaca Trading Backtestalpacahq/alpaca-skills154—~3.9kAutomated safety check: PassApache-2.0
Alpaca Trading Paper Tradingalpacahq/alpaca-skills154—~11kAutomated safety check: PassApache-2.0
Alpaca Trading Paper Trading CLIalpacahq/alpaca-skills154—~9kAutomated safety check: PassApache-2.0
Alpaca Trading Paper Trading MCPalpacahq/alpaca-skills154—~11kAutomated safety check: PassApache-2.0
Tushare Datazillionare/zillionare3222 repos~2.3kAutomated safety check: PassNone

Similar skills

  • Alpaca Trading Backtest

    alpacahq/alpaca-skills

    Execute deterministic, reproducible historical backtests from a start date, end date, and strategy concept using the Alpaca CLI plus agent-written workspace code.

    154 GitHub stars~3.9k tokensUpdated 1 mo ago
    Business, Finance & HRAuto-check passed
  • Alpaca Trading Paper Trading

    alpacahq/alpaca-skills

    Preview, submit, inspect, and manage Alpaca paper-trading orders across US equities, options, and crypto.

    154 GitHub stars~11k tokensUpdated 1 mo ago
    Business, Finance & HRAuto-check passed
  • Alpaca Trading Paper Trading CLI

    alpacahq/alpaca-skills

    Preview, submit, inspect, and manage Alpaca paper-trading orders using the Alpaca CLI.

    154 GitHub stars~9k tokensUpdated 1 mo ago
    Business, Finance & HRAuto-check passed
  • Alpaca Trading Paper Trading MCP

    alpacahq/alpaca-skills

    Preview, submit, inspect, and manage Alpaca paper-trading orders using the Alpaca Trading API MCP Server.

    154 GitHub stars~11k tokensUpdated 1 mo ago
    Business, Finance & HRAuto-check passed
  • Tushare Data

    zillionare/zillionare

    面向中文自然语言的 Tushare 数据研究技能。用于把“看看这只股票最近怎么样”“帮我查财报趋势”“最近哪个板块最强”“北向资金在买什么”“给我导出一份行情数据”这类请求,转成可执行的数据获取、清洗、对比、筛选、导出与简要分析流程。适用于 A 股、指数、ETF/基金、财务、估值、资金流、公告新闻、板块概念与宏观数据等研究场景。

    322 GitHub starsUsed in 2 repos~2.3k tokens
    Business, Finance & HRAuto-check passed
  • Tradingview MCP

    atilaahmettaner/tradingview-mcp

    AI Trading Intelligence — live prices, 30+ technical indicators, backtesting (6 strategies), walk-forward overfitting detection, trade logs, equity curves, licensed news sentiment (Marketaux), and…

    5k GitHub stars~1.3k tokensUpdated yesterday
    Business, Finance & HRAuto-check passed

More from gauss314/skills

All 32 skills in this repo
  • Backtesting

    gauss314/skills

    Academic backtesting framework for quantitative research. An agent skill from gauss314/skills.

    248 GitHub stars~2.4k tokensUpdated 3 mo ago
    Auto-check passed
  • Google Finance

    gauss314/skills

    Datos de Google Finance via batchexecute (API RPC interna sin auth ni API key).

    248 GitHub stars~3.1k tokensUpdated 3 mo ago
    Auto-check passed
  • Historyofmarket

    gauss314/skills

    History of Market (historyofmarket.com) — API publica con 88 datasets historicos de indices US desde 1871.

    248 GitHub stars~1.6k tokensUpdated 3 mo ago
    Auto-check passed
  • Indec

    gauss314/skills

    Datos macro y sociales de Argentina via la API oficial Series de Tiempo del Estado (apis.datos.gob.ar/series).

    248 GitHub stars~3k tokensUpdated 3 mo ago
    Auto-check passed
  • Morningstar

    gauss314/skills

    Morningstar Screener via API JSON publica: descarga masiva de 53 universes (102K+ listings, 39 paises, NYSE/Nasdaq/BCBA/etc) con 33 campos (precio, market cap, ratios, retornos…

    248 GitHub stars~2.6k tokensUpdated 3 mo ago
    Auto-check passed
  • Option Pricing

    gauss314/skills

    Pricing completo de opciones europeas y americanas. An agent skill from gauss314/skills.

    248 GitHub stars~4.7k tokensUpdated 3 mo ago
    Auto-check passed

Works with

Questions about Alpaca Trading

What does Alpaca Trading do?

Trading API de Alpaca: órdenes, posiciones, cuenta. An agent skill from gauss314/skills. Alpaca Trading is an agent skill from gauss314/skills. Trading API de Alpaca: órdenes, posiciones, cuenta.

When should I use Alpaca Trading?

Alpaca Trading fits situations like: tasks that involve Trading and backtesting.

How do I install Alpaca Trading in Claude Code?

Run `npx skills add gauss314/skills --skill alpaca-trading -a claude-code`. Or copy the skill folder (skills/alpaca-trading in gauss314/skills) into .claude/skills/alpaca-trading in your project. Claude Code loads it when a task matches its description.

How do I install Alpaca Trading in Codex?

Run `npx skills add gauss314/skills --skill alpaca-trading -a codex`. Or copy the skill folder (skills/alpaca-trading in gauss314/skills) into .agents/skills/alpaca-trading in your project. Codex loads it when a task matches its description.

Can I use Alpaca Trading in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add gauss314/skills --skill alpaca-trading -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/alpaca-trading, .gemini/skills/alpaca-trading, .github/skills/alpaca-trading and .opencode/skills/alpaca-trading in your project.

What does Alpaca Trading need to run?

Going by SKILL.md and its folder, Alpaca Trading needs Python for the scripts in its folder, the command-line tools its instructions call (python and pip) and credentials named API_KEY, SECRET_KEY, APCA_API_KEY_ID and APCA_API_SECRET_KEY. Our summary lists: Python 3; A credential in API_KEY; A credential in SECRET_KEY.

Does Alpaca Trading access the network?

SKILL.md names 3 domains. In commands or code: paper-api.alpaca.markets and api.alpaca.markets; the agent is likely to contact these when it follows the instructions. As links in the text: docs.alpaca.markets. This is read from the text; nothing was executed.

Is Alpaca Trading safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. The check reads SKILL.md only: the scripts in the folder are not scanned, so read them before running anything.

What licence does Alpaca Trading use?

Alpaca Trading is published under the MIT licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Alpaca Trading use?

About 2.4k tokens (SKILL.md is roughly 9.6k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Alpaca Trading?

Skills that share tags, products or a category with Alpaca Trading: Alpaca Trading Backtest (alpacahq/alpaca-skills, 154 stars), Alpaca Trading Paper Trading (alpacahq/alpaca-skills, 154 stars), Alpaca Trading Paper Trading CLI (alpacahq/alpaca-skills, 154 stars) and Alpaca Trading Paper Trading MCP (alpacahq/alpaca-skills, 154 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Alpaca Trading?

gauss314 (a GitHub user) maintains it in gauss314/skills, which has 248 GitHub stars. The repository holds 32 skills in this directory. The repository was last updated on June 14, 2026.

Source: gauss314/skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.