Alpaca Paper Trading

SkillCommerce & finance

This skill lets your AI place and manage practice trades in your Alpaca paper-trading environment, covering US equities, options, and crypto. Give it a strategy signal from a backtest, a manual idea, or an automated system, and it can execute that signal safely so you can see how it performs without real money on the line.

Available today. Use it from your connected AI after setup.

Add the skill, then ask your AI to preview and submit a first practice order in your Alpaca paper-trading account. From there you can hand it signals to execute and review the results.

Then ask your AI: use the Alpaca Paper Trading skill

What your AI can do with it

  • Preview an order before it is submitted
  • Submit orders across US equities, options, and crypto
  • Inspect the details of submitted orders
  • Manage open orders in your paper-trading account
  • Act on signals from a backtest, a manual idea, or an automated system

What this skill tells your AI

The instructions your AI receives, as published by alpacahq/alpaca-skills in skills/trading-api/paper-trading/SKILL.md and read by ahel’s review.

Use this skill when you want your AI agent to preview, submit, inspect, and manage paper-trading orders using Alpaca's Trading API.

This skill is written for you, a Trading API user working with your own Alpaca paper-trading account, credentials, and local workspace. Your agent should make assumptions visible, protect secrets, and confirm order details before submission.

This is the generic (implementation-agnostic) version of the paper-trading skill. It describes the workflow, safety gates, and output contract without binding to any specific execution tool. You can use the Alpaca Python SDK (alpaca-py), the REST API directly, JavaScript/TypeScript, Go, C#, or any tool that speaks to the Trading API. CLI-specific and MCP-specific companion skills exist for users who prefer those execution paths — see §10 for links.


0 - How your AI agent should use this skill

  1. Start with your job. Identify what the signal is — a backtest output, a manual trade idea, a scheduled trigger, or an automated system event. Your agent reads any associated context (backtest run folder, strategy description, alert payload) to understand the intent.

  2. Reiterate the strategy logic. Your agent restates the strategy interpretation in plain language — entry/exit conditions, indicator parameters, position sizing, and any assumptions — and confirms with you that the interpretation is correct before proceeding.

  3. Gather and confirm ALL detailed configurations before execution. Your agent collects every order parameter explicitly:

    • Timing of execution (immediate, scheduled, conditional)
    • Asset class (US equity, US options, crypto)
    • Symbol(s)
    • Side (buy / sell)
    • Quantity or notional amount
    • Order type (market, limit, stop, stop_limit, trailing_stop)
    • Time-in-force (day, gtc, ioc, fok, opg, cls)
    • Limit price and/or stop price if applicable
    • Extended-hours flag
    • Risk controls (max position size, max notional, stop-loss, take-profit)
    • Margin usage
  4. Confirm which paper account is being used. Your agent verifies that the paper account's configuration meets the strategy's requirements — options approval level, crypto enabled, margin vs cash account, PDT status. It does not assume features are enabled without checking.

  5. Show a complete order preview table before submission. Every order gets a visual preview with all parameters displayed, estimated notional, and buying power check. No order is ever submitted without a preview.

  6. Ask about confirmation preference. Your agent asks whether you want explicit confirmation before each order submission, or whether you prefer auto-submit mode. It respects your preference for the session. Default: confirmation ON.

  7. Submit the order to the paper-trading environment only. Your agent verifies the environment is paper before every submission. It never submits to live.

  8. Return complete post-submission details. After submission, your agent returns the order ID, status, submitted payload summary, and next inspection steps.

  9. Monitor and update on order lifecycle.

    • Filled → how many shares/contracts, at what price, and how the fill changes portfolio risk.
    • Partially filled → current fill vs remaining quantity, average fill price so far.
    • Rejected → the rejection reason and specific remediation suggestions.
    • Canceled → who canceled (you, system, broker) and why.
  10. Never place live trades. If live credentials are detected — base URL without the paper- prefix, or a profile set to live — your agent stops immediately and warns you. This is a hard block, not a soft warning.


