[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M78GRJYCZ0SQYPMRAKAF6P7A":3,"skill-same:01M78GRJYCZ0SQYPMRAKAF6P7A":51},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":27,"repositoryHtmlUrl":28,"repositoryHomepageUrl":6,"ownerHtmlUrl":29,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":30,"install":31,"resources":44},"01M78GRJYCZ0SQYPMRAKAF6P7A","alpaca-trading-backtest",null,"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.","xmkqv\u002Fmoney-tree","xmkqv","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F128587443?v=4","01M78GRH6EN49WZJ9HDHRRX4BZ","Adam M Wilson","01M78GRH7F85WS46E088A3V7C3",1,"MIT","https:\u002F\u002Fgithub.com\u002Fxmkqv\u002Fmoney-tree\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Falpaca-trading-backtest\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: alpaca-trading-backtest\ndescription: >\n  Execute deterministic, reproducible historical backtests from a start date,\n  end date, and strategy concept using the Alpaca CLI plus agent-written\n  workspace code. Use when the user wants to backtest a strategy, simulate\n  historical trades, or return trades, diagnostics, and reproducibility artifacts.\n---\n\n# Trading API Backtesting\n\nUse 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.\n\nThis 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.\n\n```text\nstrategy idea -> formalized rules -> confirmed assumptions -> CLI data fetch -> local script -> artifacts -> report\n```\n\nIt is not a promise that a strategy will work in live markets. It is a reproducible research workflow.\n\n## Required disclosures\n\nEvery report, `notes.md`, `report.md`, notebook, dashboard, or exported result should include:\n\n> **Important disclosure**  \n> 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\u002Fdisclosures](https:\u002F\u002Falpaca.markets\u002Fdisclosures).\n\nWhen paper trading appears in the workflow, add:\n\n> 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.\n\nWhen the backtest models Alpaca securities trading-activity fees, `notes.md`, `summary.json`, and `report.md` should link to the Alpaca Brokerage Fee Schedule PDF:\n\n```text\nhttps:\u002F\u002Ffiles.alpaca.markets\u002Fdisclosures\u002Flibrary\u002FBrokFeeSched.pdf\n```\n\nRecord the PDF revision date, extraction timestamp, modeled fee categories, and any fee items intentionally excluded.\n\n## CLI prerequisites\n\n### Alpaca CLI\n\nYour agent should use the Alpaca CLI for market-data access.\n\nCheck whether it is installed:\n\n```bash\nalpaca version\n```\n\nInstall with Go when needed:\n\n```bash\ngo install github.com\u002Falpacahq\u002Fcli\u002Fcmd\u002Falpaca@latest\n```\n\nOn macOS or Linux with Homebrew:\n\n```bash\nbrew install alpacahq\u002Ftap\u002Fcli\n```\n\nMake sure the binary directory is on `PATH`, commonly `~\u002Fgo\u002Fbin` for Go installs.\n\n### Local execution permissions\n\nAlpaca 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:\n\n```text\nrequired_permissions: [\"all\"]\n```\n\nUse the equivalent permission model in your agent environment so the CLI can access local auth\u002Fconfig and write run artifacts.\n\n### Connectivity and authentication check\n\nBefore any backtest run, verify the CLI and credentials:\n\n```bash\nalpaca doctor\n```\n\nIf authentication fails, your agent should stop the run and show you the available login\u002Fhelp command:\n\n```bash\nalpaca profile login --help\n```\n\nFor interactive paper setup:\n\n```bash\nalpaca profile login\n```\n\nFor API-key setup:\n\n```bash\nalpaca profile login --api-key\n```\n\nFor automation, environment variables are preferred because secrets do not need to be written into generated code:\n\n```bash\nexport ALPACA_API_KEY=PK...\nexport ALPACA_SECRET_KEY=...\nexport ALPACA_QUIET=1\n```\n\nYour 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.\n\n### Machine-readable output\n\nUse `--quiet` for commands whose output will be parsed by code:\n\n```bash\nalpaca account get --quiet\nalpaca data bars --symbol SPY --start 2024-01-01 --end 2024-12-31 --timeframe 1Day --quiet\n```\n\nUse installed CLI help and schemas as the source of truth for flags and response fields:\n\n```bash\nalpaca --help-all\nalpaca data bars --help\nalpaca data bars --schema\nalpaca data quotes --schema\n```\n\nBecause the CLI is generated from API specifications and may evolve, your agent should prefer current `--help`, `--schema`, and `alpaca doctor` output over stale examples.\n\n## Required workflow\n\nYour agent should follow this workflow:\n\n1. Gather required inputs: start date, end date, strategy concept or strategy file.\n2. Gather or infer the rest: asset class, symbols or universe, timeframe, initial cash, position sizing, feed, adjustment mode, execution assumptions, benchmark.\n3. Work through [run considerations](#run-considerations-checklist): order simulation, indicators, dividends, splits, fees, slippage, spread, market hours, calendar handling, and validation.\n4. Translate your freeform idea into precise mathematical rules.\n5. Present the formalized interpretation to you before writing code unless your request was already mathematically precise.\n6. Check the workspace for reusable data, prior runs, and existing utilities.\n7. Create a self-contained run folder.\n8. Write `notes.md`, `strategy_spec.json`, `config.json`, and a readable run-specific script.\n9. Fetch historical data through the Alpaca CLI, save raw CLI outputs, filter to the chosen market hours, and compute data fingerprints.\n10. Run the local simulation.\n11. Write artifacts.\n12. Return the Teaching Five, first\u002Flast trade, assumptions, caveats, data fingerprint, and artifact paths.\n\n## Workspace awareness\n\nBefore generating new code or fetching data, your agent should inspect the workspace.\n\n### Data reuse\n\nLook for prior raw data files or cached normalized data that match:\n\n```text\nsymbol\nasset class\nfeed\nadjustment mode\ntimeframe\nstart\u002Fend range\ncalendar filter\nregular-hours or extended-hours setting\n```\n\nReuse data only when the data fingerprint matches. If fingerprints differ, your agent should treat the runs as using different input data.\n\n### Run lineage\n\nIf this run is a variant of a prior run, `notes.md` should say what changed:\n\n```text\nchanged RSI threshold from 30\u002F70 to 25\u002F75\nchanged fill model from next_open bar proxy to quote-aware fill\nchanged slippage from 5 bps to 10 bps\nextended date range from 2020-2024 to 2018-2025\n```\n\n### Existing code\n\nIf 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.\n\n## Run folder and artifact contract\n\nArtifact paths in this skill use `raw\u002F` and `normalized\u002F` as canonical names.\n\nEvery run should create a folder like:\n\n```text\nruns\u002FYYYY-MM-DD_symbol_strategy_timeframe\u002F\n  notes.md\n  strategy_spec.json\n  config.json\n  run.py\n  requirements.txt or pyproject.toml when needed\n  raw\u002F\n    bars_SYMBOL.json\n    quotes_SYMBOL.json\n    trades_SYMBOL.json\n    calendar.json\n    corporate_actions.json\n  normalized\u002F\n    bars_SYMBOL.csv\n    quotes_SYMBOL.csv\n  summary.json\n  report.md\n  trades.csv\n  round_trips.csv\n  equity.csv\n  benchmark_equity.csv\n  data_fingerprint.json\n  warnings.json\n  fee_source.json\n```\n\n### `notes.md`\n\n`notes.md` should include your original request, confirmed strategy interpretation, every inferred\u002Fdefaulted 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.\n\n### Other artifacts\n\nSee [reference.md](reference.md) for `summary.json`, `strategy_spec.json`, `data_fingerprint.json`, and `fee_source.json` schemas.\n\n## Code generation rules\n\nFor run-specific CLI backtests, your agent should generate a script, not a reusable framework. A single-file `run.py` is the default.\n\nUse readable code:\n\n```python\nfill_price = bar_open * (1 + friction_pct)\n```\n\ninstead of compressed expressions that make the artifact hard to audit.\n\nThe generated code should:\n\n- read raw or normalized files from the run folder;\n- implement the confirmed strategy exactly;\n- implement the chosen indicator definitions exactly (see [Indicator formulas](reference.md#indicator-formulas));\n- keep signal timing separate from fill timing;\n- compute fees, slippage, spread, and settlement according to the confirmed assumptions;\n- produce all required artifacts;\n- include deterministic sorting and timezone handling;\n- avoid hidden network calls after data fetch unless explicitly documented.\n\nUse Python 3 by default. Prefer the standard library plus pandas\u002Fnumpy when available. Add dependencies only when they materially improve correctness or readability.\n\n## Strategy translation\n\nYour agent should formalize your idea before code generation.\n\nEvery rule should specify: data field, trigger, inclusive\u002Fexclusive bounds, indicator variant and parameters, warmup behavior, position sizing and rounding, cash handling, order type, fill model, and benchmark.\n\nExample confirmation:\n\n```text\nI interpreted your strategy as:\n- Symbol: SPY\n- Timeframe: 1Day\n- Data: Alpaca CLI bars, feed=sip, adjustment=split\n- Indicator: SMA(50) and SMA(200), simple arithmetic mean of completed daily closes\n- Entry: fast SMA crosses above slow SMA\n- Exit: fast SMA crosses below slow SMA\n- Signal timing: completed bar close\n- Fill timing: next trading day's open\n- Fill model: next_open bar proxy with 5 bps slippage unless quotes are available\n- Sizing: invest 100% of available cash, fractional shares allowed when supported\n- Benchmark: SPY buy-and-hold with same assumptions\n```\n\nAfter confirmation, code should match the confirmed interpretation.\n\n## Fill models\n\nUse these model names in confirmations and `notes.md`. Implementation detail is in [Fill model rules](reference.md#fill-model-rules).\n\n- **`next_open`** (default): signal on bar T close; fill on bar T+1 open or quote at T+1 open timestamp.\n- **`time_based`**: fill at a confirmed time of day; quote bid\u002Fask when available.\n- **`same_bar`**: only when explicitly requested; document look-ahead risk in `notes.md` and the report.\n- **Limit and stop orders**: OHLC-bar eligibility rules apply; use conservative intrabar conflict policy when stop and target both touch the same bar.\n\n## Report format\n\n`report.md` should lead with **Performance vs Benchmarks**:\n\n```markdown\n| | Total Return | Ann. Return | Max Drawdown | Sharpe | Final Equity |\n|---|---:|---:|---:|---:|---:|\n| **Strategy** | ...% | ...% | ...% | ... | $... |\n| Benchmark | ...% | ...% | ...% | ... | $... |\n```\n\nAfter the table, include strategy configuration, symbols\u002Ftimeframe\u002Ffeed\u002Fadjustment, fill model and friction, first and last trade, detailed metrics, benchmark explanation, assumptions, data fingerprint, caveats, and the disclosure block.\n\nMetric definitions are in [reference.md](reference.md#metric-formulas).\n\n## In-chat response standard\n\nLead with the **Teaching Five**:\n\n1. total return versus benchmark;\n2. max drawdown;\n3. number of trades;\n4. win rate;\n5. Sharpe ratio versus benchmark.\n\nThen include: annualized return, profit factor, fees paid, first trade, last trade, assumptions made, data fingerprint summary, artifact paths, and most important caveats.\n\nIf no trades occurred, say that directly and explain whether this was due to warmup, no signal, insufficient cash, missing data, or calendar filtering.\n\n## Run considerations checklist\n\nYour agent should resolve each item before running:\n\n- order simulation and fill timing;\n- quote-aware versus bar-proxy fills;\n- dividend handling;\n- split and reverse-split handling;\n- execution friction;\n- PDF-derived trading-activity fees;\n- market hours and extended-hours inclusion;\n- calendar-based decisions;\n- benchmark choice;\n- look-ahead bias;\n- survivorship bias;\n- out-of-sample or walk-forward validation for parameter tuning;\n- overfitting risk for repeated variants.\n\nFor order simulation, dividends, splits, fees, calendar, and benchmarks, document choices in `notes.md` when not specified by you.\n\n## Safety and quality guardrails\n\nYour agent must avoid:\n\n- using future data in signal generation;\n- using same-bar decision and fill without a documented `same_bar` model and warning;\n- hiding execution assumptions;\n- mixing adjusted bars with separate split adjustments;\n- pretending vague rules were fully specified;\n- discarding generated code after the run;\n- including extended-hours bars unless you requested them;\n- silently substituting indicator variants;\n- treating open, close, high, low, VWAP, and quote-derived prices as interchangeable fill proxies;\n- computing Sharpe from per-bar returns when the report says daily Sharpe;\n- using population standard deviation for Sharpe when sample standard deviation (N-1) is required;\n- submitting live orders as part of a historical backtest;\n- claiming support for unsupported products — options require explicit contract selection and fill logic;\n- bypassing the Alpaca CLI by switching to direct HTTP calls;\n- running Alpaca CLI commands in a sandbox without local auth and filesystem access;\n- implementing fill logic that deviates from [Fill model rules](reference.md#fill-model-rules) without documenting the deviation in `notes.md`;\n- using `close` vs `high` vs `low` interchangeably for signal triggers;\n- silently choosing between crossover and threshold signal logic;\n- generating a multi-module engine when a single-file script will do.\n\n## Optional paper forward-validation handoff\n\nAfter a historical backtest, your agent may prepare a paper forward-validation package if you request it:\n\n```text\npaper_config.json\nstrategy_runtime.py\nrisk_limits.json\nalpaca_order_adapter.py\nreconciliation_plan.md\n```\n\nThis is separate from the historical backtest. It should use explicit risk limits, client order IDs for automation, and reconciliation of expected versus actual paper fills.\n\n## Troubleshooting\n\n```text\ncommand not found: alpaca\n  Check PATH and Go install location, commonly ~\u002Fgo\u002Fbin.\n\nalpaca doctor reports auth failure\n  Re-run alpaca profile login or set ALPACA_API_KEY and ALPACA_SECRET_KEY.\n\nCLI output includes non-data text\n  Use --quiet or set ALPACA_QUIET=1.\n\nParsed fields changed\n  Run \u003Ccommand> --schema and update the parser for the current CLI response.\n\nRate limited\n  Respect Retry-After, reduce request frequency, and use cached data where fingerprints match.\n\nPagination missing data\n  Check next_page_token and fetch all pages.\n```\n\n## Related references\n\nUseful commands:\n\n```bash\nalpaca version\nalpaca update --check --quiet\nalpaca doctor\nalpaca --help-all\nalpaca data bars --help\nalpaca data bars --schema\nalpaca data quotes --schema\nalpaca calendar --help\n```\n\nDisclosure links:\n\n```text\nhttps:\u002F\u002Falpaca.markets\u002Fdisclosures\nhttps:\u002F\u002Ffiles.alpaca.markets\u002Fdisclosures\u002Flibrary\u002FBrokFeeSched.pdf\n```\n\nCLI data acquisition, indicator formulas, fee model, metrics, benchmarks, and JSON schemas: [reference.md](reference.md).\n\n## Related files\n\n- [reference.md](reference.md)\n","# Trading API Backtesting\n\nUse 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.\n\nThis 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.\n\n```text\nstrategy idea -> formalized rules -> confirmed assumptions -> CLI data fetch -> local script -> artifacts -> report\n```\n\nIt is not a promise that a strategy will work in live markets. It is a reproducible research workflow.\n\n## Required disclosures\n\nEvery report, `notes.md`, `report.md`, notebook, dashboard, or exported result should include:\n\n> **Important disclosure**  \n> 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\u002Fdisclosures](https:\u002F\u002Falpaca.markets\u002Fdisclosures).\n\nWhen paper trading appears in the workflow, add:\n\n> 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.\n\nWhen the backtest models Alpaca securities trading-activity fees, `notes.md`, `summary.json`, and `report.md` should link to the Alpaca Brokerage Fee Schedule PDF:\n\n```text\nhttps:\u002F\u002Ffiles.alpaca.markets\u002Fdisclosures\u002Flibrary\u002FBrokFeeSched.pdf\n```\n\nRecord the PDF revision date, extraction timestamp, modeled fee categories, and any fee items intentionally excluded.\n\n## CLI prerequisites\n\n### Alpaca CLI\n\nYour agent should use the Alpaca CLI for market-data access.\n\nCheck whether it is installed:\n\n```bash\nalpaca version\n```\n\nInstall with Go when needed:\n\n```bash\ngo install github.com\u002Falpacahq\u002Fcli\u002Fcmd\u002Falpaca@latest\n```\n\nOn macOS or Linux with Homebrew:\n\n```bash\nbrew install alpacahq\u002Ftap\u002Fcli\n```\n\nMake sure the binary directory is on `PATH`, commonly `~\u002Fgo\u002Fbin` for Go installs.\n\n### Local execution permissions\n\nAlpaca 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:\n\n```text\nrequired_permissions: [\"all\"]\n```\n\nUse the equivalent permission model in your agent environment so the CLI can access local auth\u002Fconfig and write run artifacts.\n\n### Connectivity and authentication check\n\nBefore any backtest run, verify the CLI and credentials:\n\n```bash\nalpaca doctor\n```\n\nIf authentication fails, your agent should stop the run and show you the available login\u002Fhelp command:\n\n```bash\nalpaca profile login --help\n```\n\nFor interactive paper setup:\n\n```bash\nalpaca profile login\n```\n\nFor API-key setup:\n\n```bash\nalpaca profile login --api-key\n```\n\nFor automation, environment variables are preferred because secrets do not need to be written into generated code:\n\n```bash\nexport ALPACA_API_KEY=PK...\nexport ALPACA_SECRET_KEY=...\nexport ALPACA_QUIET=1\n```\n\nYour 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.\n\n### Machine-readable output\n\nUse `--quiet` for commands whose output will be parsed by code:\n\n```bash\nalpaca account get --quiet\nalpaca data bars --symbol SPY --start 2024-01-01 --end 2024-12-31 --timeframe 1Day --quiet\n```\n\nUse installed CLI help and schemas as the source of truth for flags and response fields:\n\n```bash\nalpaca --help-all\nalpaca data bars --help\nalpaca data bars --schema\nalpaca data quotes --schema\n```\n\nBecause the CLI is generated from API specifications and may evolve, your agent should prefer current `--help`, `--schema`, and `alpaca doctor` output over stale examples.\n\n## Required workflow\n\nYour agent should follow this workflow:\n\n1. Gather required inputs: start date, end date, strategy concept or strategy file.\n2. Gather or infer the rest: asset class, symbols or universe, timeframe, initial cash, position sizing, feed, adjustment mode, execution assumptions, benchmark.\n3. Work through [run considerations](#run-considerations-checklist): order simulation, indicators, dividends, splits, fees, slippage, spread, market hours, calendar handling, and validation.\n4. Translate your freeform idea into precise mathematical rules.\n5. Present the formalized interpretation to you before writing code unless your request was already mathematically precise.\n6. Check the workspace for reusable data, prior runs, and existing utilities.\n7. Create a self-contained run folder.\n8. Write `notes.md`, `strategy_spec.json`, `config.json`, and a readable run-specific script.\n9. Fetch historical data through the Alpaca CLI, save raw CLI outputs, filter to the chosen market hours, and compute data fingerprints.\n10. Run the local simulation.\n11. Write artifacts.\n12. Return the Teaching Five, first\u002Flast trade, assumptions, caveats, data fingerprint, and artifact paths.\n\n## Workspace awareness\n\nBefore generating new code or fetching data, your agent should inspect the workspace.\n\n### Data reuse\n\nLook for prior raw data files or cached normalized data that match:\n\n```text\nsymbol\nasset class\nfeed\nadjustment mode\ntimeframe\nstart\u002Fend range\ncalendar filter\nregular-hours or extended-hours setting\n```\n\nReuse data only when the data fingerprint matches. If fingerprints differ, your agent should treat the runs as using different input data.\n\n### Run lineage\n\nIf this run is a variant of a prior run, `notes.md` should say what changed:\n\n```text\nchanged RSI threshold from 30\u002F70 to 25\u002F75\nchanged fill model from next_open bar proxy to quote-aware fill\nchanged slippage from 5 bps to 10 bps\nextended date range from 2020-2024 to 2018-2025\n```\n\n### Existing code\n\nIf 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.\n\n## Run folder and artifact contract\n\nArtifact paths in this skill use `raw\u002F` and `normalized\u002F` as canonical names.\n\nEvery run should create a folder like:\n\n```text\nruns\u002FYYYY-MM-DD_symbol_strategy_timeframe\u002F\n  notes.md\n  strategy_spec.json\n  config.json\n  run.py\n  requirements.txt or pyproject.toml when needed\n  raw\u002F\n    bars_SYMBOL.json\n    quotes_SYMBOL.json\n    trades_SYMBOL.json\n    calendar.json\n    corporate_actions.json\n  normalized\u002F\n    bars_SYMBOL.csv\n    quotes_SYMBOL.csv\n  summary.json\n  report.md\n  trades.csv\n  round_trips.csv\n  equity.csv\n  benchmark_equity.csv\n  data_fingerprint.json\n  warnings.json\n  fee_source.json\n```\n\n### `notes.md`\n\n`notes.md` should include your original request, confirmed strategy interpretation, every inferred\u002Fdefaulted 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.\n\n### Other artifacts\n\nSee [reference.md](reference.md) for `summary.json`, `strategy_spec.json`, `data_fingerprint.json`, and `fee_source.json` schemas.\n\n## Code generation rules\n\nFor run-specific CLI backtests, your agent should generate a script, not a reusable framework. A single-file `run.py` is the default.\n\nUse readable code:\n\n```python\nfill_price = bar_open * (1 + friction_pct)\n```\n\ninstead of compressed expressions that make the artifact hard to audit.\n\nThe generated code should:\n\n- read raw or normalized files from the run folder;\n- implement the confirmed strategy exactly;\n- implement the chosen indicator definitions exactly (see [Indicator formulas](reference.md#indicator-formulas));\n- keep signal timing separate from fill timing;\n- compute fees, slippage, spread, and settlement according to the confirmed assumptions;\n- produce all required artifacts;\n- include deterministic sorting and timezone handling;\n- avoid hidden network calls after data fetch unless explicitly documented.\n\nUse Python 3 by default. Prefer the standard library plus pandas\u002Fnumpy when available. Add dependencies only when they materially improve correctness or readability.\n\n## Strategy translation\n\nYour agent should formalize your idea before code generation.\n\nEvery rule should specify: data field, trigger, inclusive\u002Fexclusive bounds, indicator variant and parameters, warmup behavior, position sizing and rounding, cash handling, order type, fill model, and benchmark.\n\nExample confirmation:\n\n```text\nI interpreted your strategy as:\n- Symbol: SPY\n- Timeframe: 1Day\n- Data: Alpaca CLI bars, feed=sip, adjustment=split\n- Indicator: SMA(50) and SMA(200), simple arithmetic mean of completed daily closes\n- Entry: fast SMA crosses above slow SMA\n- Exit: fast SMA crosses below slow SMA\n- Signal timing: completed bar close\n- Fill timing: next trading day's open\n- Fill model: next_open bar proxy with 5 bps slippage unless quotes are available\n- Sizing: invest 100% of available cash, fractional shares allowed when supported\n- Benchmark: SPY buy-and-hold with same assumptions\n```\n\nAfter confirmation, code should match the confirmed interpretation.\n\n## Fill models\n\nUse these model names in confirmations and `notes.md`. Implementation detail is in [Fill model rules](reference.md#fill-model-rules).\n\n- **`next_open`** (default): signal on bar T close; fill on bar T+1 open or quote at T+1 open timestamp.\n- **`time_based`**: fill at a confirmed time of day; quote bid\u002Fask when available.\n- **`same_bar`**: only when explicitly requested; document look-ahead risk in `notes.md` and the report.\n- **Limit and stop orders**: OHLC-bar eligibility rules apply; use conservative intrabar conflict policy when stop and target both touch the same bar.\n\n## Report format\n\n`report.md` should lead with **Performance vs Benchmarks**:\n\n```markdown\n| | Total Return | Ann. Return | Max Drawdown | Sharpe | Final Equity |\n|---|---:|---:|---:|---:|---:|\n| **Strategy** | ...% | ...% | ...% | ... | $... |\n| Benchmark | ...% | ...% | ...% | ... | $... |\n```\n\nAfter the table, include strategy configuration, symbols\u002Ftimeframe\u002Ffeed\u002Fadjustment, fill model and friction, first and last trade, detailed metrics, benchmark explanation, assumptions, data fingerprint, caveats, and the disclosure block.\n\nMetric definitions are in [reference.md](reference.md#metric-formulas).\n\n## In-chat response standard\n\nLead with the **Teaching Five**:\n\n1. total return versus benchmark;\n2. max drawdown;\n3. number of trades;\n4. win rate;\n5. Sharpe ratio versus benchmark.\n\nThen include: annualized return, profit factor, fees paid, first trade, last trade, assumptions made, data fingerprint summary, artifact paths, and most important caveats.\n\nIf no trades occurred, say that directly and explain whether this was due to warmup, no signal, insufficient cash, missing data, or calendar filtering.\n\n## Run considerations checklist\n\nYour agent should resolve each item before running:\n\n- order simulation and fill timing;\n- quote-aware versus bar-proxy fills;\n- dividend handling;\n- split and reverse-split handling;\n- execution friction;\n- PDF-derived trading-activity fees;\n- market hours and extended-hours inclusion;\n- calendar-based decisions;\n- benchmark choice;\n- look-ahead bias;\n- survivorship bias;\n- out-of-sample or walk-forward validation for parameter tuning;\n- overfitting risk for repeated variants.\n\nFor order simulation, dividends, splits, fees, calendar, and benchmarks, document choices in `notes.md` when not specified by you.\n\n## Safety and quality guardrails\n\nYour agent must avoid:\n\n- using future data in signal generation;\n- using same-bar decision and fill without a documented `same_bar` model and warning;\n- hiding execution assumptions;\n- mixing adjusted bars with separate split adjustments;\n- pretending vague rules were fully specified;\n- discarding generated code after the run;\n- including extended-hours bars unless you requested them;\n- silently substituting indicator variants;\n- treating open, close, high, low, VWAP, and quote-derived prices as interchangeable fill proxies;\n- computing Sharpe from per-bar returns when the report says daily Sharpe;\n- using population standard deviation for Sharpe when sample standard deviation (N-1) is required;\n- submitting live orders as part of a historical backtest;\n- claiming support for unsupported products — options require explicit contract selection and fill logic;\n- bypassing the Alpaca CLI by switching to direct HTTP calls;\n- running Alpaca CLI commands in a sandbox without local auth and filesystem access;\n- implementing fill logic that deviates from [Fill model rules](reference.md#fill-model-rules) without documenting the deviation in `notes.md`;\n- using `close` vs `high` vs `low` interchangeably for signal triggers;\n- silently choosing between crossover and threshold signal logic;\n- generating a multi-module engine when a single-file script will do.\n\n## Optional paper forward-validation handoff\n\nAfter a historical backtest, your agent may prepare a paper forward-validation package if you request it:\n\n```text\npaper_config.json\nstrategy_runtime.py\nrisk_limits.json\nalpaca_order_adapter.py\nreconciliation_plan.md\n```\n\nThis is separate from the historical backtest. It should use explicit risk limits, client order IDs for automation, and reconciliation of expected versus actual paper fills.\n\n## Troubleshooting\n\n```text\ncommand not found: alpaca\n  Check PATH and Go install location, commonly ~\u002Fgo\u002Fbin.\n\nalpaca doctor reports auth failure\n  Re-run alpaca profile login or set ALPACA_API_KEY and ALPACA_SECRET_KEY.\n\nCLI output includes non-data text\n  Use --quiet or set ALPACA_QUIET=1.\n\nParsed fields changed\n  Run \u003Ccommand> --schema and update the parser for the current CLI response.\n\nRate limited\n  Respect Retry-After, reduce request frequency, and use cached data where fingerprints match.\n\nPagination missing data\n  Check next_page_token and fetch all pages.\n```\n\n## Related references\n\nUseful commands:\n\n```bash\nalpaca version\nalpaca update --check --quiet\nalpaca doctor\nalpaca --help-all\nalpaca data bars --help\nalpaca data bars --schema\nalpaca data quotes --schema\nalpaca calendar --help\n```\n\nDisclosure links:\n\n```text\nhttps:\u002F\u002Falpaca.markets\u002Fdisclosures\nhttps:\u002F\u002Ffiles.alpaca.markets\u002Fdisclosures\u002Flibrary\u002FBrokFeeSched.pdf\n```\n\nCLI data acquisition, indicator formulas, fee model, metrics, benchmarks, and JSON schemas: [reference.md](reference.md).\n\n## Related files\n\n- [reference.md](reference.md)\n",{"name":5,"description":7},"main","37948d6dfd82e249d48d438951b9455d07aaa525",".claude\u002Fskills\u002Falpaca-trading-backtest",0,"https:\u002F\u002Fgithub.com\u002Fxmkqv\u002Fmoney-tree","https:\u002F\u002Fgithub.com\u002Fxmkqv","2026-11-09 02:48:26",{"source":8,"skillName":5,"commands":32,"prompt":42,"zipAvailable":43},[33,36,39],{"tool":34,"command":35},"npx","npx skills add xmkqv\u002Fmoney-tree --skill alpaca-trading-backtest",{"tool":37,"command":38},"bunx","bunx skills add xmkqv\u002Fmoney-tree --skill alpaca-trading-backtest",{"tool":40,"command":41},"pnpm","pnpm dlx skills add xmkqv\u002Fmoney-tree --skill alpaca-trading-backtest","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fxmkqv\u002Fmoney-tree\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Falpaca-trading-backtest\u002FSKILL.md",true,[45],{"path":46,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":49,"sourceHtmlUrl":50},"reference.md","REFERENCE","参考文档",11531,"https:\u002F\u002Fgithub.com\u002Fxmkqv\u002Fmoney-tree\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Falpaca-trading-backtest\u002Freference.md",[52,59,65,71,77,83],{"skillNo":53,"name":54,"nameZh":6,"description":55,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":56,"categories":57,"keywords":58,"publishedAt":19},"01M78GTDKY70YF1SM5R68NHTBR","util","only-if-asked","https:\u002F\u002Fgithub.com\u002Fxmkqv\u002Fmoney-tree\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Futil\u002FSKILL.md",[],[],{"skillNo":60,"name":61,"nameZh":6,"description":55,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":62,"categories":63,"keywords":64,"publishedAt":19},"01M78GTB9KXMSF9N3SQ0V2ME2K","use-docs","https:\u002F\u002Fgithub.com\u002Fxmkqv\u002Fmoney-tree\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fuse-docs\u002FSKILL.md",[],[],{"skillNo":66,"name":67,"nameZh":6,"description":55,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":68,"categories":69,"keywords":70,"publishedAt":19},"01M78GT9FP67P1MY0Q6WMDKMD2","use-command","https:\u002F\u002Fgithub.com\u002Fxmkqv\u002Fmoney-tree\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fuse-command\u002FSKILL.md",[],[],{"skillNo":72,"name":73,"nameZh":6,"description":55,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":74,"categories":75,"keywords":76,"publishedAt":19},"01M78GT6TPHEWRS56XZCCZWANE","use-cli","https:\u002F\u002Fgithub.com\u002Fxmkqv\u002Fmoney-tree\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fuse-cli\u002FSKILL.md",[],[],{"skillNo":78,"name":79,"nameZh":6,"description":55,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":80,"categories":81,"keywords":82,"publishedAt":19},"01M78GT5BFTG07VV5GPS6WF759","use-checklist","https:\u002F\u002Fgithub.com\u002Fxmkqv\u002Fmoney-tree\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fuse-checklist\u002FSKILL.md",[],[],{"skillNo":84,"name":85,"nameZh":6,"description":55,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":86,"categories":87,"keywords":88,"publishedAt":19},"01M78GT47BMEF6QHD5ASMW53P7","solo","https:\u002F\u002Fgithub.com\u002Fxmkqv\u002Fmoney-tree\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fsolo\u002FSKILL.md",[],[]]