Communitygithub.com

SnapTrade 投资组合

通过 SnapTrade SDK 连接用户的投资账户,生成投资组合报告(例如每日总价值)。当用户需要基于 SnapTrade 的券商连接(Webull、E*TRADE 等)、连接门户链接、账户注册或自动投资组合摘要时使用。

SnapTrade 投资组合 是什么?

SnapTrade 投资组合技能通过官方 SnapTrade Python SDK(`snaptrade_client`)实现券商账户连接,并自动处理请求签名。它支持一站式注册用户、生成连接门户链接、重新启用已禁用的连接、列出允许的券商,以及检索总投资组合价值。此外,该技能还支持下单(市价单/限价单)并监控订单执行情况,可按账户查询持仓和余额,仅在用户明确要求时才使用持仓数据。该技能依赖本地配置文件存储凭证,兼容 Claude Code、Cursor 和类似终端界面的 AI 代理平台。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/baneeishaque/ljt-520_openclaw-backup/tree/HEAD/skills/brendanwood/portfolio-trader

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

SnapTrade 投资组合 是做什么的?

概述

通过 SnapTrade 连接券商账户并生成每日总价值报告。本技能使用官方 SnapTrade Python SDK(snaptrade_client),请求签名自动处理。

工作流程

2d) 下单买入/卖出(股票/ETF)

运行:

python3 scripts/snaptrade_order.py buy|sell TICKER UNITS --account-id <ACCOUNT_ID> [--order-type market|limit] [--limit-price <PRICE>] [--tif Day|GTC|IOC|FOK]

默认值:

  • 订单类型:market
  • 有效期:Day
  • 限价:仅限价单需要

可选监控(轮询近期订单):

python3 scripts/snaptrade_order.py buy|sell TICKER UNITS --account-id <ACCOUNT_ID> --watch
  • 默认每 10s 轮询一次,最长 120s
  • 可通过 --watch-interval 和 --watch-seconds 调整

按 ID 监控已有订单:

python3 scripts/snaptrade_watch_order.py --account-id <ACCOUNT_ID> --order-id <BROKERAGE_ORDER_ID>
  • 同样默认 10s/120s,可通过 --watch-interval 和 --watch-seconds 调整

当用户询问时,使用账户订单端点确认成交并报告未结订单。

0) 创建 SnapTrade 账户 + 获取 API 密钥

您需要一个 SnapTrade 账户来连接券商。在 https://snaptrade.com 免费创建账户,生成您的 Client ID 和 Consumer Key,然后将其添加到技能配置中。

1) 安装依赖

pip3 install -r requirements.txt

2) 配置凭据(一次性)

将凭据存储在本地配置文件中(不要提交)。user_id 在首次运行时自动生成:

/home/openclaw/.openclaw/workspace/secrets/snaptrade.json

示例:

{
  "client_id": "YOUR_CLIENT_ID",
  "consumer_key": "YOUR_CONSUMER_KEY",
  "user_id": "<auto-generated-uuid>"
}

2) 注册用户 + 生成连接门户链接

运行:

python3 scripts/snaptrade_portal.py

这将:

  • 如果缺少 user_secret,则注册用户
  • 将 user_secret 存储回配置文件
  • 打印用户必须打开的连接门户 URL 以关联账户

2b) 重新启用已禁用的连接

运行:

python3 scripts/snaptrade_reconnect.py [brokerage-name]

这将:

  • 列出已禁用的连接
  • 生成重新启用链接(可选按券商名称匹配)
  • 打印重新启用 URL,供用户重新启用连接

2c) 列出可用券商(允许的连接)

运行:

python3 scripts/snaptrade_brokers.py

这会调用 /snaptrade/partners 并返回 allowed_brokerages 列表(显示名称)。

3) 拉取总投资组合价值

运行:

python3 scripts/snaptrade_total.py

输出为 JSON,例如:

{"total_value": 123456.78, "currency": "CAD"}

3b) 按券商汇总(货币转换)

运行:

python3 scripts/snaptrade_broker_totals.py --currency CAD

输出 JSON 包含按券商汇总的选定货币总价值以及使用的汇率。

实现说明: 尽量避免使用 get_user_holdings。持仓/头寸数据优先使用 get_user_account_positions(头寸端点)。仅当用户明确要求时,才使用持仓中的余额/现金;否则不要调用持仓。