1 - Prerequisites

  • Alpaca paper-trading account — free at alpaca.markets
  • Paper API key and secret key stored in environment variables (APCA_API_KEY_ID, APCA_API_SECRET_KEY) or SDK/CLI profile — never pasted into chat
  • Paper base URL: https://paper-api.alpaca.markets (for REST) or appropriate SDK configuration pointing to the paper environment
  • For options: options trading must be enabled on the paper account with the appropriate approval level (level 1 for covered calls and cash-secured puts, level 2 to buy calls and puts, level 3 for spreads and straddles)
  • For crypto: crypto trading must be enabled on the paper account
  • SDK / language runtime (choose one):
    • Python 3.10+ with alpaca-py (recommended)
    • JavaScript/TypeScript with @alpacahq/alpaca-trade-api (v4+, first-party and actively maintained)
    • Go with github.com/alpacahq/alpaca-trade-api-go/v3 — the /v3 suffix is required; without it you pull the v1 path
    • C# with Alpaca.Markets (first-party). Community SDKs exist for Java and others.
    • Direct REST API calls via curl, httpx, requests, or any HTTP client
  • Network access to Alpaca APIs (paper-api.alpaca.markets)

2 - Gather inputs

Required inputs

InputDescriptionDefault
signal_sourceWhere the trade idea comes from (backtest, manual, automation)Must be provided
symbolTicker symbol (e.g., AAPL, BTC/USD, AAPL250718C00200000 for options)Must be provided
sidebuy or sellMust be provided
qty_or_notionalNumber of shares/contracts OR dollar amount (use qty for shares/contracts, notional for dollar amount)Must be provided
order_typemarket, limit, stop, stop_limit, trailing_stopsupported values vary by asset class, see belowmarket
time_in_forceday, gtc, ioc, fok, opg, clssupported values vary by asset class, see belowday for equities; gtc for crypto

Per-asset-class constraints

The API rejects combinations outside this matrix, so your agent validates before submitting rather than after:

Asset classOrder typesTime-in-forceOrder classes
us_equitymarket, limit, stop, stop_limit, trailing_stopday, gtc, opg, cls, ioc, foksimple, bracket, oco, oto
us_optionmarket, limit, stop, stop_limit (stop types single-leg only)day, gtcsimple, mleg
cryptomarket, limit, stop_limitgtc, iocstop_limit is gtc-only, and ioc applies only to market and limitsimple

Treat this as guidance for constructing orders, not as a hard pre-submission gate. Alpaca's sources disagree on the options row: the OpenAPI TimeInForce/OrderType descriptions say market/limit with day only, while the Options Trading page and the Placing Orders matrix both allow gtc and both allow stop/stop_limit on single-leg orders. The two product pages agree against the spec blob, so this table follows them. Default to day for options as the conservative choice, but let Alpaca reject rather than pre-blocking something the matrix permits.

Constraints that cut across order type:

  • Extended hours requires limit type with day or gtc TIF. Everything else is rejected.
  • Trailing stop accepts only day and gtc.
  • Notional orders cannot be combined with qty and cannot be replaced — cancel and resubmit instead. For equities they additionally require market type with day TIF; crypto notional orders are market-type and use the crypto TIF set (gtc/ioc), so the equities day restriction does not apply to them.
  • Bracket, OCO, and OTO are equities-only, require day or gtc, and do not support extended hours.
  • mleg carries up to 4 legs and is how multi-leg options strategies are expressed.

Optional inputs

InputDescriptionDefault
limit_priceRequired for limit and stop_limit ordersNone
stop_priceRequired for stop and stop_limit ordersNone
trail_price or trail_percentFor trailing stop orders (one or the other, not both)None
extended_hoursAllow extended-hours execution (equities only; limit type with day or gtc TIF)false
client_order_idUser-supplied idempotency key (max 128 chars)Auto-generated UUID
confirmation_modeWhether your agent asks for explicit confirmation before each orderon
risk_controlsMax position size, max notional, max loss thresholdNone (recommended to set)
asset_classus_equity, us_option, cryptoInferred from symbol format
order_classsimple, bracket, oco, oto, mleg — see the per-asset-class matrix abovesimple
position_intentbuy_to_open, buy_to_close, sell_to_open, sell_to_close (options only)Inferred from context

Strategy confirmation checklist

Before proceeding past the configuration phase, your agent must confirm each of these with you:

  • Strategy logic interpretation is correct — the agent's restatement of your strategy matches your intent
  • Timing — immediate execution, or scheduled/conditional (e.g., "only if price drops below $180")
  • Asset class and symbol are correct — the right ticker, the right contract (for options), the right pair (for crypto)
  • Order parameters match the strategy intent — type, side, quantity, prices, TIF all align with what you want
  • Paper account is configured for this asset class — options approval, crypto enabled, margin type
  • Risk controls are set (or explicitly waived) — you've acknowledged position sizing, stop-loss, and concentration limits

