关于 storyclaw-alpaca-trading
通过 Alpaca API 交易美国股票和加密货币,依据凭据使用模拟或真实交易。支持账户与行情查询及下单;交易前必须展示计划并获得明确确认。
主要功能
- 01凭据控制模拟或真实交易
- 02查询账户、持仓和订单历史
- 03查询报价、价格历史与 RSI
- 04提交市价买入和卖出订单
- 05运行 RSI 策略命令
适用场景
- 01查看账户余额和持仓
- 02检查报价与价格历史
- 03制定股票或加密货币交易计划
- 04获得明确确认后执行交易
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ storyclaw-official/ talenthub --skill storyclaw-alpaca-trading安装后在 Claude Code 中输入/storyclaw-alpaca-trading确认已加载。
包含的文件
除 SKILL.md 外,安装时一起下载的参考资料和脚本。
.gitignoreconfig.example.jsoncredentials/example.jsonscripts/aggressive-strategy.jsconfig-loader.jsmomentum-strategy.jstrading.js详细介绍
Alpaca 交易 - 美股与加密货币交易
通过 Alpaca API 交易美股和加密货币。支持模拟交易(免费模拟)和真实交易。
重要规则
- 绝不在展示计划并获得明确确认前执行交易
- 绝不在事先提出并获得确认前设置 cron 作业
- 绝不编造价格或数据——始终查询真实数据
- 绝不擅自假设用户想交易什么——先询问
多用户支持
每位用户都有自己的 credentials/{USER_ID}.json:
{
"apiKey": "YOUR_KEY",
"apiSecret": "YOUR_SECRET",
"baseUrl": "https://paper-api.alpaca.markets",
"dataUrl": "https://data.alpaca.markets"
}
若要切换到真实交易,请将 baseUrl 改为 https://api.alpaca.markets。
或者设置 ALPACA_API_KEY 和 ALPACA_API_SECRET 环境变量。
首次使用流程
- 检查凭据:
USER_ID=$TELEGRAM_USER_ID node {baseDir}/scripts/trading.js check - 询问用户想交易什么(股票还是加密货币、代码、金额、风险)
- 提出具体计划——等待用户确认
- 仅在用户确认后执行
命令
账户与持仓
node {baseDir}/scripts/trading.js check # Check config
node {baseDir}/scripts/trading.js account # Balance
node {baseDir}/scripts/trading.js positions # Current holdings
node {baseDir}/scripts/trading.js history # Order history
node {baseDir}/scripts/trading.js portfolio-history # Equity curve (1W default)
node {baseDir}/scripts/trading.js portfolio-history 1M # 1D/1W/1M/3M/1A
市场数据
node {baseDir}/scripts/trading.js quote AAPL # Real-time quote
node {baseDir}/scripts/trading.js bars AAPL 30 # Price history
node {baseDir}/scripts/trading.js rsi AAPL 14 # RSI indicator
交易
node {baseDir}/scripts/trading.js buy AAPL 10 # Buy (market order)
node {baseDir}/scripts/trading.js sell AAPL 10 # Sell
策略
node {baseDir}/scripts/trading.js strategy-rsi AAPL # RSI mean reversion
# RSI < 30 + no position → BUY; RSI > 70 + has position → SELL
功能
- 美股与加密货币(AAPL、TSLA、BTC、ETH 等)
- 模拟交易或真实交易(取决于凭据)
- 实时行情(免费套餐延迟 15 分钟)
- 市价单、技术指标(RSI)
- 市场交易时间:股票为周一至周五 9:30-16:00 ET;加密货币为 24/7
设置
- 在 https://app.alpaca.markets/brokerage/new-account 注册
- 生成 API 密钥和密钥(模拟交易部分)
- 创建
credentials/{USER_ID}.json或设置环境变量
API 限制
| 套餐 | 调用次数/分钟 | 数据延迟 |
|---|---|---|
| 免费 | 200 | 15 分钟 |
| 无限 | 无限 | 实时 |
评论
支持 Markdown