Preview, submit, inspect, and manage Alpaca paper-trading orders across US equities, options, and crypto. Use this skill when you want your AI agent to take a strategy signal — from a backtest, manual idea, or automated system — and execute it safely in your Alpaca paper-trading environment. This generic version works with any Alpaca SDK, REST API call, or agent tool that can reach the Trading API.
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
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.
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.
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
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.
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.
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.
Submit the order to the paper-trading environment only. Your agent verifies the environment is paper before every submission. It never submits to live.
Return complete post-submission details. After submission, your agent returns the order ID, status, submitted payload summary, and next inspection steps.
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.
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.
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
Input
Description
Default
signal_source
Where the trade idea comes from (backtest, manual, automation)
Must be provided
symbol
Ticker symbol (e.g., AAPL, BTC/USD, AAPL250718C00200000 for options)
Must be provided
side
buy or sell
Must be provided
qty_or_notional
Number of shares/contracts OR dollar amount (use qty for shares/contracts, notional for dollar amount)
Must be provided
order_type
market, limit, stop, stop_limit, trailing_stop — supported values vary by asset class, see below
market
time_in_force
day, gtc, ioc, fok, opg, cls — supported values vary by asset class, see below
day 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:
gtc, ioc — stop_limit is gtc-only, and ioc applies only to market and limit
simple
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
Input
Description
Default
limit_price
Required for limit and stop_limit orders
None
stop_price
Required for stop and stop_limit orders
None
trail_price or trail_percent
For trailing stop orders (one or the other, not both)
None
extended_hours
Allow extended-hours execution (equities only; limit type with day or gtc TIF)
false
client_order_id
User-supplied idempotency key (max 128 chars)
Auto-generated UUID
confirmation_mode
Whether your agent asks for explicit confirmation before each order
on
risk_controls
Max position size, max notional, max loss threshold
None (recommended to set)
asset_class
us_equity, us_option, crypto
Inferred from symbol format
order_class
simple, bracket, oco, oto, mleg — see the per-asset-class matrix above
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.
Check
Paper
Live (BLOCKED)
REST base URL
https://paper-api.alpaca.markets
https://api.alpaca.markets
SDK config
paper=True or equivalent
paper=False or missing
CLI profile
paper profile selected
live 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 nopattern_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.
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.
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:
Captures the full error response (HTTP status code, error message, error code)
Shows you the error in plain language
Suggests specific remediation. POST /v2/orders documents exactly two error responses, and they do not mean what their generic HTTP names suggest:
403 Forbidden → insufficient 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.
Saves the failed attempt to the session log
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
Order ID: b1e2f3a4-...
Symbol: AAPL
Side: buy
Filled Qty: 10 shares
Avg Fill Price: $185.32
Fill Time: 2026-07-26T15:30:05Z
Portfolio impact:
- AAPL position: 10 shares @ $185.32 (new position)
- Position value: $1,853.20
- Portfolio %: 1.85% of equity
- Buying Power: $98,146.80 (was $100,000.00)
Partially filled:
⏳ Order PARTIALLY FILLED
Order ID: b1e2f3a4-...
Filled: 6 of 10 shares
Avg Fill Price: $185.35
Remaining: 4 shares (still working)
Rejected:
❌ Order REJECTED
Order ID: b1e2f3a4-...
Reason: insufficient buying power
Details: Required ~$1,855.00, available $500.00
Remediation:
- Reduce order quantity
- Close existing positions to free buying power
- If this is unexpected, check your account for pending orders
consuming buying power
Canceled:
🚫 Order CANCELED
Order ID: b1e2f3a4-...
Canceled by: system
Reason: day order expired at market close (16:00 ET)
If you still want this position, consider:
- Resubmitting as a GTC order
- Waiting for the next market open
Replaced:
🔄 Order REPLACED
Old Order ID: b1e2f3a4-...
New Order ID: c2d3e4f5-...
Changed:
Limit Price: $185.50 → $186.00
Quantity: 10 → 15
Phase 7: Portfolio Impact Assessment
Step 25 — Fetch updated positions and account.
After a fill, your agent retrieves the current positions (GET /v2/positions) and account (GET /v2/account) to show the impact.
Position concentration: abs(position.market_value) / equity × 100 — the Position field is market_value. (position_market_value exists only on the account payload as an all-positions aggregate.)
Day trade count: relevant for equity accounts with less than $25k equity
Open orders: orders still working that may consume additional buying power
Phase 8: Deployment Guidance
This phase is optional. Your agent provides this guidance only when you ask about deploying or automating a strategy.
Step 27 — Provide deployment options.
If you ask how to deploy or automate the strategy, your agent outlines these paths:
Local scheduler:
Use cron (Linux/macOS), launchd (macOS), or Windows Task Scheduler
Write a Python script using alpaca-py that encapsulates the strategy logic
Schedule it to run at your desired frequency
Log output to a file for review
Cloud hosting:
AWS Lambda + EventBridge for serverless scheduled execution
Google Cloud Functions + Cloud Scheduler
Railway, Render, or Fly.io for persistent process hosting
Any platform that can run a Python/Node.js process on a schedule
Webhook-based:
TradingView alerts → webhook endpoint → your server → Alpaca API
Custom alert system → webhook → order execution logic
Every deployed path asserts paper at startup. Scheduling, hosting, and webhook triggers differ, but they share one requirement: the artifact that runs unattended proves it is pointed at paper before it can place an order, and exits if it cannot. There is no operator watching to catch a wrong endpoint, and a live account returns the same response shape as a paper one, so nothing downstream will reveal the mistake.
Two rules make that assertion trustworthy:
Pin the paper endpoint as a literal in code, not as configuration. An endpoint read from an environment variable, a config file, or a CI secret can be changed by someone who never reads this skill. In alpaca-py that means constructing the client as TradingClient(key, secret, paper=True) with paper=True written literally, never paper=os.getenv(...).
Abort on any signal that live was intended. If a live endpoint, a live-trading flag, or a live profile is present in the environment, exit non-zero before the first order rather than resolving the conflict silently.
Naming a credential or variable "paper" is not evidence. Only the resolved endpoint is.
Important notes your agent always includes:
Validate any new automation against paper for a meaningful period before considering live at all
Your agent does not recommend any specific hosting provider or guarantee uptime
Automating live trading is a separate, significant decision with additional regulatory and risk considerations
Monitor automated systems regularly — do not "set and forget"
Include error handling, logging, and alerting in any automated system
Consider what happens when your automation encounters an unexpected market condition
5 - Execution rules
Environment safety
This skill operates in the paper-trading environment ONLY.
If your agent detects live API credentials — base URL is https://api.alpaca.markets without the paper- prefix, or the SDK/CLI profile is set to live — it must STOP and warn you immediately.
Your agent must verify the environment before every order submission, not just once per session. Environment state can change if credentials are reconfigured mid-session.
Your agent never offers to "switch to live" or facilitate the transition from paper to live trading.
Confirmation behavior
At the start of each session, your agent asks whether you want explicit confirmation before each order (default: ON).
In confirmation-ON mode, your agent shows the order preview and waits for your explicit "yes" before submitting.
In confirmation-OFF mode, your agent still shows the order preview but submits after a brief display pause. It announces the submission clearly.
You can toggle confirmation mode at any time during the session by telling your agent.
Regardless of mode, your agent always shows the order preview. It never submits silently.
Idempotency
Your agent sets a unique client_order_id on every order to prevent duplicate submissions.
If submission fails with a network error and it's unclear whether the order was received, your agent checks existing orders for the client_order_id before retrying.
client_order_id values are logged in the session's orders.json for audit.
Rate limiting
Drive throttling from the response headers rather than a hard-coded ceiling. Every response carries X-RateLimit-Limit, X-RateLimit-Remaining, and X-RateLimit-Reset; your agent slows down as Remaining approaches zero instead of waiting to be throttled. A figure of 200 requests per minute is widely cited for the Trading API but is not stated in Alpaca's current documentation, so do not hard-code it.
If rate-limited (HTTP 429), stop and retry with exponential backoff plus jitter (1s, 2s, 4s, 8s, capped), and do not retry before the time given by X-RateLimit-Reset.
Do not spam order status checks. Poll at reasonable intervals:
Active market order: every 2 seconds for the first 10 seconds, then every 5 seconds
Active limit order: every 5 seconds for the first minute, then every 30 seconds
No order should be polled more than 60 times total
Asset class rules
US Equity:
Standard market hours: 9:30 AM–4:00 PM ET
Extended hours require extended_hours: true on a limit order with day or gtc TIF, and cover three sessions:
Overnight: 8:00 PM–4:00 AM ET, Sunday to Friday
Pre-market: 4:00 AM–9:30 AM ET, Monday to Friday
After-hours: 4:00 PM–8:00 PM ET, Monday to Friday
Not every asset is eligible for the overnight session — confirm on the asset record rather than assuming
Fractional shares supported for eligible symbols (check fractionable attribute)
T+1 settlement — sell proceeds are available the next business day
Short selling requires a margin account and locatable shares
US Options:
Standard market hours: 9:30 AM–4:00 PM ET
One contract = 100 shares of the underlying
Approval level required (1, 2, or 3) — verify before submitting
Exercise and assignment are automatic at expiration for ITM options
Options have expiration dates — they lose value over time (theta decay)
American-style options can be exercised any time before expiration
Weekly, monthly, and quarterly expirations available for major symbols
Crypto:
24/7 market — no market-hours constraints
Minimum order sizes apply per pair (check the asset endpoint)
Not all pairs are available — verify before submitting
No extended-hours concept — always open
Fractional quantities supported for most pairs
No short selling of crypto
Error handling
Auth failure (401): Stop, show the error, suggest re-authenticating. Never retry with the same credentials.
Insufficient buying power or shares (403): On POST /v2/orders, 403 means the tradable balance or share count is insufficient — it is not an auth failure. Show current buying power, required notional, and the shortfall. Suggest reducing quantity or closing positions.
Non-tradable symbol (422): The order endpoint reports unrecognized input as 422. Show the asset status and suggest checking the symbol. Offer to search for the correct symbol. GET /v2/assets/{symbol_or_asset_id} is the place a 404 legitimately appears.
Market closed (422): Show current market status and next open time using the clock endpoint (GET /v2/clock).
Rate limit (429): Wait and retry with exponential backoff. Inform you of the delay.
Network timeout: Check if the order was received (by client_order_id) before deciding whether to retry.
Unknown error: Show the full error response. Do not silently swallow errors. Log the error to the session file.
6 - Output contract
In-chat response after submission
Order submitted successfully.
Order ID: {order_id}
Status: {status}
Symbol: {symbol}
Side: {side}
Qty: {qty}
Type: {order_type}
TIF: {time_in_force}
Submitted at: {submitted_at}
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
Run folder artifacts
When the skill is used as part of a session with multiple orders, your agent writes session artifacts to a run folder:
runs/<YYYYMMDD-HHMMSS>-paper-trading/
notes.md # strategy context, confirmation choices, assumptions
orders.json # all orders submitted in this session
order_log.csv # timeline: order_id, timestamp, event, status, details
positions_snapshot.json # positions after last fill
portfolio_summary.md # human-readable portfolio state
review.md # session review and open questions
Run these tests mentally or against a paper account whenever modifying this skill.
8 - Disclosures, safety, and data handling
Required disclosure
Important disclosure: This material is for informational, educational, and research purposes only. It is not investment advice, a recommendation, an offer, or a solicitation to buy or sell securities, options, cryptocurrencies, or any other financial product. All investing and trading involve risk, including possible loss of principal. Paper trading is simulated and may differ from live trading in fills, market impact, liquidity, fees, latency, and other factors. Review Alpaca's disclosures at https://alpaca.markets/disclosures.
Your agent includes this disclosure in every session summary, report, and portfolio review.
Paper-trading specific
Paper trading results are simulated. They do not represent actual trading performance.
Paper fills may differ from live fills in price, timing, partial fills, and rejection behavior.
Paper trading does not charge real commissions or fees. Live trading may incur costs.
Moving from paper to live trading is a separate, significant decision that requires additional review of risk tolerance, capital adequacy, and regulatory requirements.
This skill will never facilitate that transition directly.
Options-specific
When options are involved, your agent includes:
Options involve significant risk and are not suitable for all investors.
Options can expire worthless. You can lose the entire premium paid for long options.
Selling options carries risk that can exceed the premium received, and assignment can force a position at an unfavorable price.
Complex options strategies (spreads, straddles, strangles) carry additional risks and may have multiple legs with different outcomes.
Options are subject to exercise and assignment risk, especially near expiration.
Understand the Greeks (delta, gamma, theta, vega) and how they affect your position before trading.
Crypto-specific
When crypto is involved, your agent includes:
Cryptocurrency trading involves substantial risk due to high volatility.
Crypto assets are not securities and may have different regulatory protections than traditional securities.
Crypto markets operate 24/7 and can experience significant price swings at any time.
Crypto assets are not FDIC insured or SIPC protected.
Regulatory environment for crypto is evolving and may change.
Credentials and data handling
Your agent reads credentials from environment variables (APCA_API_KEY_ID, APCA_API_SECRET_KEY), SDK configuration files, or CLI profile settings.
Never paste API keys or secrets into chat. Your agent will refuse to accept them if offered.
Your agent redacts account IDs, order IDs, and personally identifiable information in any summaries shared outside the session.
Raw API responses are stored locally only (in the run folder) and classified as account-level confidential.
Your agent does not send trading data, account data, or credentials to any third party.
Session artifacts (run folder files) remain on your local filesystem. Review and delete them as appropriate.
9 - Anti-patterns
NEVER submit orders to a live trading environment. This skill is paper-only.
NEVER ask for API keys or secrets in chat. Credentials come from environment variables or
…(truncated)
1---2name: alpaca-trading-paper-trading3description: Preview, submit, inspect, and manage Alpaca paper-trading orders across US equities, options, and crypto. Use this skill when you want your AI agent to take a strategy signal — from a backtest, manual idea, or automated system — and execute it safely in your Alpaca paper-trading environment. This generic version works with any Alpaca SDK, REST API call, or agent tool that can reach the Trading API.4---56# Alpaca Paper Trading78Use this skill when you want your AI agent to preview, submit, inspect, and manage paper-trading orders using Alpaca's Trading API.910This 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.1112This 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.1314---1516## 0 - How your AI agent should use this skill17181. **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.19202. **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.21223. **Gather and confirm ALL detailed configurations before execution.** Your agent collects every order parameter explicitly:23 - Timing of execution (immediate, scheduled, conditional)24 - Asset class (US equity, US options, crypto)25 - Symbol(s)26 - Side (buy / sell)27 - Quantity or notional amount28 - Order type (market, limit, stop, stop_limit, trailing_stop)29 - Time-in-force (day, gtc, ioc, fok, opg, cls)30 - Limit price and/or stop price if applicable31 - Extended-hours flag32 - Risk controls (max position size, max notional, stop-loss, take-profit)33 - Margin usage34354. **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.36375. **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.38396. **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.40417. **Submit the order to the paper-trading environment only.** Your agent verifies the environment is paper before every submission. It never submits to live.42438. **Return complete post-submission details.** After submission, your agent returns the order ID, status, submitted payload summary, and next inspection steps.44459. **Monitor and update on order lifecycle.**46 - **Filled** → how many shares/contracts, at what price, and how the fill changes portfolio risk.47 - **Partially filled** → current fill vs remaining quantity, average fill price so far.48 - **Rejected** → the rejection reason and specific remediation suggestions.49 - **Canceled** → who canceled (you, system, broker) and why.505110. **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.5253---5455## 1 - Prerequisites5657- **Alpaca paper-trading account** — free at [alpaca.markets](https://alpaca.markets)58- **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 chat59- **Paper base URL**: `https://paper-api.alpaca.markets` (for REST) or appropriate SDK configuration pointing to the paper environment60- **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)61- **For crypto**: crypto trading must be enabled on the paper account62- **SDK / language runtime** (choose one):63 - Python 3.10+ with `alpaca-py` (recommended)64 - JavaScript/TypeScript with `@alpacahq/alpaca-trade-api` (v4+, first-party and actively maintained)65 - Go with `github.com/alpacahq/alpaca-trade-api-go/v3` — the `/v3` suffix is required; without it you pull the v1 path66 - C# with `Alpaca.Markets` (first-party). Community SDKs exist for Java and others.67 - Direct REST API calls via `curl`, `httpx`, `requests`, or any HTTP client68- **Network access** to Alpaca APIs (`paper-api.alpaca.markets`)6970---7172## 2 - Gather inputs7374### Required inputs7576| Input | Description | Default |77|---|---|---|78| `signal_source` | Where the trade idea comes from (backtest, manual, automation) | Must be provided |79| `symbol` | Ticker symbol (e.g., `AAPL`, `BTC/USD`, `AAPL250718C00200000` for options) | Must be provided |80| `side` | `buy` or `sell` | Must be provided |81| `qty_or_notional` | Number of shares/contracts OR dollar amount (use `qty` for shares/contracts, `notional` for dollar amount) | Must be provided |82| `order_type` | `market`, `limit`, `stop`, `stop_limit`, `trailing_stop` — **supported values vary by asset class, see below** | `market` |83| `time_in_force` | `day`, `gtc`, `ioc`, `fok`, `opg`, `cls` — **supported values vary by asset class, see below** | `day` for equities; `gtc` for crypto |8485### Per-asset-class constraints8687The API rejects combinations outside this matrix, so your agent validates before submitting rather than after:8889| Asset class | Order types | Time-in-force | Order classes |90|---|---|---|---|91| `us_equity` | `market`, `limit`, `stop`, `stop_limit`, `trailing_stop` | `day`, `gtc`, `opg`, `cls`, `ioc`, `fok` | `simple`, `bracket`, `oco`, `oto` |92| `us_option` | `market`, `limit`, `stop`, `stop_limit` (`stop` types single-leg only) | `day`, `gtc` | `simple`, `mleg` |93| `crypto` | `market`, `limit`, `stop_limit` | `gtc`, `ioc` — `stop_limit` is `gtc`-only, and `ioc` applies only to `market` and `limit` | `simple` |9495Treat 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.9697Constraints that cut across order type:9899- **Extended hours** requires `limit` type with `day` or `gtc` TIF. Everything else is rejected.100- **Trailing stop** accepts only `day` and `gtc`.101- **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.102- **Bracket, OCO, and OTO** are equities-only, require `day` or `gtc`, and do not support extended hours.103- **`mleg`** carries up to 4 legs and is how multi-leg options strategies are expressed.104105### Optional inputs106107| Input | Description | Default |108|---|---|---|109| `limit_price` | Required for `limit` and `stop_limit` orders | None |110| `stop_price` | Required for `stop` and `stop_limit` orders | None |111| `trail_price` or `trail_percent` | For trailing stop orders (one or the other, not both) | None |112| `extended_hours` | Allow extended-hours execution (equities only; `limit` type with `day` or `gtc` TIF) | `false` |113| `client_order_id` | User-supplied idempotency key (max 128 chars) | Auto-generated UUID |114| `confirmation_mode` | Whether your agent asks for explicit confirmation before each order | `on` |115| `risk_controls` | Max position size, max notional, max loss threshold | None (recommended to set) |116| `asset_class` | `us_equity`, `us_option`, `crypto` | Inferred from symbol format |117| `order_class` | `simple`, `bracket`, `oco`, `oto`, `mleg` — see the per-asset-class matrix above | `simple` |118| `position_intent` | `buy_to_open`, `buy_to_close`, `sell_to_open`, `sell_to_close` (options only) | Inferred from context |119120### Strategy confirmation checklist121122Before proceeding past the configuration phase, your agent must confirm each of these with you:123124- [ ] **Strategy logic interpretation is correct** — the agent's restatement of your strategy matches your intent125- [ ] **Timing** — immediate execution, or scheduled/conditional (e.g., "only if price drops below $180")126- [ ] **Asset class and symbol are correct** — the right ticker, the right contract (for options), the right pair (for crypto)127- [ ] **Order parameters match the strategy intent** — type, side, quantity, prices, TIF all align with what you want128- [ ] **Paper account is configured for this asset class** — options approval, crypto enabled, margin type129- [ ] **Risk controls are set** (or explicitly waived) — you've acknowledged position sizing, stop-loss, and concentration limits130131---132133## 3 - Source-of-truth references134135| Source | URL | Used for |136|---|---|---|137| Trading API overview | https://docs.alpaca.markets/us/docs/trading-api | API capabilities and structure |138| Working with orders | https://docs.alpaca.markets/us/docs/working-with-orders | Order submission, replacement, cancellation |139| Orders on Alpaca | https://docs.alpaca.markets/us/docs/orders-at-alpaca | Order types, TIF values, status lifecycle |140| Paper trading | https://docs.alpaca.markets/us/docs/paper-trading | Paper environment behavior and limitations |141| Working with positions | https://docs.alpaca.markets/us/docs/working-with-positions | Position retrieval and management |142| Working with account | https://docs.alpaca.markets/us/docs/working-with-account | Account state, buying power, day trade count |143| Working with assets | https://docs.alpaca.markets/us/docs/working-with-assets | Tradability checks, asset attributes |144| Options trading | https://docs.alpaca.markets/us/docs/options-trading | Options order specifics, approval levels |145| Crypto trading | https://docs.alpaca.markets/us/docs/crypto-trading | Crypto order specifics, supported pairs |146| Alpaca disclosures | https://alpaca.markets/disclosures | Required disclosure language |147148---149150## 4 - Workflow151152### Phase 1: Strategy Confirmation153154**Step 1 — Identify the signal source.**155Your agent determines where the trade idea comes from:156- **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.157- **Manual idea**: you describe the trade in natural language. Your agent extracts the parameters and asks clarifying questions.158- **Automated system**: a webhook, alert, or scheduled trigger. Your agent reads the payload and maps it to order parameters.159160**Step 2 — Reiterate the strategy logic.**161Your agent restates the complete strategy interpretation in plain language:162- What triggers a trade (entry condition)163- What exits a trade (exit condition, stop-loss, take-profit)164- Indicator parameters (e.g., "20-day SMA crossover with 50-day SMA")165- Position sizing rules (e.g., "risk 1% of portfolio per trade")166- Any assumptions your agent is making (e.g., "assuming you want to enter at market price")167168**Step 3 — Confirm the interpretation.**169Your 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.170171### Phase 2: Configuration Agreement172173**Step 4 — Gather all order parameters.**174Using the inputs table from §2, your agent collects every required and optional parameter. It asks for anything not already specified.175176**Step 5 — Show parameter attribution.**177For each parameter, your agent shows:178- The value being used179- Whether it was **provided** by you, **inferred** from context (e.g., asset class from symbol format), or **defaulted** to a standard value180181Example:182```183Symbol: AAPL (provided)184Side: buy (provided)185Quantity: 50 shares (provided)186Order type: limit (provided)187Limit price: $180.00 (provided)188TIF: day (defaulted — standard for equities)189Extended hrs: false (defaulted)190Client order: a7b3c9d1-... (auto-generated)191```192193**Step 6 — Confirm timing.**194Your agent confirms execution timing:195- **Immediate**: submit now, during current market session196- **Scheduled**: submit at a specific time (your agent notes this requires external scheduling)197- **Conditional**: submit only when a condition is met (your agent notes this requires monitoring logic)198199If 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).200201**Step 7 — Confirm asset class specifics.**202203For **US Equity**:204- Verify the symbol is tradable via the assets endpoint205- Check fractional share eligibility if quantity includes decimals206- Confirm extended-hours eligibility if `extended_hours` is `true` (only `limit` orders qualify)207- Note T+1 settlement for sell proceeds208209For **US Options**:210- Validate the contract symbol follows OCC symbology: `AAPL250718C00200000`211 - Root symbol (AAPL), expiration (250718 = July 18, 2025), call/put (C/P), strike price × 1000 (00200000 = $200.00)212- Confirm expiration date, strike price, and put/call213- Confirm position intent: buy-to-open, buy-to-close, sell-to-open, sell-to-close214- Note the contract multiplier: 1 contract = 100 shares of the underlying215- Confirm the account's options approval level meets the strategy requirements216- Warn about expiration risk if the expiration is within 5 trading days217218For **Crypto**:219- Confirm the pair format (e.g., `BTC/USD`, `ETH/USD`)220- Note 24/7 market — no market-hours constraints221- Check minimum order size for the pair222- Confirm the account has crypto trading enabled223224**Step 8 — Confirm risk controls.**225Your agent asks about risk controls:226- **Max position size**: maximum number of shares/contracts in a single position227- **Max portfolio allocation**: maximum percentage of portfolio equity in one symbol228- **Stop-loss**: price or percentage at which to exit a losing position229- **Take-profit**: price or percentage at which to take gains230231If 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.232233**Step 9 — Confirm margin usage.**234Your agent checks:235- 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 overnight236- Whether shorting is permitted (`account.shorting_enabled`), since the strategy may require it237- Current buying power (`account.buying_power`) and, for options, `account.options_buying_power`238- Current equity (`account.equity`)239- If margin is involved, the maintenance margin requirement (`account.maintenance_margin`)240241### Phase 3: Paper Account Verification242243**Step 10 — Verify the environment is paper.**244Your agent checks the base URL, SDK configuration, or CLI profile to confirm the environment is **paper**, not live.245246| Check | Paper | Live (BLOCKED) |247|---|---|---|248| REST base URL | `https://paper-api.alpaca.markets` | `https://api.alpaca.markets` |249| SDK config | `paper=True` or equivalent | `paper=False` or missing |250| CLI profile | paper profile selected | live profile selected |251252If 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.253254**Step 11 — Fetch account status.**255Your agent retrieves the account and verifies:256- `status` is `ACTIVE` or `PAPER_ONLY` — a paper-only account is valid for this skill and must not be blocked257- `trading_blocked` is `false`258- `account_blocked` is `false`259- `trade_suspended_by_user` is `false`260- `buying_power` is sufficient for the planned order261- `multiplier` for margin classification, which is also the only PDT signal available262263The 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.264265**Step 12 — Verify options readiness** (if trading options).266- 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.267- Each level includes the ones below it:268 - Level 0: options trading disabled269 - Level 1: sell covered calls, sell cash-secured puts270 - Level 2: buy calls, buy puts271 - Level 3: spreads and straddles272- 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.273- 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 upgrade274275**Step 13 — Verify crypto readiness** (if trading crypto).276- `crypto_status` is `ACTIVE`277- If crypto is not enabled, your agent stops and explains how to enable it on the account278279**Step 14 — Show account summary.**280Your agent displays a summary of the account state:281282```283┌─────────────────────────────────────────┐284│ PAPER ACCOUNT SUMMARY │285├──────────────┬──────────────────────────┤286│ Account ID │ ****-****-****-a1b2 │287│ Status │ ACTIVE │288│ Equity │ $100,000.00 │289│ Buying Power │ $100,000.00 │290│ Cash │ $100,000.00 │291│ Positions │ 3 open │292│ Multiplier │ 2 (Reg T margin) │293│ Options Lvl │ 2 (effective) │294│ Crypto │ ACTIVE │295└──────────────┴──────────────────────────┘296```297298### Phase 4: Order Preview299300**Step 15 — Build the order payload.**301Your agent constructs the complete API request body with all confirmed parameters. It sets a unique `client_order_id` for idempotency.302303**Step 16 — Display the order preview.**304Your agent shows a complete order preview table:305306```307┌─────────────────────────────────────────┐308│ ORDER PREVIEW │309├──────────────┬──────────────────────────┤310│ Environment │ PAPER │311│ Symbol │ AAPL │312│ Side │ buy │313│ Quantity │ 10 shares │314│ Order Type │ limit │315│ Limit Price │ $185.50 │316│ Time-in-Force│ day │317│ Extended Hrs │ no │318│ Client Order │ abc-123-def │319│ Est. Notional│ ~$1,855.00 │320│ Buying Power │ $98,500.00 (sufficient) │321└──────────────┴──────────────────────────┘322```323324For **options**, the preview also shows:325- Contract: `AAPL 07/18/2025 $200 Call`326- Contracts: 2327- Multiplier: 100 shares/contract328- Est. Premium: ~$3.50 × 2 × 100 = $700.00329- Position intent: buy-to-open330331For **crypto**, the preview also shows:332- Pair: BTC/USD333- Market: 24/7 (always open)334- Notional: $500.00 (if notional order)335336**Step 17 — Confirmation-ON mode.**337If `confirmation_mode` is `on`, your agent asks:338339> Submit this order? (yes / no)340341It 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.342343**Step 18 — Confirmation-OFF mode.**344If `confirmation_mode` is `off`, your agent informs you:345346> Confirmation mode is OFF. This order will be submitted now. The preview is shown above for your review.347348Your agent then proceeds to submission.349350### Phase 5: Order Submission351352**Step 19 — Submit the order.**353Your 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.354355**Step 20 — Capture the response.**356On success, your agent captures:357- `id` (order ID)358- `client_order_id`359- `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 rare360- `created_at`361- `submitted_at`362- `symbol`, `side`, `qty`, `type`, `time_in_force`363- All echoed fields from the API response364365**Step 21 — Handle submission failure.**366If the submission fails, your agent:3671. Captures the full error response (HTTP status code, error message, error code)3682. Shows you the error in plain language3693. Suggests specific remediation. `POST /v2/orders` documents exactly two error responses, and they do not mean what their generic HTTP names suggest:370 - `403 Forbidden` → **insufficient buying power or shares**, not an auth problem. Show current buying power versus required, or current position versus the quantity being sold371 - `422 Unprocessable Entity` → input parameters not recognized. Show which ones, and check them against the per-asset-class matrix in section 2372 - `429 Too Many Requests` → rate limited; honor `Retry-After` and back off373 - `401 Unauthorized` → credential problem. Stop; do not retry with the same credentials374 - Network timeout → verify whether the order was received before doing anything else375376 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.3774. Saves the failed attempt to the session log3785. 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.379380### Phase 6: Post-Submission Monitoring381382**Step 22 — Fetch order status.**383Immediately after a successful submission, your agent fetches the order by ID (`GET /v2/orders/{id}`) to confirm the current status.384385**Step 23 — Return post-submission summary.**386Your agent shows you:387388```389Order submitted successfully.390391Order ID: b1e2f3a4-5678-9012-cdef-abcdef123456392Status: accepted393Symbol: AAPL394Side: buy395Qty: 10396Type: limit397Limit Price: $185.50398TIF: day399Submitted at: 2026-07-26T15:30:00Z400Environment: PAPER401402Next steps:403- Ask me to check the status of this order404- Ask me to cancel this order405- Ask me to show your current positions406- Ask me to show your portfolio summary407```408409**Step 24 — Order lifecycle updates.**410411Your agent tracks the order through its lifecycle and reports each transition:412413**Filled:**414```415✅ Order FILLED416417Order ID: b1e2f3a4-...418Symbol: AAPL419Side: buy420Filled Qty: 10 shares421Avg Fill Price: $185.32422Fill Time: 2026-07-26T15:30:05Z423424Portfolio impact:425- AAPL position: 10 shares @ $185.32 (new position)426- Position value: $1,853.20427- Portfolio %: 1.85% of equity428- Buying Power: $98,146.80 (was $100,000.00)429```430431**Partially filled:**432```433⏳ Order PARTIALLY FILLED434435Order ID: b1e2f3a4-...436Filled: 6 of 10 shares437Avg Fill Price: $185.35438Remaining: 4 shares (still working)439```440441**Rejected:**442```443❌ Order REJECTED444445Order ID: b1e2f3a4-...446Reason: insufficient buying power447Details: Required ~$1,855.00, available $500.00448449Remediation:450- Reduce order quantity451- Close existing positions to free buying power452- If this is unexpected, check your account for pending orders453 consuming buying power454```455456**Canceled:**457```458🚫 Order CANCELED459460Order ID: b1e2f3a4-...461Canceled by: system462Reason: day order expired at market close (16:00 ET)463464If you still want this position, consider:465- Resubmitting as a GTC order466- Waiting for the next market open467```468469**Replaced:**470```471🔄 Order REPLACED472473Old Order ID: b1e2f3a4-...474New Order ID: c2d3e4f5-...475Changed:476 Limit Price: $185.50 → $186.00477 Quantity: 10 → 15478```479480### Phase 7: Portfolio Impact Assessment481482**Step 25 — Fetch updated positions and account.**483After a fill, your agent retrieves the current positions (`GET /v2/positions`) and account (`GET /v2/account`) to show the impact.484485**Step 26 — Show portfolio risk summary.**486```487┌─────────────────────────────────────────┐488│ PORTFOLIO RISK SUMMARY │489├──────────────┬──────────────────────────┤490│ Total Equity │ $100,050.00 │491│ Buying Power │ $98,146.80 │492│ Open Pos. │ 4 positions │493│ Open Orders │ 1 working │494│ │495│ Position Concentration: │496│ AAPL │ 1.85% ($1,853.20) │497│ MSFT │ 3.20% ($3,201.00) │498│ TSLA │ 2.10% ($2,100.50) │499│ BTC/USD │ 5.00% ($5,002.30) │500│ │501│ Unrealized P&L (total): +$50.00 │502└──────────────┴──────────────────────────┘503```504505- **Position concentration**: `abs(position.market_value) / equity × 100` — the Position field is `market_value`. (`position_market_value` exists only on the account payload as an all-positions aggregate.)506- **Unrealized P&L**: `(current_price - avg_entry_price) × qty`507- **Day trade count**: relevant for equity accounts with less than $25k equity508- **Open orders**: orders still working that may consume additional buying power509510### Phase 8: Deployment Guidance511512> This phase is optional. Your agent provides this guidance only when you ask about deploying or automating a strategy.513514**Step 27 — Provide deployment options.**515516If you ask how to deploy or automate the strategy, your agent outlines these paths:517518**Local scheduler:**519- Use `cron` (Linux/macOS), `launchd` (macOS), or Windows Task Scheduler520- Write a Python script using `alpaca-py` that encapsulates the strategy logic521- Schedule it to run at your desired frequency522- Log output to a file for review523524**Cloud hosting:**525- AWS Lambda + EventBridge for serverless scheduled execution526- Google Cloud Functions + Cloud Scheduler527- Railway, Render, or Fly.io for persistent process hosting528- Any platform that can run a Python/Node.js process on a schedule529530**Webhook-based:**531- TradingView alerts → webhook endpoint → your server → Alpaca API532- Custom alert system → webhook → order execution logic533534**Every deployed path asserts paper at startup.** Scheduling, hosting, and webhook triggers differ, but they share one requirement: the artifact that runs unattended proves it is pointed at paper before it can place an order, and exits if it cannot. There is no operator watching to catch a wrong endpoint, and a live account returns the same response shape as a paper one, so nothing downstream will reveal the mistake.535536Two rules make that assertion trustworthy:537538- **Pin the paper endpoint as a literal in code, not as configuration.** An endpoint read from an environment variable, a config file, or a CI secret can be changed by someone who never reads this skill. In `alpaca-py` that means constructing the client as `TradingClient(key, secret, paper=True)` with `paper=True` written literally, never `paper=os.getenv(...)`.539- **Abort on any signal that live was intended.** If a live endpoint, a live-trading flag, or a live profile is present in the environment, exit non-zero before the first order rather than resolving the conflict silently.540541Naming a credential or variable "paper" is not evidence. Only the resolved endpoint is.542543**Important notes your agent always includes:**544- Validate any new automation against paper for a meaningful period before considering live at all545- Your agent does not recommend any specific hosting provider or guarantee uptime546- Automating live trading is a separate, significant decision with additional regulatory and risk considerations547- Monitor automated systems regularly — do not "set and forget"548- Include error handling, logging, and alerting in any automated system549- Consider what happens when your automation encounters an unexpected market condition550551---552553## 5 - Execution rules554555### Environment safety556557- This skill operates in the **paper-trading environment ONLY**.558- If your agent detects live API credentials — base URL is `https://api.alpaca.markets` without the `paper-` prefix, or the SDK/CLI profile is set to live — it must **STOP** and warn you immediately.559- Your agent must verify the environment before **every** order submission, not just once per session. Environment state can change if credentials are reconfigured mid-session.560- Your agent never offers to "switch to live" or facilitate the transition from paper to live trading.561562### Confirmation behavior563564- At the start of each session, your agent asks whether you want explicit confirmation before each order (default: **ON**).565- In **confirmation-ON** mode, your agent shows the order preview and waits for your explicit "yes" before submitting.566- In **confirmation-OFF** mode, your agent still shows the order preview but submits after a brief display pause. It announces the submission clearly.567- You can toggle confirmation mode at any time during the session by telling your agent.568- Regardless of mode, your agent **always** shows the order preview. It never submits silently.569570### Idempotency571572- Your agent sets a unique `client_order_id` on every order to prevent duplicate submissions.573- If submission fails with a network error and it's unclear whether the order was received, your agent checks existing orders for the `client_order_id` before retrying.574- `client_order_id` values are logged in the session's `orders.json` for audit.575576### Rate limiting577578- Drive throttling from the response headers rather than a hard-coded ceiling. Every response carries `X-RateLimit-Limit`, `X-RateLimit-Remaining`, and `X-RateLimit-Reset`; your agent slows down as `Remaining` approaches zero instead of waiting to be throttled. A figure of 200 requests per minute is widely cited for the Trading API but is not stated in Alpaca's current documentation, so do not hard-code it.579- If rate-limited (HTTP 429), stop and retry with exponential backoff plus jitter (1s, 2s, 4s, 8s, capped), and do not retry before the time given by `X-RateLimit-Reset`.580- Do not spam order status checks. Poll at reasonable intervals:581 - Active market order: every 2 seconds for the first 10 seconds, then every 5 seconds582 - Active limit order: every 5 seconds for the first minute, then every 30 seconds583 - No order should be polled more than 60 times total584585### Asset class rules586587**US Equity:**588- Standard market hours: 9:30 AM–4:00 PM ET589- Extended hours require `extended_hours: true` on a `limit` order with `day` or `gtc` TIF, and cover three sessions:590 - Overnight: 8:00 PM–4:00 AM ET, Sunday to Friday591 - Pre-market: 4:00 AM–9:30 AM ET, Monday to Friday592 - After-hours: 4:00 PM–8:00 PM ET, Monday to Friday593- Not every asset is eligible for the overnight session — confirm on the asset record rather than assuming594- Fractional shares supported for eligible symbols (check `fractionable` attribute)595- T+1 settlement — sell proceeds are available the next business day596- Short selling requires a margin account and locatable shares597598**US Options:**599- Standard market hours: 9:30 AM–4:00 PM ET600- One contract = 100 shares of the underlying601- Approval level required (1, 2, or 3) — verify before submitting602- Exercise and assignment are automatic at expiration for ITM options603- Options have expiration dates — they lose value over time (theta decay)604- American-style options can be exercised any time before expiration605- Weekly, monthly, and quarterly expirations available for major symbols606607**Crypto:**608- 24/7 market — no market-hours constraints609- Minimum order sizes apply per pair (check the asset endpoint)610- Not all pairs are available — verify before submitting611- No extended-hours concept — always open612- Fractional quantities supported for most pairs613- No short selling of crypto614615### Error handling616617- **Auth failure (401):** Stop, show the error, suggest re-authenticating. Never retry with the same credentials.618- **Insufficient buying power or shares (403):** On `POST /v2/orders`, `403` means the tradable balance or share count is insufficient — it is not an auth failure. Show current buying power, required notional, and the shortfall. Suggest reducing quantity or closing positions.619- **Non-tradable symbol (422):** The order endpoint reports unrecognized input as `422`. Show the asset status and suggest checking the symbol. Offer to search for the correct symbol. `GET /v2/assets/{symbol_or_asset_id}` is the place a `404` legitimately appears.620- **Market closed (422):** Show current market status and next open time using the clock endpoint (`GET /v2/clock`).621- **Rate limit (429):** Wait and retry with exponential backoff. Inform you of the delay.622- **Network timeout:** Check if the order was received (by `client_order_id`) before deciding whether to retry.623- **Unknown error:** Show the full error response. Do not silently swallow errors. Log the error to the session file.624625---626627## 6 - Output contract628629### In-chat response after submission630631```632Order submitted successfully.633634Order ID: {order_id}635Status: {status}636Symbol: {symbol}637Side: {side}638Qty: {qty}639Type: {order_type}640TIF: {time_in_force}641Submitted at: {submitted_at}642Environment: PAPER643644Next steps:645- Ask me to check the status of this order646- Ask me to cancel this order647- Ask me to show your current positions648- Ask me to show your portfolio summary649```650651### Run folder artifacts652653When the skill is used as part of a session with multiple orders, your agent writes session artifacts to a run folder:654655```656runs/<YYYYMMDD-HHMMSS>-paper-trading/657 notes.md # strategy context, confirmation choices, assumptions658 orders.json # all orders submitted in this session659 order_log.csv # timeline: order_id, timestamp, event, status, details660 positions_snapshot.json # positions after last fill661 portfolio_summary.md # human-readable portfolio state662 review.md # session review and open questions663```664665**File descriptions:**666667| File | Content | Format |668|---|---|---|669| `notes.md` | Strategy description, signal source, confirmation preferences, assumptions made, risk controls applied | Markdown |670| `orders.json` | Array of all orders submitted, including request payload and response | JSON |671| `order_log.csv` | Chronological event log: `order_id, timestamp, event_type, status, details` | CSV |672| `positions_snapshot.json` | Positions at the end of the session (from `GET /v2/positions`) | JSON |673| `portfolio_summary.md` | Human-readable portfolio state: equity, buying power, positions, concentration, P&L | Markdown |674| `review.md` | Session review: what worked, what didn't, open questions, suggested improvements | Markdown |675676---677678## 7 - Validation and tests679680Validate behavior against:681- Happy path scenarios for each asset class682- Missing and ambiguous input handling683- Auth and permission failure handling684- Environment safety verification (live credential detection)685- Order lifecycle transitions686- Edge cases: insufficient buying power, non-tradable symbols, market-closed, PDT warnings687- Idempotency and network failure recovery688- Confirmation mode switching689690Run these tests mentally or against a paper account whenever modifying this skill.691692---693694## 8 - Disclosures, safety, and data handling695696### Required disclosure697698> **Important disclosure:** This material is for informational, educational, and research purposes only. It is not investment advice, a recommendation, an offer, or a solicitation to buy or sell securities, options, cryptocurrencies, or any other financial product. All investing and trading involve risk, including possible loss of principal. Paper trading is simulated and may differ from live trading in fills, market impact, liquidity, fees, latency, and other factors. Review Alpaca's disclosures at https://alpaca.markets/disclosures.699700Your agent includes this disclosure in every session summary, report, and portfolio review.701702### Paper-trading specific703704- Paper trading results are simulated. They do not represent actual trading performance.705- Paper fills may differ from live fills in price, timing, partial fills, and rejection behavior.706- Paper trading does not charge real commissions or fees. Live trading may incur costs.707- Moving from paper to live trading is a separate, significant decision that requires additional review of risk tolerance, capital adequacy, and regulatory requirements.708- This skill will never facilitate that transition directly.709710### Options-specific711712When options are involved, your agent includes:713714- Options involve significant risk and are not suitable for all investors.715- Options can expire worthless. You can lose the entire premium paid for long options.716- Selling options carries risk that can exceed the premium received, and assignment can force a position at an unfavorable price.717- Complex options strategies (spreads, straddles, strangles) carry additional risks and may have multiple legs with different outcomes.718- Options are subject to exercise and assignment risk, especially near expiration.719- Understand the Greeks (delta, gamma, theta, vega) and how they affect your position before trading.720721### Crypto-specific722723When crypto is involved, your agent includes:724725- Cryptocurrency trading involves substantial risk due to high volatility.726- Crypto assets are not securities and may have different regulatory protections than traditional securities.727- Crypto markets operate 24/7 and can experience significant price swings at any time.728- Crypto assets are not FDIC insured or SIPC protected.729- Regulatory environment for crypto is evolving and may change.730731### Credentials and data handling732733- Your agent reads credentials from environment variables (`APCA_API_KEY_ID`, `APCA_API_SECRET_KEY`), SDK configuration files, or CLI profile settings.734- **Never** paste API keys or secrets into chat. Your agent will refuse to accept them if offered.735- Your agent redacts account IDs, order IDs, and personally identifiable information in any summaries shared outside the session.736- Raw API responses are stored locally only (in the run folder) and classified as account-level confidential.737- Your agent does not send trading data, account data, or credentials to any third party.738- Session artifacts (run folder files) remain on your local filesystem. Review and delete them as appropriate.739740---741742## 9 - Anti-patterns743744- **NEVER** submit orders to a live trading environment. This skill is paper-only.745- **NEVER** ask for API keys or secrets in chat. Credentials come from environment variables or746747…(truncated)
Run npx skillmds@latest add alpacahq/alpaca-trading-paper-trading in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
Preview, submit, inspect, and manage Alpaca paper-trading orders across US equities, options, and crypto. Use this skill when you want your AI agent to take a strategy signal — from a backtest, manual idea, or automated system — and execute it safely in your Alpaca paper-trading environment. This generic version works with any Alpaca SDK, REST API call, or agent tool that can reach the Trading API. It is listed under AI & ML on SkillMD.
This skill has not completed SkillMD's automated safety review yet. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
alpacahq (@alpacahq) published this skill. Their other Agent Skills are listed on their SkillMD profile.