3 - Source-of-truth references

SourceURLUsed for
Trading API overviewhttps://docs.alpaca.markets/us/docs/trading-apiAPI capabilities and structure
Working with ordershttps://docs.alpaca.markets/us/docs/working-with-ordersOrder submission, replacement, cancellation
Orders on Alpacahttps://docs.alpaca.markets/us/docs/orders-at-alpacaOrder types, TIF values, status lifecycle
Paper tradinghttps://docs.alpaca.markets/us/docs/paper-tradingPaper environment behavior and limitations
Working with positionshttps://docs.alpaca.markets/us/docs/working-with-positionsPosition retrieval and management
Working with accounthttps://docs.alpaca.markets/us/docs/working-with-accountAccount state, buying power, day trade count
Working with assetshttps://docs.alpaca.markets/us/docs/working-with-assetsTradability checks, asset attributes
Options tradinghttps://docs.alpaca.markets/us/docs/options-tradingOptions order specifics, approval levels
Crypto tradinghttps://docs.alpaca.markets/us/docs/crypto-tradingCrypto order specifics, supported pairs
Alpaca disclosureshttps://alpaca.markets/disclosuresRequired disclosure language

4 - Workflow

Phase 1: Strategy Confirmation

Step 1 — Identify the signal source. Your agent determines where the trade idea comes from:

  • Backtest output: read the run folder (notes.md, summary.json) to extract the strategy logic, confirmed parameters, and the last signal. Parse the signal for symbol, side, quantity, and any price targets.
  • Manual idea: you describe the trade in natural language. Your agent extracts the parameters and asks clarifying questions.
  • Automated system: a webhook, alert, or scheduled trigger. Your agent reads the payload and maps it to order parameters.

Step 2 — Reiterate the strategy logic. Your agent restates the complete strategy interpretation in plain language:

  • What triggers a trade (entry condition)
  • What exits a trade (exit condition, stop-loss, take-profit)
  • Indicator parameters (e.g., "20-day SMA crossover with 50-day SMA")
  • Position sizing rules (e.g., "risk 1% of portfolio per trade")
  • Any assumptions your agent is making (e.g., "assuming you want to enter at market price")

Step 3 — Confirm the interpretation. Your agent asks you to confirm or correct the restatement. It does not proceed until you confirm. If you correct it, your agent restates the corrected version and asks again.

Phase 2: Configuration Agreement

Step 4 — Gather all order parameters. Using the inputs table from §2, your agent collects every required and optional parameter. It asks for anything not already specified.

Step 5 — Show parameter attribution. For each parameter, your agent shows:

  • The value being used
  • Whether it was provided by you, inferred from context (e.g., asset class from symbol format), or defaulted to a standard value

Example:

Symbol:        AAPL           (provided)
Side:          buy            (provided)
Quantity:      50 shares      (provided)
Order type:    limit          (provided)
Limit price:   $180.00        (provided)
TIF:           day            (defaulted — standard for equities)
Extended hrs:  false          (defaulted)
Client order:  a7b3c9d1-...   (auto-generated)

Step 6 — Confirm timing. Your agent confirms execution timing:

  • Immediate: submit now, during current market session
  • Scheduled: submit at a specific time (your agent notes this requires external scheduling)
  • Conditional: submit only when a condition is met (your agent notes this requires monitoring logic)

If the timing is not immediate, your agent explains what tooling you'd need and whether it can help set it up (see §4 Phase 8 for deployment guidance).

Step 7 — Confirm asset class specifics.

For US Equity:

  • Verify the symbol is tradable via the assets endpoint
  • Check fractional share eligibility if quantity includes decimals
  • Confirm extended-hours eligibility if extended_hours is true (only limit orders qualify)
  • Note T+1 settlement for sell proceeds

For US Options:

  • Validate the contract symbol follows OCC symbology: AAPL250718C00200000
    • Root symbol (AAPL), expiration (250718 = July 18, 2025), call/put (C/P), strike price × 1000 (00200000 = $200.00)
  • Confirm expiration date, strike price, and put/call
  • Confirm position intent: buy-to-open, buy-to-close, sell-to-open, sell-to-close
  • Note the contract multiplier: 1 contract = 100 shares of the underlying
  • Confirm the account's options approval level meets the strategy requirements
  • Warn about expiration risk if the expiration is within 5 trading days