4) 安排每日报告

使用 cron 调用 snaptrade_total.py,格式化简洁的 WhatsApp 消息,然后发送给用户。仅需总价值。

脚本

  • scripts/snaptrade_common.py — 配置加载/保存 + 客户端创建
  • scripts/snaptrade_portal.py — 注册用户 + 生成连接门户链接
  • scripts/snaptrade_reconnect.py — 为禁用的连接生成重新启用链接
  • scripts/snaptrade_brokers.py — 列出该客户允许的券商
  • scripts/snaptrade_order.py — 下单买入/卖出(市价/限价),可选监控
  • scripts/snaptrade_watch_order.py — 按 ID 监控已有订单以确认成交
  • scripts/snaptrade_total.py — 计算所有账户的总价值
  • scripts/snaptrade_broker_totals.py — 按券商汇总,支持汇率转换

备注

  • 请求签名由 SDK 通过 request_after_hook 使用 consumer_key 处理。
  • 总价值通过将每个账户的 account.balance.total 相加得出;这避免了添加或删除账户时出错。
  • 如果存在多种货币,脚本使用遇到的第一个货币。
  • 将密钥保存在本地配置文件中,并设置 chmod 600 权限。

Individual skills in this repo

This repo contains 13 individual skills — each has its own dedicated page.

baneeishaque/ljt-520_openclaw-backup

Complete investment portfolio risk management system. Analyze positions, calculate risk metrics, stress test scenarios, optimize allocations, and generate institutional-grade risk reports — all without external APIs.

baneeishaque/ljt-520_openclaw-backup

Balance tracking, order overview, and market data across exchanges using OpenMM.

baneeishaque/ljt-520_openclaw-backup

Balance tracking, order overview, and market data across exchanges using OpenMM.

baneeishaque/ljt-520_openclaw-backup

An investment portfolio tracker that runs entirely locally. All data stays in ~/.portfolio-tracker/.

baneeishaque/ljt-520_openclaw-backup

Discover and register autonomous AI agents. Use when: browsing the agent registry, submitting an agent for verification, or embedding agent badges. NOT for: general web search or agent capability analysis.

baneeishaque/ljt-520_openclaw-backup

Query land ownership, leases, landlord info, and land payments. Write operations for payment management and lease renewals.

baneeishaque/ljt-520_openclaw-backup

Build high-converting landing pages and product sales pages using proven 10-section conversion frameworks. Includes Hero → Social Proof → Benefits → CTA flow for both lead capture and e-commerce pages.

baneeishaque/ljt-520_openclaw-backup

Generate complete, responsive HTML landing pages from a product name, tagline, and description. Clean CSS, mobile-ready, with hero, features, CTA, and footer sections.

baneeishaque/ljt-520_openclaw-backup

Optimize conversion pages for paid traffic from Meta (Facebook/Instagram), Google Ads, TikTok Ads, YouTube Ads, Amazon Ads, and Shopify Ads journeys.

baneeishaque/ljt-520_openclaw-backup

Perform a structured conversion rate optimization (CRO) audit of a landing page. Use when a user shares a landing page URL, pastes their page copy, describes their page content, or uploads a screenshot and asks for a conversion audit, CRO review, conversion analysis, landing page feedback, or wants to know why their page isn't converting. Produces a scored 8-factor audit (0–80 total), prioritized fix list with quick wins and strategic recommendations, and an executive summary. Covers: headline clarity, supporting copy, social proof, CTA effectiveness, visual hierarchy, trust signals, mobile/speed signals, and offer clarity.

baneeishaque/ljt-520_openclaw-backup

Generate landing page content from PRD — hero section, features, A/B headline variants, CTA, and SEO meta tags. Use when user says "create landing page", "write landing copy", "hero section", "A/B headlines", or "landing content". Can scaffold actual pages for astro-static. Do NOT use for SEO auditing (use /seo-audit).

baneeishaque/ljt-520_openclaw-backup

Build high-converting landing pages with proven structure, persuasive copy, and conversion optimization.

baneeishaque/ljt-520_openclaw-backup

Track a crypto portfolio across Binance, Hyperliquid, and Polymarket. Calculates NAV, unrealized P&L, daily drawdown, win rate, and equity curve. Use when you need portfolio tracking, NAV calculation, drawdown monitoring, or multi-venue position management.

相关技能