alpaca
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseWhat this is
这是什么
☁️ Cloud broker — Alpaca exposes a public REST API, so this runs directly in the Starchild container, no local gateway needed. US equities and ETFs.
Paper and live are fully separated: different key pairs, different hosts ( vs ). A paper key physically cannot touch the live account. Live order placement additionally requires the flag.
paper-api.alpaca.marketsapi.alpaca.markets--confirm-live☁️ 云经纪商 — Alpaca提供公开的REST API,因此该工具可直接在Starchild容器中运行,无需本地网关。支持美股与ETF交易。
模拟账户与实盘账户完全分离:不同的密钥对、不同的主机地址( vs )。模拟账户密钥无法访问实盘账户。实盘下单额外需要添加参数。
paper-api.alpaca.marketsapi.alpaca.markets--confirm-liveGet your API keys
获取API密钥
- Sign up at alpaca.markets (US brokerage; paper trading is free and needs no funding).
- Paper keys: log in → switch to Paper Trading (toggle top-left) → Home → "API Keys" panel → Generate New Keys. Copy the Key ID and Secret Key (secret shown once).
- Live keys (optional, real money): switch to Live Trading → same API Keys panel → generate. These are a different pair from paper.
- Market data: the free IEX feed works out of the box. SIP (full-market) needs a paid data subscription.
- 在alpaca.markets注册(美国经纪商;模拟交易免费,无需入金)。
- 模拟密钥:登录 → 切换至Paper Trading(模拟交易)(左上角切换按钮)→ 主页 → "API密钥"面板 → 生成新密钥。复制Key ID和Secret Key(密钥仅显示一次)。
- 实盘密钥(可选,涉及真实资金):切换至Live Trading(实盘交易) → 同样在API密钥面板 → 生成密钥。这与模拟密钥是不同的密钥对。
- 市场数据:免费的IEX数据源可直接使用。SIP(全市场)数据源需要付费订阅。
Configure (.env)
配置(.env)
Request via secure input — never paste keys in chat. Variables:
| Variable | Required | Notes |
|---|---|---|
| yes (paper) | paper Key ID |
| yes (paper) | paper Secret |
| only for live | live Key ID |
| only for live | live Secret |
| no | |
通过安全输入方式请求密钥——切勿在聊天框中粘贴密钥。变量说明:
| 变量 | 是否必填 | 备注 |
|---|---|---|
| 是(模拟账户) | 模拟账户的Key ID |
| 是(模拟账户) | 模拟账户的密钥 |
| 仅实盘账户需要 | 实盘账户的Key ID |
| 仅实盘账户需要 | 实盘账户的密钥 |
| 否 | |
Usage
使用方法
pip install alpaca-pypaperbash
python skills/alpaca/scripts/alpaca_cli.py status
python skills/alpaca/scripts/alpaca_cli.py account
python skills/alpaca/scripts/alpaca_cli.py positions
python skills/alpaca/scripts/alpaca_cli.py orders [--executions]
python skills/alpaca/scripts/alpaca_cli.py quote --symbol AAPL
python skills/alpaca/scripts/alpaca_cli.py history --symbol AAPL --period 1d --limit 90首次运行需执行。所有命令均输出JSON格式内容。默认配置为(模拟账户)。
pip install alpaca-pypaperbash
python skills/alpaca/scripts/alpaca_cli.py status
python skills/alpaca/scripts/alpaca_cli.py account
python skills/alpaca/scripts/alpaca_cli.py positions
python skills/alpaca/scripts/alpaca_cli.py orders [--executions]
python skills/alpaca/scripts/alpaca_cli.py quote --symbol AAPL
python skills/alpaca/scripts/alpaca_cli.py history --symbol AAPL --period 1d --limit 90place (paper): qty OR notional, market OR limit
下单(模拟账户):指定数量(qty)或金额(notional),市价(market)或限价(limit)
python skills/alpaca/scripts/alpaca_cli.py place --symbol AAPL --side buy --qty 1 --type market
python skills/alpaca/scripts/alpaca_cli.py place --symbol AAPL --side buy --notional 500 --type limit --limit-price 180
python skills/alpaca/scripts/alpaca_cli.py cancel --order-id <id>
python skills/alpaca/scripts/alpaca_cli.py place --symbol AAPL --side buy --qty 1 --type market
python skills/alpaca/scripts/alpaca_cli.py place --symbol AAPL --side buy --notional 500 --type limit --limit-price 180
python skills/alpaca/scripts/alpaca_cli.py cancel --order-id <id>
live: must add --profile live AND --confirm-live
实盘下单:必须添加--profile live和--confirm-live参数
python skills/alpaca/scripts/alpaca_cli.py --profile live --confirm-live place --symbol AAPL --side buy --qty 1
Periods: `1m 5m 15m 30m 1h 1d 1w 1M`. Alpaca supports fractional `--notional` (dollar amount) orders.python skills/alpaca/scripts/alpaca_cli.py --profile live --confirm-live place --symbol AAPL --side buy --qty 1
时间周期选项:`1m 5m 15m 30m 1h 1d 1w 1M`。Alpaca支持按金额(`--notional`)进行fractional下单。Gotchas
注意事项
- is the health check — it reports SDK install state, key presence, and pings the account. Run it first.
status - Free IEX data can be sparse/delayed off-hours; use only if the account has the paid feed.
sip - Live trading is real money. The gate is intentional; never auto-add it.
--confirm-live
- 命令用于健康检查——它会报告SDK安装状态、密钥是否存在,并测试账户连通性。请先运行该命令。
status - 免费的IEX数据在非交易时段可能数据稀疏或延迟;仅当账户已订阅付费数据源时才使用。
sip - 实盘交易涉及真实资金。参数是有意设置的安全门槛;切勿自动添加该参数。
--confirm-live