For Crypto:

  • Confirm the pair format (e.g., BTC/USD, ETH/USD)
  • Note 24/7 market — no market-hours constraints
  • Check minimum order size for the pair
  • Confirm the account has crypto trading enabled

Step 8 — Confirm risk controls. Your agent asks about risk controls:

  • Max position size: maximum number of shares/contracts in a single position
  • Max portfolio allocation: maximum percentage of portfolio equity in one symbol
  • Stop-loss: price or percentage at which to exit a losing position
  • Take-profit: price or percentage at which to take gains

If you haven't set any risk controls, your agent recommends you consider them. It asks whether you want to set them now or proceed without them. If you proceed without them, your agent notes this in the session log.

Step 9 — Confirm margin usage. Your agent checks:

  • Margin classification via account.multiplier — the account object has no account_type field. 1 is a limited-margin, cash-style account; 2 is a Reg T margin account with 2x intraday and overnight buying power; 4 is a PDT account with 4x intraday and 2x overnight
  • Whether shorting is permitted (account.shorting_enabled), since the strategy may require it
  • Current buying power (account.buying_power) and, for options, account.options_buying_power
  • Current equity (account.equity)
  • If margin is involved, the maintenance margin requirement (account.maintenance_margin)

Phase 3: Paper Account Verification

Step 10 — Verify the environment is paper. Your agent checks the base URL, SDK configuration, or CLI profile to confirm the environment is paper, not live.

CheckPaperLive (BLOCKED)
REST base URLhttps://paper-api.alpaca.marketshttps://api.alpaca.markets
SDK configpaper=True or equivalentpaper=False or missing
CLI profilepaper profile selectedlive profile selected

If live credentials are detected: STOP immediately. Your agent displays a clear warning and refuses to proceed. It does not offer to "switch to paper" on your behalf — you must reconfigure your credentials.

Step 11 — Fetch account status. Your agent retrieves the account and verifies:

  • status is ACTIVE or PAPER_ONLY — a paper-only account is valid for this skill and must not be blocked
  • trading_blocked is false
  • account_blocked is false
  • trade_suspended_by_user is false
  • buying_power is sufficient for the planned order
  • multiplier for margin classification, which is also the only PDT signal available

The Trading API account object carries no pattern_day_trader or daytrade_count field. Your agent must not read them. A multiplier of 4 indicates a PDT account; if you need day-trade counts, derive them from GET /v2/account/activities rather than the account object.

Step 12 — Verify options readiness (if trading options).

  • Gate on options_trading_level, not options_approved_level. The effective level is the minimum of options_approved_level and the max_options_trading_level in account configuration, and Alpaca exposes it directly as options_trading_level. An account approved for level 3 but configured to level 1 can only trade level 1.
  • Each level includes the ones below it:
    • Level 0: options trading disabled
    • Level 1: sell covered calls, sell cash-secured puts
    • Level 2: buy calls, buy puts
    • Level 3: spreads and straddles
  • Alpaca does not offer naked short options at any level. If a strategy requires one, stop and say so rather than looking for a higher level.
  • If options_trading_level is 0 or below what the strategy needs, your agent stops and explains which level is required and how to request an upgrade

Step 13 — Verify crypto readiness (if trading crypto).

  • crypto_status is ACTIVE
  • If crypto is not enabled, your agent stops and explains how to enable it on the account

Step 14 — Show account summary. Your agent displays a summary of the account state:

┌─────────────────────────────────────────┐
│         PAPER ACCOUNT SUMMARY           │
├──────────────┬──────────────────────────┤
│ Account ID   │ ****-****-****-a1b2     │
│ Status       │ ACTIVE                   │
│ Equity       │ $100,000.00             │
│ Buying Power │ $100,000.00             │
│ Cash         │ $100,000.00             │
│ Positions    │ 3 open                   │
│ Multiplier   │ 2 (Reg T margin)         │
│ Options Lvl  │ 2 (effective)            │
│ Crypto       │ ACTIVE                   │
└──────────────┴──────────────────────────┘

Phase 4: Order Preview

Step 15 — Build the order payload. Your agent constructs the complete API request body with all confirmed parameters. It sets a unique client_order_id for idempotency.

Step 16 — Display the order preview. Your agent shows a complete order preview table:

