Creator · alpacahq
Last updated · Sep 4, 2026
Execute deterministic, reproducible historical backtests from a start date, end date, and strategy concept using the Alpaca CLI plus agent-written workspace code. Use when the user wants to backtest a strategy, simulate historical trades, or return trades, diagnostics, and reprod
Creator · alpacahq
Last updated · Sep 4, 2026
Execute deterministic, reproducible historical backtests from a start date, end date, and strategy concept using the Alpaca CLI plus agent-written workspace code. Use when the user wants to backtest a strategy, simulate historical trades, or return trades, diagnostics, and reprod
Creator · alpacahq
Last updated · Sep 4, 2026
Execute deterministic, reproducible historical backtests from a start date, end date, and strategy concept using the Alpaca CLI plus agent-written workspace code. Use when the user wants to backtest a strategy, simulate historical trades, or return trades, diagnostics, and reprod
Creator · alpacahq
Last updated · Sep 4, 2026
Execute deterministic, reproducible historical backtests from a start date, end date, and strategy concept using the Alpaca CLI plus agent-written workspace code. Use when the user wants to backtest a strategy, simulate historical trades, or return trades, diagnostics, and reprod
Sandbox only
Install targets
Codex install prompt
Install the "alpaca-trading-backtest" agent skill from https://github.com/alpacahq/alpaca-skills/tree/main/skills/trading-api/backtest. Read its SKILL.md or equivalent instructions first, install only the files needed for this workspace, and summarize any required setup before using it. Skill purpose: Execute deterministic, reproducible historical backtests from a start date, end date, and strategy concept using the Alpaca CLI plus agent-written workspace code. Use when the user wants to backtest a strategy, simulate historical trades, or return trades, diagnostics, and reproducibility artifacts. After the install attempt, report the result to https://www.openagentskill.com/api/agent/outcome with POST JSON {"event_id":"install_<unique-id>","skill_slug":"alpacahq-alpaca-trading-backtest","task":"Install alpaca-trading-backtest","agent":"codex","outcome":"success","install_used":true}. Replace event_id with a unique value and outcome with success or failed. Report success only after the skill is installed and a minimal verification passes.Supply asset profile
Code review, repo analysis, testing, CI, GitHub, DevOps, and developer workflow skills.
Scenario
Coding agents
I need a coding agent that can understand a repository, edit code, and review pull requests.
Agent fit
Claude Code + CLI + Codex
Codex, Claude Code, Cursor, CLI, or custom agents.
Install
Ready
npx skills add alpacahq/alpaca-skills --skill alpaca-trading-backtest
Maintenance
fresh
3d since push
Risk
Risky
Dependency or permission surface needs review
GitHub quality
142
68/100 Quality · 73/100 Trust
Coverage tags
Review notes
Dependency or permission surface needs review · Permission surface may require sandboxing
Agent adoption scorecard
These scores combine public repository metadata, OpenAgentSkill review signals, maintenance freshness, and install readiness. They are a shortlist signal, not a replacement for human review.
Quality
PromisingUseful candidate, but compare it with alternatives before adopting.
Trust
Sandbox onlyUseful candidate with missing or mixed trust signals. Keep it in an isolated workspace until the outcome loop proves task fit.
Audit
RiskyA machine-readable review of install readiness, security metadata, maintenance, and adoption risk.
OpenAgentSkill Trust Score v5
Run only in a sandbox and compare close alternatives before using it for real work.
Stars
142 GitHub stars
Repo activity
142 stars, 17 forks
Maintenance
3d since push
License
Apache-2.0
Install
npx skills add alpacahq/alpaca-skills --skill alpaca-trading-backtest
Install safety
Agent-readable metadata
Use this block or the embedded JSON to decide whether an agent should install this skill, choose an alternative, or ask for human review first.
Suited tasks
Suited agents
Install decision
Trust and risk
Outcome loop
Install command
npx skills add alpacahq/alpaca-skills --skill alpaca-trading-backtestDo not use when
Alternative
168.6K Stars
npx skills add mattpocock/skills --skill code-review
Alternative
40.8K Stars
npx skills add appsmithorg/appsmith
Alternative
175.7K Stars
npx skills add mattpocock/skills --skill implement
Alternative
30.9K Stars
npx skills add vercel-labs/agent-skills --skill vercel-react-best-practices
Agent safety v2
This skill should not be selected by an agent without explicit human security review.
Do not auto-install. Inspect the source, dependencies, and permission surface first.
high
Skill metadata references terminal, CLI, shell, subprocess, or command execution workflows.
medium
Skill likely fetches remote pages, APIs, repositories, or external services.
medium
Skill may read or write project files, documents, generated artifacts, or local workspace state.
high
Skill metadata references credentials, tokens, environment variables, or secret-bearing workflows.
Agent resolve plan
The Resolve API returns the selected skill, alternatives, safety policy, audit notes, install target, and copy-paste prompt an agent can follow without scraping this page.
Open JSON
/api/agent/resolve?task=Use%20alpaca-trading-backtest%20for%20an%20agent%20workflow&agent=codex&max_risk=medium
Resolve text
/api/agent/resolve?task=Use%20alpaca-trading-backtest%20for%20an%20agent%20workflow&agent=codex&max_risk=medium&format=text
Install handoff
/api/skills/alpacahq-alpaca-trading-backtest/install
Agent should check
Copy prompt
Task: Use alpaca-trading-backtest in this workspace.
Resolve first: https://www.openagentskill.com/api/agent/resolve?task=Use%20alpaca-trading-backtest%20for%20an%20agent%20workflow&agent=codex&max_risk=medium
Review install handoff: https://www.openagentskill.com/api/skills/alpacahq-alpaca-trading-backtest/install
Install command: npx skills add alpacahq/alpaca-skills --skill alpaca-trading-backtest
Before running it, summarize audit warnings, required permissions, and the fallback skill if install is risky.Agent handoff
Use the public install endpoint to fetch the command, safety checklist, target prompts, and canonical links for this skill.
Install handoff
/api/skills/alpacahq-alpaca-trading-backtest/install
LLM text format
/api/skills/alpacahq-alpaca-trading-backtest/install?format=text
Find alternatives
/api/skills/search?q=alpaca-trading-backtest&limit=3
Agent prompt
Use alpaca-trading-backtest for this task. Review https://www.openagentskill.com/api/skills/alpacahq-alpaca-trading-backtest/install, then install with: npx skills add alpacahq/alpaca-skills --skill alpaca-trading-backtestRegistry metadata
This page exposes the same decision, trust, audit, use-case, and install signals through the Registry API, so agents can rank this skill without scraping the UI.
Manifest
/api/registry/manifest/alpacahq-alpaca-trading-backtest
LLM text
/api/registry/manifest/alpacahq-alpaca-trading-backtest?format=text
Install alias
/api/registry/install/alpacahq-alpaca-trading-backtest
Recommend
/api/registry/recommend?task=Use%20alpaca-trading-backtest%20in%20an%20agent%20workflow&limit=3
Agent fit
Finance and quant
Use-case tags
Platforms
Claude Code
Audit report
A machine-readable review of install readiness, security metadata, maintenance, and adoption risk.
Agent decision cockpit
Prototype with this skill first; keep a fallback candidate ready.
Role in stack
Fallback candidate
Primary fit
Finance and quant
Trust label
Prototype first
Install path
Command ready
Use when
Evidence
review first
Implementation path
Trust profile
Useful candidate with missing or mixed trust signals. Keep it in an isolated workspace until the outcome loop proves task fit.
GitHub adoption
INFO142 GitHub stars
Stars/forks activity
CHECK142 stars, 17 forks; issue activity unavailable in current metadata
Recent maintenance
PASS3d since push
License clarity
PASSApache-2.0
Good signals
Review before install
Recommended action
Run only in a sandbox and compare close alternatives before using it for real work.
Quality profile
Useful candidate, but compare it with alternatives before adopting.
Workflow fit
Analyze markets
I need my agent to analyze markets, financial data, filings, portfolios, and quant strategies.
Build and ship code
I need a coding agent that can understand a repository, edit code, and review pull requests.
Investigate faster
I need my agent to research a topic, compare sources, and produce a concise report.
Workflow fit
Inspect, patch, and verify code
A workflow for software agents that inspect repositories, review pull requests, generate tests, and turn findings into shippable patches.
Find, compare, and synthesize
A workflow for agents that gather sources, compare claims, summarize long material, and draft useful research briefs.
Turn skills into distribution
A workflow for turning newly indexed skills into SEO briefs, social drafts, comparison pages, and reusable publishing workflows.
Alternative shortlist
Similar skills that may fit this task.
Review a branch or diff against repository standards and the originating spec in two independent analysis passes.
Platform to build admin panels, internal tools, and dashboards. Integrates with 25+ databases and any API.
Implement work from an approved spec or ticket set, run focused and full tests, invoke code review, and commit the result to the current branch.
React and Next.js performance guidance for writing, reviewing, and refactoring production UI code.
--- name: alpaca-trading-backtest description: > Execute deterministic, reproducible historical backtests from a start date, end date, and strategy concept using the Alpaca CLI plus agent-written workspace code. Use when the user wants to backtest a strategy, simulate historical trades, or return trades, diagnostics, and reproducibility artifacts. ---
# Trading API Backtesting
Use this skill when you want your AI agent to run a specific historical backtest with the Alpaca CLI and local workspace code. This version is optimized for run-specific execution: your agent writes the minimum readable code needed for the confirmed strategy, stores the exact artifacts, and reports the results back to you.
This skill is written for you, the person invoking it through your AI agent. **You** means the trader, developer, researcher, or operator asking your agent to run the backtest. Your agent should address you directly, restate assumptions clearly, and make every interpretation choice visible.
```text strategy idea -> formalized rules -> confirmed assumptions -> CLI data fetch -> local script -> artifacts -> report ```
It is not a promise that a strategy will work in live markets. It is a reproducible research workflow.
## Required disclosures
Every report, `notes.md`, `report.md`, notebook, dashboard, or exported result should include:
> **Important disclosure** > This backtest is a hypothetical historical simulation and does not represent actual trading performance. Backtested results do not guarantee future results. Results depend on market-data quality, data feed selection, corporate-action handling, fees, slippage, liquidity, taxes, execution assumptions, and implementation details. This material is for research and educational purposes only and is not investment advice, a recommendation, an offer, or a solicitation to buy or sell securities, options, cryptocurrencies, or any other financial product. All investments involve risk and may lose value. Review Alpaca's disclosures and agreements at [alpaca.markets/disclosures](https://alpaca.markets/disclosures).
When paper trading appears in the workflow, add:
> Paper trading is a simulated environment. It does not involve real money or actual securities transactions. Paper results may differ from live trading because of fill assumptions, market impact, liquidity, latency, data differences, order handling, fees, and other market conditions.
When the backtest models Alpaca securities trading-activity fees, `notes.md`, `summary.json`, and `report.md` should link to the Alpaca Brokerage Fee Schedule PDF:
```text https://files.alpaca.markets/disclosures/library/BrokFeeSched.pdf ```
Record the PDF revision date, extraction timestamp, modeled fee categories, and any fee items intentionally excluded.
## CLI prerequisites
### Alpaca CLI
Your agent should use the Alpaca CLI for market-data access.
Check whether it is installed:
```bash alpaca version ```
Install with Go when needed:
```bash go install github.com/alpacahq/cli/cmd/alpaca@latest ```
On macOS or Linux with Homebrew:
```bash brew install alpacahq/tap/cli ```
Make sure the binary directory is on `PATH`, commonly `~/go/bin` for Go installs.
### Local execution permissions
Alpaca CLI commands should run in your local workspace where your Alpaca profile, environment variables, network access, and saved artifacts are available. Some agent runtimes express this as:
```text required_permissions: ["all"] ```
Use the equivalent permission model in your agent environment so the CLI can access local auth/config and write run artifacts.
### Connectivity and authentication check
Before any backtest run, verify the CLI and credentials:
```bash alpaca doctor ```
If authentication fails, your agent should stop the run and show you the available login/help command:
```bash alpaca profile login --help ```
For interactive paper setup:
```bash alpaca profile login ```
For API-key setup:
```bash alpaca profile login --api-key ```
For automation, environment variables are preferred because secrets do not need to be written into generated code:
```bash export ALPACA_API_KEY=PK... export ALPACA_SECRET_KEY=... export ALPACA_QUIET=1 ```
Your agent should never print your secret key, commit it to files, include it in reports, or pass it in a way that exposes it to shell history.
### Machine-readable output
Use `--quiet` for commands whose output will be parsed by code:
```bash alpaca account get --quiet alpaca data bars --symbol SPY --start 2024-01-01 --end 2024-12-31 --timeframe 1Day --quiet ```
Use installed CLI help and schemas as the source of truth for flags and response fields:
```bash alpaca --help-all alpaca data bars --help alpaca data bars --schema alpaca data quotes --schema ```
Because the CLI is generated from API specifications and may evolve, your agent should prefer current `--help`, `--schema`, and `alpaca doctor` output over stale examples.
## Required workflow
Your agent should follow this workflow:
1. Gather required inputs: start date, end date, strategy concept or strategy file. 2. Gather or infer the rest: asset class, symbols or universe, timeframe, initial cash, position sizing, feed, adjustment mode, execution assumptions, benchmark. 3. Work through [run considerations](#run-considerations-checklist): order simulation, indicators, dividends, splits, fees, slippage, spread, market hours, calendar handling, and validation. 4. Translate your freeform idea into precise mathematical rules. 5. Present the formalized interpretation to you before writing code unless your request was already mathematically precise. 6. Check the workspace for reusable data, prior runs, and existing utilities. 7. Create a self-contained run folder. 8. Write `notes.md`, `strategy_spec.json`, `config.json`, and a readable run-specific script. 9. Fetch historical data through the Alpaca CLI, save raw CLI outputs, filter to the chosen market hours, and compute data fingerprints. 10. Run the local simulation. 11. Write artifacts. 12. Return the Teaching Five, first/last trade, assumptions, caveats, data fingerprint, and artifact paths.
## Workspace awareness
Before generating new code or fetching data, your agent should inspect the workspace.
### Data reuse
Look for prior raw data files or cached normalized data that match:
```text symbol asset class feed adjustment mode timeframe start/end range calendar filter regular-hours or extended-hours setting ```
Reuse data only when the data fingerprint matches. If fingerprints differ, your agent should treat the runs as using different input data.
### Run lineage
If this run is a variant of a prior run, `notes.md` should say what changed:
```text changed RSI threshold from 30/70 to 25/75 changed fill model from next_open bar proxy to quote-aware fill changed slippage from 5 bps to 10 bps extended date range from 2020-2024 to 2018-2025 ```
### Existing code
If the workspace already has a backtest engine or shared utility that matches the strategy requirements, your agent may reuse it. Otherwise, the default is a single readable `run.py` in the run folder.
## Run folder and artifact contract
Artifact paths in this skill use `raw/` and `normalized/` as canonical names.
Every run should create a folder like:
```text runs/YYYY-MM-DD_symbol_strategy_timeframe/ notes.md strategy_spec.json config.json run.py requirements.txt or pyproject.toml when needed raw/ bars_SYMBOL.json quotes_SYMBOL.json trades_SYMBOL.json calendar.json corporate_actions.json normalized/ bars_SYMBOL.csv quotes_SYMBOL.csv summary.json report.md trades.csv round_trips.csv equity.csv benchmark_equity.csv data_fingerprint.json warnings.json fee_source.json ```
### `notes.md`
`notes.md` should include your original request, confirmed strategy interpretation, every inferred/defaulted assumption, indicator definitions, fill model, fee model, data feed and adjustment mode, dividend and split treatment, benchmark definitions, calendar and market-hours handling, warnings and caveats, and Alpaca disclosure and fee schedule links.
### Other artifacts
See [reference.md](reference.md) for `summary.json`, `strategy_spec.json`, `data_fingerprint.json`, and `fee_source.json` schemas.
## Code generation rules
For run-specific CLI backtests, your agent should generate a script, not a reusable framework. A single-file `run.py` is the default.
Use readable code:
```python fill_price = bar_open * (1 + friction_pct) ```
instead of compressed expressions that make the artifact hard to audit.
The generated code should:
- read raw or normalized files from the run folder; - implement the confirmed strategy exactly; - implement the chosen indicator definitions exactly (see [Indicator formulas](reference.md#indicator-formulas)); - keep signal timing separate from fill timing; - compute fees, slippage, spread, and settlement according to the confirmed assumptions; - produce all required artifacts; - include deterministic sorting and timezone handling; - avoid hidden network calls after data fetch unless explicitly documented.
Use Python 3 by default. Prefer the standard library plus pandas/numpy when available. Add dependencies only when they materially improve correctness or readability.
## Strategy translation
Your agent should formalize your idea before code generation.
Every rule should specify: data field, trigger, inclusive/exclusive bounds, indicator variant and parameters, warmup behavior, position sizing and rounding, cash handling, order type, fill model, and benchmark.
Example confirmation:
```text I interpreted your strategy as: - Symbol: SPY - Timeframe: 1Day - Data: Alpaca CLI bars, feed=sip, adjustment=split - Indicator: SMA(50) and SMA(200), simple arithmetic mean of completed daily closes - Entry: fast SMA crosses above slow SMA - Exit: fast SMA crosses below slow SMA - Signal timing: completed bar close - Fill timing: next trading day's open - Fill model: next_open bar proxy with 5 bps slippage unless quotes are available - Sizing: invest 100% of available cash, fractional shares allowed when supported - Benchmark: SPY buy-and-hold with same assumptions ```
After confirmation, code should match the confirmed interpretation.
## Fill models
Use these model names in confirmations and `notes.md`. Implementation detail is in [Fill model rules](reference.md#fill-model-rules).
- **`next_open`** (default): signal on bar T close; fill on bar T+1 open or quote at T+1 open timestamp. - **`time_based`**: fill at a confirmed time of day; quote bid/ask when available. - **`same_bar`**: only when explicitly requested; document look-ahead risk in `notes.md` and the report. - **Limit and stop orders**: OHLC-bar eligibility rules apply; use conservative intrabar conflict policy when stop and target both touch the same bar.
## Report format
`report.md` should lead with **Performance vs Benchmarks**:
```markdown | | Total Return | Ann. Return | Max Drawdown | Sharpe | Final Equity | |---|---:|---:|---:|---:|---:| | **Strategy** | ...% | ...% | ...% | ... | $... | | Benchmark | ...% | ...% | ...% | ... | $... | ```
After the table, include strategy configuration, symbols/timeframe/feed/adjustment, fill model and friction, first and last trade, detailed metrics, benchmark explanation, assumptions, data fingerprint, caveats, and the disclosure block.
Metric definitions are in [reference.md](reference.md#metric-formulas).
## In-chat response standard
Lead with the **Teaching Five**:
1. total return versus benchmark; 2. max drawdown; 3. number of trades; 4. win rate; 5. Sharpe ratio versus benchmark.
Then include: annualized return, profit factor, fees paid, first trade, last trade, assumptions made, data fingerprint summary, artifact paths, and most important caveats.
If no trades occurred, say that directly and explain whether this was due to warmup, no signal, insufficient
Source provenance
Decision snapshot
recent repository activity
Audit
Install and adoption review
Agent-proven evidence
Outcome reports after resolve, review, install, and one narrow run.
No agent outcome data yet. The first agent run can report success, setup needs, risk blocks, failure, or not-relevant through /api/agent/outcome.
Install
Free and open source. Review the report before installing into production agents.
Growth loop
Scenario-led draft for alpaca-trading-backtest, ready for a manual X post.
alpaca-trading-backtest: Execute deterministic, reproducible historical backtests from a start date, end date, and str... 142 stars https://www.openagentskill.com/skills/alpacahq-alpaca-trading-backtest?ref=x
Listing + install path for alpaca-trading-backtest: https://www.openagentskill.com/skills/alpacahq-alpaca-trading-backtest?ref=x Install: npx skills add alpacahq/alpaca-skills --skill alpaca-trading-backtest
Listing source
This listing was indexed from public sources and is not marked official until a maintainer claim is approved.
Attribution links to the public repository or creator profile. Creators can claim the listing to update ownership signals.
Claim this skillOwner claim
This Registry indexed listing is attributed to alpacahq but is not marked official yet. Claim it to add a verified owner signal and make future launch, install, and audit updates easier to trust.
Creator backlink kit
Show the canonical listing, current trust and audit signals, and real Agent-Proven evidence where developers evaluate the repository.
[](https://www.openagentskill.com/skills/alpacahq-alpaca-trading-backtest?ref=github&utm_source=github&utm_medium=referral&utm_campaign=creator_badge)
[](https://www.openagentskill.com/skills/alpacahq-alpaca-trading-backtest?ref=github&utm_source=github&utm_medium=referral&utm_campaign=creator_badge)
[](https://www.openagentskill.com/skills/alpacahq-alpaca-trading-backtest/audit)
[](https://www.openagentskill.com/skills/alpacahq-alpaca-trading-backtest?ref=github&utm_source=github&utm_medium=referral&utm_campaign=creator_badge)alpacahq
@alpacahq
Share whether this skill looks useful for your agent workflow. Aggregated feedback improves rankings over time.
Sandbox only
Code Review
Review a branch or diff against repository standards and the originating spec in two independent analysis passes.
168.6K StarsAppsmith
Platform to build admin panels, internal tools, and dashboards. Integrates with 25+ databases and any API.
40.8K StarsImplement
Implement work from an approved spec or ticket set, run focused and full tests, invoke code review, and commit the result to the current branch.
175.7K StarsVercel React Best Practices
React and Next.js performance guidance for writing, reviewing, and refactoring production UI code.
30.9K StarsSandbox only
Install targets
Codex install prompt
Install the "alpaca-trading-backtest" agent skill from https://github.com/alpacahq/alpaca-skills/tree/main/skills/trading-api/backtest. Read its SKILL.md or equivalent instructions first, install only the files needed for this workspace, and summarize any required setup before using it. Skill purpose: Execute deterministic, reproducible historical backtests from a start date, end date, and strategy concept using the Alpaca CLI plus agent-written workspace code. Use when the user wants to backtest a strategy, simulate historical trades, or return trades, diagnostics, and reproducibility artifacts. After the install attempt, report the result to https://www.openagentskill.com/api/agent/outcome with POST JSON {"event_id":"install_<unique-id>","skill_slug":"alpacahq-alpaca-trading-backtest","task":"Install alpaca-trading-backtest","agent":"codex","outcome":"success","install_used":true}. Replace event_id with a unique value and outcome with success or failed. Report success only after the skill is installed and a minimal verification passes.Supply asset profile
Code review, repo analysis, testing, CI, GitHub, DevOps, and developer workflow skills.
Scenario
Coding agents
I need a coding agent that can understand a repository, edit code, and review pull requests.
Agent fit
Claude Code + CLI + Codex
Codex, Claude Code, Cursor, CLI, or custom agents.
Install
Ready
npx skills add alpacahq/alpaca-skills --skill alpaca-trading-backtest
Maintenance
fresh
3d since push
Risk
Risky
Dependency or permission surface needs review
GitHub quality
142
68/100 Quality · 73/100 Trust
Coverage tags
Review notes
Dependency or permission surface needs review · Permission surface may require sandboxing
Agent adoption scorecard
These scores combine public repository metadata, OpenAgentSkill review signals, maintenance freshness, and install readiness. They are a shortlist signal, not a replacement for human review.
Quality
PromisingUseful candidate, but compare it with alternatives before adopting.
Trust
Sandbox onlyUseful candidate with missing or mixed trust signals. Keep it in an isolated workspace until the outcome loop proves task fit.
Audit
RiskyA machine-readable review of install readiness, security metadata, maintenance, and adoption risk.
OpenAgentSkill Trust Score v5
Run only in a sandbox and compare close alternatives before using it for real work.
Stars
142 GitHub stars
Repo activity
142 stars, 17 forks
Maintenance
3d since push
License
Apache-2.0
Install
npx skills add alpacahq/alpaca-skills --skill alpaca-trading-backtest
Install safety
Agent-readable metadata
Use this block or the embedded JSON to decide whether an agent should install this skill, choose an alternative, or ask for human review first.
Suited tasks
Suited agents
Install decision
Trust and risk
Outcome loop
Install command
npx skills add alpacahq/alpaca-skills --skill alpaca-trading-backtestDo not use when
Alternative
168.6K Stars
npx skills add mattpocock/skills --skill code-review
Alternative
40.8K Stars
npx skills add appsmithorg/appsmith
Alternative
175.7K Stars
npx skills add mattpocock/skills --skill implement
Alternative
30.9K Stars
npx skills add vercel-labs/agent-skills --skill vercel-react-best-practices
Agent safety v2
This skill should not be selected by an agent without explicit human security review.
Do not auto-install. Inspect the source, dependencies, and permission surface first.
high
Skill metadata references terminal, CLI, shell, subprocess, or command execution workflows.
medium
Skill likely fetches remote pages, APIs, repositories, or external services.
medium
Skill may read or write project files, documents, generated artifacts, or local workspace state.
high
Skill metadata references credentials, tokens, environment variables, or secret-bearing workflows.
Agent resolve plan
The Resolve API returns the selected skill, alternatives, safety policy, audit notes, install target, and copy-paste prompt an agent can follow without scraping this page.
Open JSON
/api/agent/resolve?task=Use%20alpaca-trading-backtest%20for%20an%20agent%20workflow&agent=codex&max_risk=medium
Resolve text
/api/agent/resolve?task=Use%20alpaca-trading-backtest%20for%20an%20agent%20workflow&agent=codex&max_risk=medium&format=text
Install handoff
/api/skills/alpacahq-alpaca-trading-backtest/install
Agent should check
Copy prompt
Task: Use alpaca-trading-backtest in this workspace.
Resolve first: https://www.openagentskill.com/api/agent/resolve?task=Use%20alpaca-trading-backtest%20for%20an%20agent%20workflow&agent=codex&max_risk=medium
Review install handoff: https://www.openagentskill.com/api/skills/alpacahq-alpaca-trading-backtest/install
Install command: npx skills add alpacahq/alpaca-skills --skill alpaca-trading-backtest
Before running it, summarize audit warnings, required permissions, and the fallback skill if install is risky.Agent handoff
Use the public install endpoint to fetch the command, safety checklist, target prompts, and canonical links for this skill.
Install handoff
/api/skills/alpacahq-alpaca-trading-backtest/install
LLM text format
/api/skills/alpacahq-alpaca-trading-backtest/install?format=text
Find alternatives
/api/skills/search?q=alpaca-trading-backtest&limit=3
Agent prompt
Use alpaca-trading-backtest for this task. Review https://www.openagentskill.com/api/skills/alpacahq-alpaca-trading-backtest/install, then install with: npx skills add alpacahq/alpaca-skills --skill alpaca-trading-backtestRegistry metadata
This page exposes the same decision, trust, audit, use-case, and install signals through the Registry API, so agents can rank this skill without scraping the UI.
Manifest
/api/registry/manifest/alpacahq-alpaca-trading-backtest
LLM text
/api/registry/manifest/alpacahq-alpaca-trading-backtest?format=text
Install alias
/api/registry/install/alpacahq-alpaca-trading-backtest
Recommend
/api/registry/recommend?task=Use%20alpaca-trading-backtest%20in%20an%20agent%20workflow&limit=3
Agent fit
Finance and quant
Use-case tags
Platforms
Claude Code
Audit report
A machine-readable review of install readiness, security metadata, maintenance, and adoption risk.
Agent decision cockpit
Prototype with this skill first; keep a fallback candidate ready.
Role in stack
Fallback candidate
Primary fit
Finance and quant
Trust label
Prototype first
Install path
Command ready
Use when
Evidence
review first
Implementation path
Trust profile
Useful candidate with missing or mixed trust signals. Keep it in an isolated workspace until the outcome loop proves task fit.
GitHub adoption
INFO142 GitHub stars
Stars/forks activity
CHECK142 stars, 17 forks; issue activity unavailable in current metadata
Recent maintenance
PASS3d since push
License clarity
PASSApache-2.0
Good signals
Review before install
Recommended action
Run only in a sandbox and compare close alternatives before using it for real work.
Quality profile
Useful candidate, but compare it with alternatives before adopting.
Workflow fit
Analyze markets
I need my agent to analyze markets, financial data, filings, portfolios, and quant strategies.
Build and ship code
I need a coding agent that can understand a repository, edit code, and review pull requests.
Investigate faster
I need my agent to research a topic, compare sources, and produce a concise report.
Workflow fit
Inspect, patch, and verify code
A workflow for software agents that inspect repositories, review pull requests, generate tests, and turn findings into shippable patches.
Find, compare, and synthesize
A workflow for agents that gather sources, compare claims, summarize long material, and draft useful research briefs.
Turn skills into distribution
A workflow for turning newly indexed skills into SEO briefs, social drafts, comparison pages, and reusable publishing workflows.
Alternative shortlist
Similar skills that may fit this task.
Review a branch or diff against repository standards and the originating spec in two independent analysis passes.
Platform to build admin panels, internal tools, and dashboards. Integrates with 25+ databases and any API.
Implement work from an approved spec or ticket set, run focused and full tests, invoke code review, and commit the result to the current branch.
React and Next.js performance guidance for writing, reviewing, and refactoring production UI code.
--- name: alpaca-trading-backtest description: > Execute deterministic, reproducible historical backtests from a start date, end date, and strategy concept using the Alpaca CLI plus agent-written workspace code. Use when the user wants to backtest a strategy, simulate historical trades, or return trades, diagnostics, and reproducibility artifacts. ---
# Trading API Backtesting
Use this skill when you want your AI agent to run a specific historical backtest with the Alpaca CLI and local workspace code. This version is optimized for run-specific execution: your agent writes the minimum readable code needed for the confirmed strategy, stores the exact artifacts, and reports the results back to you.
This skill is written for you, the person invoking it through your AI agent. **You** means the trader, developer, researcher, or operator asking your agent to run the backtest. Your agent should address you directly, restate assumptions clearly, and make every interpretation choice visible.
```text strategy idea -> formalized rules -> confirmed assumptions -> CLI data fetch -> local script -> artifacts -> report ```
It is not a promise that a strategy will work in live markets. It is a reproducible research workflow.
## Required disclosures
Every report, `notes.md`, `report.md`, notebook, dashboard, or exported result should include:
> **Important disclosure** > This backtest is a hypothetical historical simulation and does not represent actual trading performance. Backtested results do not guarantee future results. Results depend on market-data quality, data feed selection, corporate-action handling, fees, slippage, liquidity, taxes, execution assumptions, and implementation details. This material is for research and educational purposes only and is not investment advice, a recommendation, an offer, or a solicitation to buy or sell securities, options, cryptocurrencies, or any other financial product. All investments involve risk and may lose value. Review Alpaca's disclosures and agreements at [alpaca.markets/disclosures](https://alpaca.markets/disclosures).
When paper trading appears in the workflow, add:
> Paper trading is a simulated environment. It does not involve real money or actual securities transactions. Paper results may differ from live trading because of fill assumptions, market impact, liquidity, latency, data differences, order handling, fees, and other market conditions.
When the backtest models Alpaca securities trading-activity fees, `notes.md`, `summary.json`, and `report.md` should link to the Alpaca Brokerage Fee Schedule PDF:
```text https://files.alpaca.markets/disclosures/library/BrokFeeSched.pdf ```
Record the PDF revision date, extraction timestamp, modeled fee categories, and any fee items intentionally excluded.
## CLI prerequisites
### Alpaca CLI
Your agent should use the Alpaca CLI for market-data access.
Check whether it is installed:
```bash alpaca version ```
Install with Go when needed:
```bash go install github.com/alpacahq/cli/cmd/alpaca@latest ```
On macOS or Linux with Homebrew:
```bash brew install alpacahq/tap/cli ```
Make sure the binary directory is on `PATH`, commonly `~/go/bin` for Go installs.
### Local execution permissions
Alpaca CLI commands should run in your local workspace where your Alpaca profile, environment variables, network access, and saved artifacts are available. Some agent runtimes express this as:
```text required_permissions: ["all"] ```
Use the equivalent permission model in your agent environment so the CLI can access local auth/config and write run artifacts.
### Connectivity and authentication check
Before any backtest run, verify the CLI and credentials:
```bash alpaca doctor ```
If authentication fails, your agent should stop the run and show you the available login/help command:
```bash alpaca profile login --help ```
For interactive paper setup:
```bash alpaca profile login ```
For API-key setup:
```bash alpaca profile login --api-key ```
For automation, environment variables are preferred because secrets do not need to be written into generated code:
```bash export ALPACA_API_KEY=PK... export ALPACA_SECRET_KEY=... export ALPACA_QUIET=1 ```
Your agent should never print your secret key, commit it to files, include it in reports, or pass it in a way that exposes it to shell history.
### Machine-readable output
Use `--quiet` for commands whose output will be parsed by code:
```bash alpaca account get --quiet alpaca data bars --symbol SPY --start 2024-01-01 --end 2024-12-31 --timeframe 1Day --quiet ```
Use installed CLI help and schemas as the source of truth for flags and response fields:
```bash alpaca --help-all alpaca data bars --help alpaca data bars --schema alpaca data quotes --schema ```
Because the CLI is generated from API specifications and may evolve, your agent should prefer current `--help`, `--schema`, and `alpaca doctor` output over stale examples.
## Required workflow
Your agent should follow this workflow:
1. Gather required inputs: start date, end date, strategy concept or strategy file. 2. Gather or infer the rest: asset class, symbols or universe, timeframe, initial cash, position sizing, feed, adjustment mode, execution assumptions, benchmark. 3. Work through [run considerations](#run-considerations-checklist): order simulation, indicators, dividends, splits, fees, slippage, spread, market hours, calendar handling, and validation. 4. Translate your freeform idea into precise mathematical rules. 5. Present the formalized interpretation to you before writing code unless your request was already mathematically precise. 6. Check the workspace for reusable data, prior runs, and existing utilities. 7. Create a self-contained run folder. 8. Write `notes.md`, `strategy_spec.json`, `config.json`, and a readable run-specific script. 9. Fetch historical data through the Alpaca CLI, save raw CLI outputs, filter to the chosen market hours, and compute data fingerprints. 10. Run the local simulation. 11. Write artifacts. 12. Return the Teaching Five, first/last trade, assumptions, caveats, data fingerprint, and artifact paths.
## Workspace awareness
Before generating new code or fetching data, your agent should inspect the workspace.
### Data reuse
Look for prior raw data files or cached normalized data that match:
```text symbol asset class feed adjustment mode timeframe start/end range calendar filter regular-hours or extended-hours setting ```
Reuse data only when the data fingerprint matches. If fingerprints differ, your agent should treat the runs as using different input data.
### Run lineage
If this run is a variant of a prior run, `notes.md` should say what changed:
```text changed RSI threshold from 30/70 to 25/75 changed fill model from next_open bar proxy to quote-aware fill changed slippage from 5 bps to 10 bps extended date range from 2020-2024 to 2018-2025 ```
### Existing code
If the workspace already has a backtest engine or shared utility that matches the strategy requirements, your agent may reuse it. Otherwise, the default is a single readable `run.py` in the run folder.
## Run folder and artifact contract
Artifact paths in this skill use `raw/` and `normalized/` as canonical names.
Every run should create a folder like:
```text runs/YYYY-MM-DD_symbol_strategy_timeframe/ notes.md strategy_spec.json config.json run.py requirements.txt or pyproject.toml when needed raw/ bars_SYMBOL.json quotes_SYMBOL.json trades_SYMBOL.json calendar.json corporate_actions.json normalized/ bars_SYMBOL.csv quotes_SYMBOL.csv summary.json report.md trades.csv round_trips.csv equity.csv benchmark_equity.csv data_fingerprint.json warnings.json fee_source.json ```
### `notes.md`
`notes.md` should include your original request, confirmed strategy interpretation, every inferred/defaulted assumption, indicator definitions, fill model, fee model, data feed and adjustment mode, dividend and split treatment, benchmark definitions, calendar and market-hours handling, warnings and caveats, and Alpaca disclosure and fee schedule links.
### Other artifacts
See [reference.md](reference.md) for `summary.json`, `strategy_spec.json`, `data_fingerprint.json`, and `fee_source.json` schemas.
## Code generation rules
For run-specific CLI backtests, your agent should generate a script, not a reusable framework. A single-file `run.py` is the default.
Use readable code:
```python fill_price = bar_open * (1 + friction_pct) ```
instead of compressed expressions that make the artifact hard to audit.
The generated code should:
- read raw or normalized files from the run folder; - implement the confirmed strategy exactly; - implement the chosen indicator definitions exactly (see [Indicator formulas](reference.md#indicator-formulas)); - keep signal timing separate from fill timing; - compute fees, slippage, spread, and settlement according to the confirmed assumptions; - produce all required artifacts; - include deterministic sorting and timezone handling; - avoid hidden network calls after data fetch unless explicitly documented.
Use Python 3 by default. Prefer the standard library plus pandas/numpy when available. Add dependencies only when they materially improve correctness or readability.
## Strategy translation
Your agent should formalize your idea before code generation.
Every rule should specify: data field, trigger, inclusive/exclusive bounds, indicator variant and parameters, warmup behavior, position sizing and rounding, cash handling, order type, fill model, and benchmark.
Example confirmation:
```text I interpreted your strategy as: - Symbol: SPY - Timeframe: 1Day - Data: Alpaca CLI bars, feed=sip, adjustment=split - Indicator: SMA(50) and SMA(200), simple arithmetic mean of completed daily closes - Entry: fast SMA crosses above slow SMA - Exit: fast SMA crosses below slow SMA - Signal timing: completed bar close - Fill timing: next trading day's open - Fill model: next_open bar proxy with 5 bps slippage unless quotes are available - Sizing: invest 100% of available cash, fractional shares allowed when supported - Benchmark: SPY buy-and-hold with same assumptions ```
After confirmation, code should match the confirmed interpretation.
## Fill models
Use these model names in confirmations and `notes.md`. Implementation detail is in [Fill model rules](reference.md#fill-model-rules).
- **`next_open`** (default): signal on bar T close; fill on bar T+1 open or quote at T+1 open timestamp. - **`time_based`**: fill at a confirmed time of day; quote bid/ask when available. - **`same_bar`**: only when explicitly requested; document look-ahead risk in `notes.md` and the report. - **Limit and stop orders**: OHLC-bar eligibility rules apply; use conservative intrabar conflict policy when stop and target both touch the same bar.
## Report format
`report.md` should lead with **Performance vs Benchmarks**:
```markdown | | Total Return | Ann. Return | Max Drawdown | Sharpe | Final Equity | |---|---:|---:|---:|---:|---:| | **Strategy** | ...% | ...% | ...% | ... | $... | | Benchmark | ...% | ...% | ...% | ... | $... | ```
After the table, include strategy configuration, symbols/timeframe/feed/adjustment, fill model and friction, first and last trade, detailed metrics, benchmark explanation, assumptions, data fingerprint, caveats, and the disclosure block.
Metric definitions are in [reference.md](reference.md#metric-formulas).
## In-chat response standard
Lead with the **Teaching Five**:
1. total return versus benchmark; 2. max drawdown; 3. number of trades; 4. win rate; 5. Sharpe ratio versus benchmark.
Then include: annualized return, profit factor, fees paid, first trade, last trade, assumptions made, data fingerprint summary, artifact paths, and most important caveats.
If no trades occurred, say that directly and explain whether this was due to warmup, no signal, insufficient
Source provenance
Decision snapshot
recent repository activity
Audit
Install and adoption review
Agent-proven evidence
Outcome reports after resolve, review, install, and one narrow run.
No agent outcome data yet. The first agent run can report success, setup needs, risk blocks, failure, or not-relevant through /api/agent/outcome.
Install
Free and open source. Review the report before installing into production agents.
Growth loop
Scenario-led draft for alpaca-trading-backtest, ready for a manual X post.
alpaca-trading-backtest: Execute deterministic, reproducible historical backtests from a start date, end date, and str... 142 stars https://www.openagentskill.com/skills/alpacahq-alpaca-trading-backtest?ref=x
Listing + install path for alpaca-trading-backtest: https://www.openagentskill.com/skills/alpacahq-alpaca-trading-backtest?ref=x Install: npx skills add alpacahq/alpaca-skills --skill alpaca-trading-backtest
Listing source
This listing was indexed from public sources and is not marked official until a maintainer claim is approved.
Attribution links to the public repository or creator profile. Creators can claim the listing to update ownership signals.
Claim this skillOwner claim
This Registry indexed listing is attributed to alpacahq but is not marked official yet. Claim it to add a verified owner signal and make future launch, install, and audit updates easier to trust.
Creator backlink kit
Show the canonical listing, current trust and audit signals, and real Agent-Proven evidence where developers evaluate the repository.
[](https://www.openagentskill.com/skills/alpacahq-alpaca-trading-backtest?ref=github&utm_source=github&utm_medium=referral&utm_campaign=creator_badge)
[](https://www.openagentskill.com/skills/alpacahq-alpaca-trading-backtest?ref=github&utm_source=github&utm_medium=referral&utm_campaign=creator_badge)
[](https://www.openagentskill.com/skills/alpacahq-alpaca-trading-backtest/audit)
[](https://www.openagentskill.com/skills/alpacahq-alpaca-trading-backtest?ref=github&utm_source=github&utm_medium=referral&utm_campaign=creator_badge)alpacahq
@alpacahq
Share whether this skill looks useful for your agent workflow. Aggregated feedback improves rankings over time.
Sandbox only
Code Review
Review a branch or diff against repository standards and the originating spec in two independent analysis passes.
168.6K StarsAppsmith
Platform to build admin panels, internal tools, and dashboards. Integrates with 25+ databases and any API.
40.8K StarsImplement
Implement work from an approved spec or ticket set, run focused and full tests, invoke code review, and commit the result to the current branch.
175.7K StarsVercel React Best Practices
React and Next.js performance guidance for writing, reviewing, and refactoring production UI code.
30.9K StarsSandbox only
Install targets
Codex install prompt
Install the "alpaca-trading-backtest" agent skill from https://github.com/alpacahq/alpaca-skills/tree/main/skills/trading-api/backtest. Read its SKILL.md or equivalent instructions first, install only the files needed for this workspace, and summarize any required setup before using it. Skill purpose: Execute deterministic, reproducible historical backtests from a start date, end date, and strategy concept using the Alpaca CLI plus agent-written workspace code. Use when the user wants to backtest a strategy, simulate historical trades, or return trades, diagnostics, and reproducibility artifacts. After the install attempt, report the result to https://www.openagentskill.com/api/agent/outcome with POST JSON {"event_id":"install_<unique-id>","skill_slug":"alpacahq-alpaca-trading-backtest","task":"Install alpaca-trading-backtest","agent":"codex","outcome":"success","install_used":true}. Replace event_id with a unique value and outcome with success or failed. Report success only after the skill is installed and a minimal verification passes.Supply asset profile
Code review, repo analysis, testing, CI, GitHub, DevOps, and developer workflow skills.
Scenario
Coding agents
I need a coding agent that can understand a repository, edit code, and review pull requests.
Agent fit
Claude Code + CLI + Codex
Codex, Claude Code, Cursor, CLI, or custom agents.
Install
Ready
npx skills add alpacahq/alpaca-skills --skill alpaca-trading-backtest
Maintenance
fresh
3d since push
Risk
Risky
Dependency or permission surface needs review
GitHub quality
142
68/100 Quality · 73/100 Trust
Coverage tags
Review notes
Dependency or permission surface needs review · Permission surface may require sandboxing
Agent adoption scorecard
These scores combine public repository metadata, OpenAgentSkill review signals, maintenance freshness, and install readiness. They are a shortlist signal, not a replacement for human review.
Quality
PromisingUseful candidate, but compare it with alternatives before adopting.
Trust
Sandbox onlyUseful candidate with missing or mixed trust signals. Keep it in an isolated workspace until the outcome loop proves task fit.
Audit
RiskyA machine-readable review of install readiness, security metadata, maintenance, and adoption risk.
OpenAgentSkill Trust Score v5
Run only in a sandbox and compare close alternatives before using it for real work.
Stars
142 GitHub stars
Repo activity
142 stars, 17 forks
Maintenance
3d since push
License
Apache-2.0
Install
npx skills add alpacahq/alpaca-skills --skill alpaca-trading-backtest
Install safety
Agent-readable metadata
Use this block or the embedded JSON to decide whether an agent should install this skill, choose an alternative, or ask for human review first.
Suited tasks
Suited agents
Install decision
Trust and risk
Outcome loop
Install command
npx skills add alpacahq/alpaca-skills --skill alpaca-trading-backtestDo not use when
Alternative
168.6K Stars
npx skills add mattpocock/skills --skill code-review
Alternative
40.8K Stars
npx skills add appsmithorg/appsmith
Alternative
175.7K Stars
npx skills add mattpocock/skills --skill implement
Alternative
30.9K Stars
npx skills add vercel-labs/agent-skills --skill vercel-react-best-practices
Agent safety v2
This skill should not be selected by an agent without explicit human security review.
Do not auto-install. Inspect the source, dependencies, and permission surface first.
high
Skill metadata references terminal, CLI, shell, subprocess, or command execution workflows.
medium
Skill likely fetches remote pages, APIs, repositories, or external services.
medium
Skill may read or write project files, documents, generated artifacts, or local workspace state.
high
Skill metadata references credentials, tokens, environment variables, or secret-bearing workflows.
Agent resolve plan
The Resolve API returns the selected skill, alternatives, safety policy, audit notes, install target, and copy-paste prompt an agent can follow without scraping this page.
Open JSON
/api/agent/resolve?task=Use%20alpaca-trading-backtest%20for%20an%20agent%20workflow&agent=codex&max_risk=medium
Resolve text
/api/agent/resolve?task=Use%20alpaca-trading-backtest%20for%20an%20agent%20workflow&agent=codex&max_risk=medium&format=text
Install handoff
/api/skills/alpacahq-alpaca-trading-backtest/install
Agent should check
Copy prompt
Task: Use alpaca-trading-backtest in this workspace.
Resolve first: https://www.openagentskill.com/api/agent/resolve?task=Use%20alpaca-trading-backtest%20for%20an%20agent%20workflow&agent=codex&max_risk=medium
Review install handoff: https://www.openagentskill.com/api/skills/alpacahq-alpaca-trading-backtest/install
Install command: npx skills add alpacahq/alpaca-skills --skill alpaca-trading-backtest
Before running it, summarize audit warnings, required permissions, and the fallback skill if install is risky.Agent handoff
Use the public install endpoint to fetch the command, safety checklist, target prompts, and canonical links for this skill.
Install handoff
/api/skills/alpacahq-alpaca-trading-backtest/install
LLM text format
/api/skills/alpacahq-alpaca-trading-backtest/install?format=text
Find alternatives
/api/skills/search?q=alpaca-trading-backtest&limit=3
Agent prompt
Use alpaca-trading-backtest for this task. Review https://www.openagentskill.com/api/skills/alpacahq-alpaca-trading-backtest/install, then install with: npx skills add alpacahq/alpaca-skills --skill alpaca-trading-backtestRegistry metadata
This page exposes the same decision, trust, audit, use-case, and install signals through the Registry API, so agents can rank this skill without scraping the UI.
Manifest
/api/registry/manifest/alpacahq-alpaca-trading-backtest
LLM text
/api/registry/manifest/alpacahq-alpaca-trading-backtest?format=text
Install alias
/api/registry/install/alpacahq-alpaca-trading-backtest
Recommend
/api/registry/recommend?task=Use%20alpaca-trading-backtest%20in%20an%20agent%20workflow&limit=3
Agent fit
Finance and quant
Use-case tags
Platforms
Claude Code
Audit report
A machine-readable review of install readiness, security metadata, maintenance, and adoption risk.
Agent decision cockpit
Prototype with this skill first; keep a fallback candidate ready.
Role in stack
Fallback candidate
Primary fit
Finance and quant
Trust label
Prototype first
Install path
Command ready
Use when
Evidence
review first
Implementation path
Trust profile
Useful candidate with missing or mixed trust signals. Keep it in an isolated workspace until the outcome loop proves task fit.
GitHub adoption
INFO142 GitHub stars
Stars/forks activity
CHECK142 stars, 17 forks; issue activity unavailable in current metadata
Recent maintenance
PASS3d since push
License clarity
PASSApache-2.0
Good signals
Review before install
Recommended action
Run only in a sandbox and compare close alternatives before using it for real work.
Quality profile
Useful candidate, but compare it with alternatives before adopting.
Workflow fit
Analyze markets
I need my agent to analyze markets, financial data, filings, portfolios, and quant strategies.
Build and ship code
I need a coding agent that can understand a repository, edit code, and review pull requests.
Investigate faster
I need my agent to research a topic, compare sources, and produce a concise report.
Workflow fit
Inspect, patch, and verify code
A workflow for software agents that inspect repositories, review pull requests, generate tests, and turn findings into shippable patches.
Find, compare, and synthesize
A workflow for agents that gather sources, compare claims, summarize long material, and draft useful research briefs.
Turn skills into distribution
A workflow for turning newly indexed skills into SEO briefs, social drafts, comparison pages, and reusable publishing workflows.
Alternative shortlist
Similar skills that may fit this task.
Review a branch or diff against repository standards and the originating spec in two independent analysis passes.
Platform to build admin panels, internal tools, and dashboards. Integrates with 25+ databases and any API.
Implement work from an approved spec or ticket set, run focused and full tests, invoke code review, and commit the result to the current branch.
React and Next.js performance guidance for writing, reviewing, and refactoring production UI code.
--- name: alpaca-trading-backtest description: > Execute deterministic, reproducible historical backtests from a start date, end date, and strategy concept using the Alpaca CLI plus agent-written workspace code. Use when the user wants to backtest a strategy, simulate historical trades, or return trades, diagnostics, and reproducibility artifacts. ---
# Trading API Backtesting
Use this skill when you want your AI agent to run a specific historical backtest with the Alpaca CLI and local workspace code. This version is optimized for run-specific execution: your agent writes the minimum readable code needed for the confirmed strategy, stores the exact artifacts, and reports the results back to you.
This skill is written for you, the person invoking it through your AI agent. **You** means the trader, developer, researcher, or operator asking your agent to run the backtest. Your agent should address you directly, restate assumptions clearly, and make every interpretation choice visible.
```text strategy idea -> formalized rules -> confirmed assumptions -> CLI data fetch -> local script -> artifacts -> report ```
It is not a promise that a strategy will work in live markets. It is a reproducible research workflow.
## Required disclosures
Every report, `notes.md`, `report.md`, notebook, dashboard, or exported result should include:
> **Important disclosure** > This backtest is a hypothetical historical simulation and does not represent actual trading performance. Backtested results do not guarantee future results. Results depend on market-data quality, data feed selection, corporate-action handling, fees, slippage, liquidity, taxes, execution assumptions, and implementation details. This material is for research and educational purposes only and is not investment advice, a recommendation, an offer, or a solicitation to buy or sell securities, options, cryptocurrencies, or any other financial product. All investments involve risk and may lose value. Review Alpaca's disclosures and agreements at [alpaca.markets/disclosures](https://alpaca.markets/disclosures).
When paper trading appears in the workflow, add:
> Paper trading is a simulated environment. It does not involve real money or actual securities transactions. Paper results may differ from live trading because of fill assumptions, market impact, liquidity, latency, data differences, order handling, fees, and other market conditions.
When the backtest models Alpaca securities trading-activity fees, `notes.md`, `summary.json`, and `report.md` should link to the Alpaca Brokerage Fee Schedule PDF:
```text https://files.alpaca.markets/disclosures/library/BrokFeeSched.pdf ```
Record the PDF revision date, extraction timestamp, modeled fee categories, and any fee items intentionally excluded.
## CLI prerequisites
### Alpaca CLI
Your agent should use the Alpaca CLI for market-data access.
Check whether it is installed:
```bash alpaca version ```
Install with Go when needed:
```bash go install github.com/alpacahq/cli/cmd/alpaca@latest ```
On macOS or Linux with Homebrew:
```bash brew install alpacahq/tap/cli ```
Make sure the binary directory is on `PATH`, commonly `~/go/bin` for Go installs.
### Local execution permissions
Alpaca CLI commands should run in your local workspace where your Alpaca profile, environment variables, network access, and saved artifacts are available. Some agent runtimes express this as:
```text required_permissions: ["all"] ```
Use the equivalent permission model in your agent environment so the CLI can access local auth/config and write run artifacts.
### Connectivity and authentication check
Before any backtest run, verify the CLI and credentials:
```bash alpaca doctor ```
If authentication fails, your agent should stop the run and show you the available login/help command:
```bash alpaca profile login --help ```
For interactive paper setup:
```bash alpaca profile login ```
For API-key setup:
```bash alpaca profile login --api-key ```
For automation, environment variables are preferred because secrets do not need to be written into generated code:
```bash export ALPACA_API_KEY=PK... export ALPACA_SECRET_KEY=... export ALPACA_QUIET=1 ```
Your agent should never print your secret key, commit it to files, include it in reports, or pass it in a way that exposes it to shell history.
### Machine-readable output
Use `--quiet` for commands whose output will be parsed by code:
```bash alpaca account get --quiet alpaca data bars --symbol SPY --start 2024-01-01 --end 2024-12-31 --timeframe 1Day --quiet ```
Use installed CLI help and schemas as the source of truth for flags and response fields:
```bash alpaca --help-all alpaca data bars --help alpaca data bars --schema alpaca data quotes --schema ```
Because the CLI is generated from API specifications and may evolve, your agent should prefer current `--help`, `--schema`, and `alpaca doctor` output over stale examples.
## Required workflow
Your agent should follow this workflow:
1. Gather required inputs: start date, end date, strategy concept or strategy file. 2. Gather or infer the rest: asset class, symbols or universe, timeframe, initial cash, position sizing, feed, adjustment mode, execution assumptions, benchmark. 3. Work through [run considerations](#run-considerations-checklist): order simulation, indicators, dividends, splits, fees, slippage, spread, market hours, calendar handling, and validation. 4. Translate your freeform idea into precise mathematical rules. 5. Present the formalized interpretation to you before writing code unless your request was already mathematically precise. 6. Check the workspace for reusable data, prior runs, and existing utilities. 7. Create a self-contained run folder. 8. Write `notes.md`, `strategy_spec.json`, `config.json`, and a readable run-specific script. 9. Fetch historical data through the Alpaca CLI, save raw CLI outputs, filter to the chosen market hours, and compute data fingerprints. 10. Run the local simulation. 11. Write artifacts. 12. Return the Teaching Five, first/last trade, assumptions, caveats, data fingerprint, and artifact paths.
## Workspace awareness
Before generating new code or fetching data, your agent should inspect the workspace.
### Data reuse
Look for prior raw data files or cached normalized data that match:
```text symbol asset class feed adjustment mode timeframe start/end range calendar filter regular-hours or extended-hours setting ```
Reuse data only when the data fingerprint matches. If fingerprints differ, your agent should treat the runs as using different input data.
### Run lineage
If this run is a variant of a prior run, `notes.md` should say what changed:
```text changed RSI threshold from 30/70 to 25/75 changed fill model from next_open bar proxy to quote-aware fill changed slippage from 5 bps to 10 bps extended date range from 2020-2024 to 2018-2025 ```
### Existing code
If the workspace already has a backtest engine or shared utility that matches the strategy requirements, your agent may reuse it. Otherwise, the default is a single readable `run.py` in the run folder.
## Run folder and artifact contract
Artifact paths in this skill use `raw/` and `normalized/` as canonical names.
Every run should create a folder like:
```text runs/YYYY-MM-DD_symbol_strategy_timeframe/ notes.md strategy_spec.json config.json run.py requirements.txt or pyproject.toml when needed raw/ bars_SYMBOL.json quotes_SYMBOL.json trades_SYMBOL.json calendar.json corporate_actions.json normalized/ bars_SYMBOL.csv quotes_SYMBOL.csv summary.json report.md trades.csv round_trips.csv equity.csv benchmark_equity.csv data_fingerprint.json warnings.json fee_source.json ```
### `notes.md`
`notes.md` should include your original request, confirmed strategy interpretation, every inferred/defaulted assumption, indicator definitions, fill model, fee model, data feed and adjustment mode, dividend and split treatment, benchmark definitions, calendar and market-hours handling, warnings and caveats, and Alpaca disclosure and fee schedule links.
### Other artifacts
See [reference.md](reference.md) for `summary.json`, `strategy_spec.json`, `data_fingerprint.json`, and `fee_source.json` schemas.
## Code generation rules
For run-specific CLI backtests, your agent should generate a script, not a reusable framework. A single-file `run.py` is the default.
Use readable code:
```python fill_price = bar_open * (1 + friction_pct) ```
instead of compressed expressions that make the artifact hard to audit.
The generated code should:
- read raw or normalized files from the run folder; - implement the confirmed strategy exactly; - implement the chosen indicator definitions exactly (see [Indicator formulas](reference.md#indicator-formulas)); - keep signal timing separate from fill timing; - compute fees, slippage, spread, and settlement according to the confirmed assumptions; - produce all required artifacts; - include deterministic sorting and timezone handling; - avoid hidden network calls after data fetch unless explicitly documented.
Use Python 3 by default. Prefer the standard library plus pandas/numpy when available. Add dependencies only when they materially improve correctness or readability.
## Strategy translation
Your agent should formalize your idea before code generation.
Every rule should specify: data field, trigger, inclusive/exclusive bounds, indicator variant and parameters, warmup behavior, position sizing and rounding, cash handling, order type, fill model, and benchmark.
Example confirmation:
```text I interpreted your strategy as: - Symbol: SPY - Timeframe: 1Day - Data: Alpaca CLI bars, feed=sip, adjustment=split - Indicator: SMA(50) and SMA(200), simple arithmetic mean of completed daily closes - Entry: fast SMA crosses above slow SMA - Exit: fast SMA crosses below slow SMA - Signal timing: completed bar close - Fill timing: next trading day's open - Fill model: next_open bar proxy with 5 bps slippage unless quotes are available - Sizing: invest 100% of available cash, fractional shares allowed when supported - Benchmark: SPY buy-and-hold with same assumptions ```
After confirmation, code should match the confirmed interpretation.
## Fill models
Use these model names in confirmations and `notes.md`. Implementation detail is in [Fill model rules](reference.md#fill-model-rules).
- **`next_open`** (default): signal on bar T close; fill on bar T+1 open or quote at T+1 open timestamp. - **`time_based`**: fill at a confirmed time of day; quote bid/ask when available. - **`same_bar`**: only when explicitly requested; document look-ahead risk in `notes.md` and the report. - **Limit and stop orders**: OHLC-bar eligibility rules apply; use conservative intrabar conflict policy when stop and target both touch the same bar.
## Report format
`report.md` should lead with **Performance vs Benchmarks**:
```markdown | | Total Return | Ann. Return | Max Drawdown | Sharpe | Final Equity | |---|---:|---:|---:|---:|---:| | **Strategy** | ...% | ...% | ...% | ... | $... | | Benchmark | ...% | ...% | ...% | ... | $... | ```
After the table, include strategy configuration, symbols/timeframe/feed/adjustment, fill model and friction, first and last trade, detailed metrics, benchmark explanation, assumptions, data fingerprint, caveats, and the disclosure block.
Metric definitions are in [reference.md](reference.md#metric-formulas).
## In-chat response standard
Lead with the **Teaching Five**:
1. total return versus benchmark; 2. max drawdown; 3. number of trades; 4. win rate; 5. Sharpe ratio versus benchmark.
Then include: annualized return, profit factor, fees paid, first trade, last trade, assumptions made, data fingerprint summary, artifact paths, and most important caveats.
If no trades occurred, say that directly and explain whether this was due to warmup, no signal, insufficient
Source provenance
Decision snapshot
recent repository activity
Audit
Install and adoption review
Agent-proven evidence
Outcome reports after resolve, review, install, and one narrow run.
No agent outcome data yet. The first agent run can report success, setup needs, risk blocks, failure, or not-relevant through /api/agent/outcome.
Install
Free and open source. Review the report before installing into production agents.
Growth loop
Scenario-led draft for alpaca-trading-backtest, ready for a manual X post.
alpaca-trading-backtest: Execute deterministic, reproducible historical backtests from a start date, end date, and str... 142 stars https://www.openagentskill.com/skills/alpacahq-alpaca-trading-backtest?ref=x
Listing + install path for alpaca-trading-backtest: https://www.openagentskill.com/skills/alpacahq-alpaca-trading-backtest?ref=x Install: npx skills add alpacahq/alpaca-skills --skill alpaca-trading-backtest
Listing source
This listing was indexed from public sources and is not marked official until a maintainer claim is approved.
Attribution links to the public repository or creator profile. Creators can claim the listing to update ownership signals.
Claim this skillOwner claim
This Registry indexed listing is attributed to alpacahq but is not marked official yet. Claim it to add a verified owner signal and make future launch, install, and audit updates easier to trust.
Creator backlink kit
Show the canonical listing, current trust and audit signals, and real Agent-Proven evidence where developers evaluate the repository.
[](https://www.openagentskill.com/skills/alpacahq-alpaca-trading-backtest?ref=github&utm_source=github&utm_medium=referral&utm_campaign=creator_badge)
[](https://www.openagentskill.com/skills/alpacahq-alpaca-trading-backtest?ref=github&utm_source=github&utm_medium=referral&utm_campaign=creator_badge)
[](https://www.openagentskill.com/skills/alpacahq-alpaca-trading-backtest/audit)
[](https://www.openagentskill.com/skills/alpacahq-alpaca-trading-backtest?ref=github&utm_source=github&utm_medium=referral&utm_campaign=creator_badge)alpacahq
@alpacahq
Share whether this skill looks useful for your agent workflow. Aggregated feedback improves rankings over time.
Sandbox only
Code Review
Review a branch or diff against repository standards and the originating spec in two independent analysis passes.
168.6K StarsAppsmith
Platform to build admin panels, internal tools, and dashboards. Integrates with 25+ databases and any API.
40.8K StarsImplement
Implement work from an approved spec or ticket set, run focused and full tests, invoke code review, and commit the result to the current branch.
175.7K StarsVercel React Best Practices
React and Next.js performance guidance for writing, reviewing, and refactoring production UI code.
30.9K StarsSandbox only
Install targets
Codex install prompt
Install the "alpaca-trading-backtest" agent skill from https://github.com/alpacahq/alpaca-skills/tree/main/skills/trading-api/backtest. Read its SKILL.md or equivalent instructions first, install only the files needed for this workspace, and summarize any required setup before using it. Skill purpose: Execute deterministic, reproducible historical backtests from a start date, end date, and strategy concept using the Alpaca CLI plus agent-written workspace code. Use when the user wants to backtest a strategy, simulate historical trades, or return trades, diagnostics, and reproducibility artifacts. After the install attempt, report the result to https://www.openagentskill.com/api/agent/outcome with POST JSON {"event_id":"install_<unique-id>","skill_slug":"alpacahq-alpaca-trading-backtest","task":"Install alpaca-trading-backtest","agent":"codex","outcome":"success","install_used":true}. Replace event_id with a unique value and outcome with success or failed. Report success only after the skill is installed and a minimal verification passes.Supply asset profile
Code review, repo analysis, testing, CI, GitHub, DevOps, and developer workflow skills.
Scenario
Coding agents
I need a coding agent that can understand a repository, edit code, and review pull requests.
Agent fit
Claude Code + CLI + Codex
Codex, Claude Code, Cursor, CLI, or custom agents.
Install
Ready
npx skills add alpacahq/alpaca-skills --skill alpaca-trading-backtest
Maintenance
fresh
3d since push
Risk
Risky
Dependency or permission surface needs review
GitHub quality
142
68/100 Quality · 73/100 Trust
Coverage tags
Review notes
Dependency or permission surface needs review · Permission surface may require sandboxing
Agent adoption scorecard
These scores combine public repository metadata, OpenAgentSkill review signals, maintenance freshness, and install readiness. They are a shortlist signal, not a replacement for human review.
Quality
PromisingUseful candidate, but compare it with alternatives before adopting.
Trust
Sandbox onlyUseful candidate with missing or mixed trust signals. Keep it in an isolated workspace until the outcome loop proves task fit.
Audit
RiskyA machine-readable review of install readiness, security metadata, maintenance, and adoption risk.
OpenAgentSkill Trust Score v5
Run only in a sandbox and compare close alternatives before using it for real work.
Stars
142 GitHub stars
Repo activity
142 stars, 17 forks
Maintenance
3d since push
License
Apache-2.0
Install
npx skills add alpacahq/alpaca-skills --skill alpaca-trading-backtest
Install safety
Agent-readable metadata
Use this block or the embedded JSON to decide whether an agent should install this skill, choose an alternative, or ask for human review first.
Suited tasks
Suited agents
Install decision
Trust and risk
Outcome loop
Install command
npx skills add alpacahq/alpaca-skills --skill alpaca-trading-backtestDo not use when
Alternative
168.6K Stars
npx skills add mattpocock/skills --skill code-review
Alternative
40.8K Stars
npx skills add appsmithorg/appsmith
Alternative
175.7K Stars
npx skills add mattpocock/skills --skill implement
Alternative
30.9K Stars
npx skills add vercel-labs/agent-skills --skill vercel-react-best-practices
Agent safety v2
This skill should not be selected by an agent without explicit human security review.
Do not auto-install. Inspect the source, dependencies, and permission surface first.
high
Skill metadata references terminal, CLI, shell, subprocess, or command execution workflows.
medium
Skill likely fetches remote pages, APIs, repositories, or external services.
medium
Skill may read or write project files, documents, generated artifacts, or local workspace state.
high
Skill metadata references credentials, tokens, environment variables, or secret-bearing workflows.
Agent resolve plan
The Resolve API returns the selected skill, alternatives, safety policy, audit notes, install target, and copy-paste prompt an agent can follow without scraping this page.
Open JSON
/api/agent/resolve?task=Use%20alpaca-trading-backtest%20for%20an%20agent%20workflow&agent=codex&max_risk=medium
Resolve text
/api/agent/resolve?task=Use%20alpaca-trading-backtest%20for%20an%20agent%20workflow&agent=codex&max_risk=medium&format=text
Install handoff
/api/skills/alpacahq-alpaca-trading-backtest/install
Agent should check
Copy prompt
Task: Use alpaca-trading-backtest in this workspace.
Resolve first: https://www.openagentskill.com/api/agent/resolve?task=Use%20alpaca-trading-backtest%20for%20an%20agent%20workflow&agent=codex&max_risk=medium
Review install handoff: https://www.openagentskill.com/api/skills/alpacahq-alpaca-trading-backtest/install
Install command: npx skills add alpacahq/alpaca-skills --skill alpaca-trading-backtest
Before running it, summarize audit warnings, required permissions, and the fallback skill if install is risky.Agent handoff
Use the public install endpoint to fetch the command, safety checklist, target prompts, and canonical links for this skill.
Install handoff
/api/skills/alpacahq-alpaca-trading-backtest/install
LLM text format
/api/skills/alpacahq-alpaca-trading-backtest/install?format=text
Find alternatives
/api/skills/search?q=alpaca-trading-backtest&limit=3
Agent prompt
Use alpaca-trading-backtest for this task. Review https://www.openagentskill.com/api/skills/alpacahq-alpaca-trading-backtest/install, then install with: npx skills add alpacahq/alpaca-skills --skill alpaca-trading-backtestRegistry metadata
This page exposes the same decision, trust, audit, use-case, and install signals through the Registry API, so agents can rank this skill without scraping the UI.
Manifest
/api/registry/manifest/alpacahq-alpaca-trading-backtest
LLM text
/api/registry/manifest/alpacahq-alpaca-trading-backtest?format=text
Install alias
/api/registry/install/alpacahq-alpaca-trading-backtest
Recommend
/api/registry/recommend?task=Use%20alpaca-trading-backtest%20in%20an%20agent%20workflow&limit=3
Agent fit
Finance and quant
Use-case tags
Platforms
Claude Code
Audit report
A machine-readable review of install readiness, security metadata, maintenance, and adoption risk.
Agent decision cockpit
Prototype with this skill first; keep a fallback candidate ready.
Role in stack
Fallback candidate
Primary fit
Finance and quant
Trust label
Prototype first
Install path
Command ready
Use when
Evidence
review first
Implementation path
Trust profile
Useful candidate with missing or mixed trust signals. Keep it in an isolated workspace until the outcome loop proves task fit.
GitHub adoption
INFO142 GitHub stars
Stars/forks activity
CHECK142 stars, 17 forks; issue activity unavailable in current metadata
Recent maintenance
PASS3d since push
License clarity
PASSApache-2.0
Good signals
Review before install
Recommended action
Run only in a sandbox and compare close alternatives before using it for real work.
Quality profile
Useful candidate, but compare it with alternatives before adopting.
Workflow fit
Analyze markets
I need my agent to analyze markets, financial data, filings, portfolios, and quant strategies.
Build and ship code
I need a coding agent that can understand a repository, edit code, and review pull requests.
Investigate faster
I need my agent to research a topic, compare sources, and produce a concise report.
Workflow fit
Inspect, patch, and verify code
A workflow for software agents that inspect repositories, review pull requests, generate tests, and turn findings into shippable patches.
Find, compare, and synthesize
A workflow for agents that gather sources, compare claims, summarize long material, and draft useful research briefs.
Turn skills into distribution
A workflow for turning newly indexed skills into SEO briefs, social drafts, comparison pages, and reusable publishing workflows.
Alternative shortlist
Similar skills that may fit this task.
Review a branch or diff against repository standards and the originating spec in two independent analysis passes.
Platform to build admin panels, internal tools, and dashboards. Integrates with 25+ databases and any API.
Implement work from an approved spec or ticket set, run focused and full tests, invoke code review, and commit the result to the current branch.
React and Next.js performance guidance for writing, reviewing, and refactoring production UI code.
--- name: alpaca-trading-backtest description: > Execute deterministic, reproducible historical backtests from a start date, end date, and strategy concept using the Alpaca CLI plus agent-written workspace code. Use when the user wants to backtest a strategy, simulate historical trades, or return trades, diagnostics, and reproducibility artifacts. ---
# Trading API Backtesting
Use this skill when you want your AI agent to run a specific historical backtest with the Alpaca CLI and local workspace code. This version is optimized for run-specific execution: your agent writes the minimum readable code needed for the confirmed strategy, stores the exact artifacts, and reports the results back to you.
This skill is written for you, the person invoking it through your AI agent. **You** means the trader, developer, researcher, or operator asking your agent to run the backtest. Your agent should address you directly, restate assumptions clearly, and make every interpretation choice visible.
```text strategy idea -> formalized rules -> confirmed assumptions -> CLI data fetch -> local script -> artifacts -> report ```
It is not a promise that a strategy will work in live markets. It is a reproducible research workflow.
## Required disclosures
Every report, `notes.md`, `report.md`, notebook, dashboard, or exported result should include:
> **Important disclosure** > This backtest is a hypothetical historical simulation and does not represent actual trading performance. Backtested results do not guarantee future results. Results depend on market-data quality, data feed selection, corporate-action handling, fees, slippage, liquidity, taxes, execution assumptions, and implementation details. This material is for research and educational purposes only and is not investment advice, a recommendation, an offer, or a solicitation to buy or sell securities, options, cryptocurrencies, or any other financial product. All investments involve risk and may lose value. Review Alpaca's disclosures and agreements at [alpaca.markets/disclosures](https://alpaca.markets/disclosures).
When paper trading appears in the workflow, add:
> Paper trading is a simulated environment. It does not involve real money or actual securities transactions. Paper results may differ from live trading because of fill assumptions, market impact, liquidity, latency, data differences, order handling, fees, and other market conditions.
When the backtest models Alpaca securities trading-activity fees, `notes.md`, `summary.json`, and `report.md` should link to the Alpaca Brokerage Fee Schedule PDF:
```text https://files.alpaca.markets/disclosures/library/BrokFeeSched.pdf ```
Record the PDF revision date, extraction timestamp, modeled fee categories, and any fee items intentionally excluded.
## CLI prerequisites
### Alpaca CLI
Your agent should use the Alpaca CLI for market-data access.
Check whether it is installed:
```bash alpaca version ```
Install with Go when needed:
```bash go install github.com/alpacahq/cli/cmd/alpaca@latest ```
On macOS or Linux with Homebrew:
```bash brew install alpacahq/tap/cli ```
Make sure the binary directory is on `PATH`, commonly `~/go/bin` for Go installs.
### Local execution permissions
Alpaca CLI commands should run in your local workspace where your Alpaca profile, environment variables, network access, and saved artifacts are available. Some agent runtimes express this as:
```text required_permissions: ["all"] ```
Use the equivalent permission model in your agent environment so the CLI can access local auth/config and write run artifacts.
### Connectivity and authentication check
Before any backtest run, verify the CLI and credentials:
```bash alpaca doctor ```
If authentication fails, your agent should stop the run and show you the available login/help command:
```bash alpaca profile login --help ```
For interactive paper setup:
```bash alpaca profile login ```
For API-key setup:
```bash alpaca profile login --api-key ```
For automation, environment variables are preferred because secrets do not need to be written into generated code:
```bash export ALPACA_API_KEY=PK... export ALPACA_SECRET_KEY=... export ALPACA_QUIET=1 ```
Your agent should never print your secret key, commit it to files, include it in reports, or pass it in a way that exposes it to shell history.
### Machine-readable output
Use `--quiet` for commands whose output will be parsed by code:
```bash alpaca account get --quiet alpaca data bars --symbol SPY --start 2024-01-01 --end 2024-12-31 --timeframe 1Day --quiet ```
Use installed CLI help and schemas as the source of truth for flags and response fields:
```bash alpaca --help-all alpaca data bars --help alpaca data bars --schema alpaca data quotes --schema ```
Because the CLI is generated from API specifications and may evolve, your agent should prefer current `--help`, `--schema`, and `alpaca doctor` output over stale examples.
## Required workflow
Your agent should follow this workflow:
1. Gather required inputs: start date, end date, strategy concept or strategy file. 2. Gather or infer the rest: asset class, symbols or universe, timeframe, initial cash, position sizing, feed, adjustment mode, execution assumptions, benchmark. 3. Work through [run considerations](#run-considerations-checklist): order simulation, indicators, dividends, splits, fees, slippage, spread, market hours, calendar handling, and validation. 4. Translate your freeform idea into precise mathematical rules. 5. Present the formalized interpretation to you before writing code unless your request was already mathematically precise. 6. Check the workspace for reusable data, prior runs, and existing utilities. 7. Create a self-contained run folder. 8. Write `notes.md`, `strategy_spec.json`, `config.json`, and a readable run-specific script. 9. Fetch historical data through the Alpaca CLI, save raw CLI outputs, filter to the chosen market hours, and compute data fingerprints. 10. Run the local simulation. 11. Write artifacts. 12. Return the Teaching Five, first/last trade, assumptions, caveats, data fingerprint, and artifact paths.
## Workspace awareness
Before generating new code or fetching data, your agent should inspect the workspace.
### Data reuse
Look for prior raw data files or cached normalized data that match:
```text symbol asset class feed adjustment mode timeframe start/end range calendar filter regular-hours or extended-hours setting ```
Reuse data only when the data fingerprint matches. If fingerprints differ, your agent should treat the runs as using different input data.
### Run lineage
If this run is a variant of a prior run, `notes.md` should say what changed:
```text changed RSI threshold from 30/70 to 25/75 changed fill model from next_open bar proxy to quote-aware fill changed slippage from 5 bps to 10 bps extended date range from 2020-2024 to 2018-2025 ```
### Existing code
If the workspace already has a backtest engine or shared utility that matches the strategy requirements, your agent may reuse it. Otherwise, the default is a single readable `run.py` in the run folder.
## Run folder and artifact contract
Artifact paths in this skill use `raw/` and `normalized/` as canonical names.
Every run should create a folder like:
```text runs/YYYY-MM-DD_symbol_strategy_timeframe/ notes.md strategy_spec.json config.json run.py requirements.txt or pyproject.toml when needed raw/ bars_SYMBOL.json quotes_SYMBOL.json trades_SYMBOL.json calendar.json corporate_actions.json normalized/ bars_SYMBOL.csv quotes_SYMBOL.csv summary.json report.md trades.csv round_trips.csv equity.csv benchmark_equity.csv data_fingerprint.json warnings.json fee_source.json ```
### `notes.md`
`notes.md` should include your original request, confirmed strategy interpretation, every inferred/defaulted assumption, indicator definitions, fill model, fee model, data feed and adjustment mode, dividend and split treatment, benchmark definitions, calendar and market-hours handling, warnings and caveats, and Alpaca disclosure and fee schedule links.
### Other artifacts
See [reference.md](reference.md) for `summary.json`, `strategy_spec.json`, `data_fingerprint.json`, and `fee_source.json` schemas.
## Code generation rules
For run-specific CLI backtests, your agent should generate a script, not a reusable framework. A single-file `run.py` is the default.
Use readable code:
```python fill_price = bar_open * (1 + friction_pct) ```
instead of compressed expressions that make the artifact hard to audit.
The generated code should:
- read raw or normalized files from the run folder; - implement the confirmed strategy exactly; - implement the chosen indicator definitions exactly (see [Indicator formulas](reference.md#indicator-formulas)); - keep signal timing separate from fill timing; - compute fees, slippage, spread, and settlement according to the confirmed assumptions; - produce all required artifacts; - include deterministic sorting and timezone handling; - avoid hidden network calls after data fetch unless explicitly documented.
Use Python 3 by default. Prefer the standard library plus pandas/numpy when available. Add dependencies only when they materially improve correctness or readability.
## Strategy translation
Your agent should formalize your idea before code generation.
Every rule should specify: data field, trigger, inclusive/exclusive bounds, indicator variant and parameters, warmup behavior, position sizing and rounding, cash handling, order type, fill model, and benchmark.
Example confirmation:
```text I interpreted your strategy as: - Symbol: SPY - Timeframe: 1Day - Data: Alpaca CLI bars, feed=sip, adjustment=split - Indicator: SMA(50) and SMA(200), simple arithmetic mean of completed daily closes - Entry: fast SMA crosses above slow SMA - Exit: fast SMA crosses below slow SMA - Signal timing: completed bar close - Fill timing: next trading day's open - Fill model: next_open bar proxy with 5 bps slippage unless quotes are available - Sizing: invest 100% of available cash, fractional shares allowed when supported - Benchmark: SPY buy-and-hold with same assumptions ```
After confirmation, code should match the confirmed interpretation.
## Fill models
Use these model names in confirmations and `notes.md`. Implementation detail is in [Fill model rules](reference.md#fill-model-rules).
- **`next_open`** (default): signal on bar T close; fill on bar T+1 open or quote at T+1 open timestamp. - **`time_based`**: fill at a confirmed time of day; quote bid/ask when available. - **`same_bar`**: only when explicitly requested; document look-ahead risk in `notes.md` and the report. - **Limit and stop orders**: OHLC-bar eligibility rules apply; use conservative intrabar conflict policy when stop and target both touch the same bar.
## Report format
`report.md` should lead with **Performance vs Benchmarks**:
```markdown | | Total Return | Ann. Return | Max Drawdown | Sharpe | Final Equity | |---|---:|---:|---:|---:|---:| | **Strategy** | ...% | ...% | ...% | ... | $... | | Benchmark | ...% | ...% | ...% | ... | $... | ```
After the table, include strategy configuration, symbols/timeframe/feed/adjustment, fill model and friction, first and last trade, detailed metrics, benchmark explanation, assumptions, data fingerprint, caveats, and the disclosure block.
Metric definitions are in [reference.md](reference.md#metric-formulas).
## In-chat response standard
Lead with the **Teaching Five**:
1. total return versus benchmark; 2. max drawdown; 3. number of trades; 4. win rate; 5. Sharpe ratio versus benchmark.
Then include: annualized return, profit factor, fees paid, first trade, last trade, assumptions made, data fingerprint summary, artifact paths, and most important caveats.
If no trades occurred, say that directly and explain whether this was due to warmup, no signal, insufficient
Source provenance
Decision snapshot
recent repository activity
Audit
Install and adoption review
Agent-proven evidence
Outcome reports after resolve, review, install, and one narrow run.
No agent outcome data yet. The first agent run can report success, setup needs, risk blocks, failure, or not-relevant through /api/agent/outcome.
Install
Free and open source. Review the report before installing into production agents.
Growth loop
Scenario-led draft for alpaca-trading-backtest, ready for a manual X post.
alpaca-trading-backtest: Execute deterministic, reproducible historical backtests from a start date, end date, and str... 142 stars https://www.openagentskill.com/skills/alpacahq-alpaca-trading-backtest?ref=x
Listing + install path for alpaca-trading-backtest: https://www.openagentskill.com/skills/alpacahq-alpaca-trading-backtest?ref=x Install: npx skills add alpacahq/alpaca-skills --skill alpaca-trading-backtest
Listing source
This listing was indexed from public sources and is not marked official until a maintainer claim is approved.
Attribution links to the public repository or creator profile. Creators can claim the listing to update ownership signals.
Claim this skillOwner claim
This Registry indexed listing is attributed to alpacahq but is not marked official yet. Claim it to add a verified owner signal and make future launch, install, and audit updates easier to trust.
Creator backlink kit
Show the canonical listing, current trust and audit signals, and real Agent-Proven evidence where developers evaluate the repository.
[](https://www.openagentskill.com/skills/alpacahq-alpaca-trading-backtest?ref=github&utm_source=github&utm_medium=referral&utm_campaign=creator_badge)
[](https://www.openagentskill.com/skills/alpacahq-alpaca-trading-backtest?ref=github&utm_source=github&utm_medium=referral&utm_campaign=creator_badge)
[](https://www.openagentskill.com/skills/alpacahq-alpaca-trading-backtest/audit)
[](https://www.openagentskill.com/skills/alpacahq-alpaca-trading-backtest?ref=github&utm_source=github&utm_medium=referral&utm_campaign=creator_badge)alpacahq
@alpacahq
Share whether this skill looks useful for your agent workflow. Aggregated feedback improves rankings over time.
Sandbox only
Code Review
Review a branch or diff against repository standards and the originating spec in two independent analysis passes.
168.6K StarsAppsmith
Platform to build admin panels, internal tools, and dashboards. Integrates with 25+ databases and any API.
40.8K StarsImplement
Implement work from an approved spec or ticket set, run focused and full tests, invoke code review, and commit the result to the current branch.
175.7K StarsVercel React Best Practices
React and Next.js performance guidance for writing, reviewing, and refactoring production UI code.
30.9K StarsPermission surface
secrets or environment access, shell or command execution
Agent outcomes
No agent outcome data yet
Docs
Strong README/SKILL.md context
Risk summary
Install readiness
Permission surface
secrets or environment access, shell or command execution
Agent outcomes
No agent outcome data yet
Docs
Strong README/SKILL.md context
Risk summary
Install readiness
Permission surface
secrets or environment access, shell or command execution
Agent outcomes
No agent outcome data yet
Docs
Strong README/SKILL.md context
Risk summary
Install readiness
Permission surface
secrets or environment access, shell or command execution
Agent outcomes
No agent outcome data yet
Docs
Strong README/SKILL.md context
Risk summary
Install readiness