┌─────────────────────────────────────────┐
│           ORDER PREVIEW                  │
├──────────────┬──────────────────────────┤
│ Environment  │ PAPER                    │
│ Symbol       │ AAPL                     │
│ Side         │ buy                      │
│ Quantity     │ 10 shares                │
│ Order Type   │ limit                    │
│ Limit Price  │ $185.50                  │
│ Time-in-Force│ day                      │
│ Extended Hrs │ no                       │
│ Client Order │ abc-123-def              │
│ Est. Notional│ ~$1,855.00              │
│ Buying Power │ $98,500.00 (sufficient) │
└──────────────┴──────────────────────────┘

For options, the preview also shows:

  • Contract: AAPL 07/18/2025 $200 Call
  • Contracts: 2
  • Multiplier: 100 shares/contract
  • Est. Premium: ~$3.50 × 2 × 100 = $700.00
  • Position intent: buy-to-open

For crypto, the preview also shows:

  • Pair: BTC/USD
  • Market: 24/7 (always open)
  • Notional: $500.00 (if notional order)

Step 17 — Confirmation-ON mode. If confirmation_mode is on, your agent asks:

Submit this order? (yes / no)

It waits for your explicit yes before proceeding. Any response other than a clear affirmative is treated as "no" and your agent asks what you'd like to change.

Step 18 — Confirmation-OFF mode. If confirmation_mode is off, your agent informs you:

Confirmation mode is OFF. This order will be submitted now. The preview is shown above for your review.

Your agent then proceeds to submission.

Phase 5: Order Submission

Step 19 — Submit the order. Your agent sends the order to the paper trading API via your chosen execution method (SDK, REST, CLI, or MCP tool). The endpoint is POST /v2/orders against the paper base URL.

Step 20 — Capture the response. On success, your agent captures:

  • id (order ID)
  • client_order_id
  • status — usually new, meaning Alpaca received the order and routed it. accepted means received but not yet routed and is common outside trading hours; pending_new and accepted_for_bidding are documented as rare
  • created_at
  • submitted_at
  • symbol, side, qty, type, time_in_force
  • All echoed fields from the API response

Step 21 — Handle submission failure. If the submission fails, your agent:

  1. Captures the full error response (HTTP status code, error message, error code)

  2. Shows you the error in plain language

  3. Suggests specific remediation. POST /v2/orders documents exactly two error responses, and they do not mean what their generic HTTP names suggest:

    • 403 Forbiddeninsufficient buying power or shares, not an auth problem. Show current buying power versus required, or current position versus the quantity being sold
    • 422 Unprocessable Entity → input parameters not recognized. Show which ones, and check them against the per-asset-class matrix in section 2
    • 429 Too Many Requests → rate limited; honor Retry-After and back off
    • 401 Unauthorized → credential problem. Stop; do not retry with the same credentials
    • Network timeout → verify whether the order was received before doing anything else

    A non-tradable or unknown symbol surfaces as 422 from the order endpoint, not 404. Your agent validates the symbol against GET /v2/assets/{symbol_or_asset_id} beforehand, where a genuinely unknown symbol does return 404. Crypto requires the old symbology without a slash (BTCUSD), and any slash that remains must be URL-encoded (/v2/assets/BTC%2FUSDT) or the request is malformed.

  4. Saves the failed attempt to the session log

  5. Does NOT automatically retry for non-idempotent submissions. If it's unclear whether the order was received (e.g., network timeout), your agent checks existing orders by client_order_id first.

Phase 6: Post-Submission Monitoring

Step 22 — Fetch order status. Immediately after a successful submission, your agent fetches the order by ID (GET /v2/orders/{id}) to confirm the current status.

Step 23 — Return post-submission summary. Your agent shows you:

Order submitted successfully.

Order ID:        b1e2f3a4-5678-9012-cdef-abcdef123456
Status:          accepted
Symbol:          AAPL
Side:            buy
Qty:             10
Type:            limit
Limit Price:     $185.50
TIF:             day
Submitted at:    2026-07-26T15:30:00Z
Environment:     PAPER

Next steps:
- Ask me to check the status of this order
- Ask me to cancel this order
- Ask me to show your current positions
- Ask me to show your portfolio summary

Step 24 — Order lifecycle updates.

Your agent tracks the order through its lifecycle and reports each transition:

Filled:

✅ Order FILLED

Shortened here. Read the whole file on GitHub.

Signals

GitHub stars
147
Forks
16
Last commit
Sep 2026
Advanced
Catalog kind
skill
Gateway key
alpaca-trading-paper-trading
Source
github.com/alpacahq/alpaca-skills