alpaca-broker-money-precision-zcg3
安装方式
先用 Prompt 核对来源与依赖。也可下载安装包。
用 AI 助手安装
复制提示词,让助手先核对固定版本和依赖。
查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "alpaca-broker-money-precision-zcg3":https://skillpi.com/zh/skills/deepskill-a255348c444ecdbe79728c820c584e365d6ee645421bdd5ebd0b3125dfd6b0e0。安装前核对上游来源和版本:https://skillhub.cn/skills/user_3c6cb52e/alpaca-broker-money-precision-zcg3。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。
来源与配置
skillhub.cn
配置方式待核实
请查看原始来源中的适用工具、依赖和权限要求。
安装实测待补充
Alpaca 券商金额精度专用技能,帮助AI Agent高效完成与券商金额精度处理相关的任务。
介绍来源: third_party · user_3c6cb52e · 1.0.0 参考来源
SkillPi 解读
- 能完成的任务
- 翻译待完成,请参阅来源文档。
- 适合谁
- 来源文档未说明。
- 输入和输出
- 来源文档未说明。
- 软件、账号及付费要求
- 来源文档未说明。
- 限制与区别
- 来源文档未说明。
- 实测状态
- 未测试
文件浏览
Frontmatter
name: Alpaca券商金额精度
slug: alpaca-broker-money-precision
version: 1.0.0
displayName: Alpaca券商金额精度
description: >
Alpaca券商金额精度专用技能,帮助AI Agent高效完成相关任务。
summary: "Handle money and numeric precision correctly with the Alpaca API — numbers-as-strings on the wire, decimals vs floats, rounding/truncation before sending amounts, fractional-share precision, and safe..."
license: MIT
category: 量化交易
framework:
- Claude Code
- Codex
- Hermes Agent
- OpenClaw
- QClaw
- WorkBuddy
platform: multi-platform
homepage: https://github.com/1991513ccie-png
repository: https://github.com/1991513ccie-pngAlpaca — Money & Numeric Precision
Financial bugs are silent and expensive. Alpaca's wire format and the realities of decimal arithmetic create a few specific traps. This skill is short, opinionated, and language-agnostic.
Read
alpaca-broker-integrationfirst.
1. Numbers come as strings — keep them that way
Alpaca returns prices, quantities, notional, and money amounts as JSON strings ("100.50", "1.5", "190.2345"), and accepts them as strings on the way in. This is deliberate: it avoids the precision loss of JSON's binary floats.
Rule: parse string money fields into a decimal type, never a binary float/double. Serialize back to a string. Don't let a number ever live as an IEEE-754 float in the money path.
| Language | Use | Avoid |
|---|---|---|
| Python | decimal.Decimal("100.50") |
float("100.50") |
| TypeScript/JS | a decimal lib (decimal.js/big.js) or string arithmetic |
Number(...), parseFloat |
| Go | shopspring/decimal |
float64 for accumulation |
| Java/Kotlin | java.math.BigDecimal |
double |
Real-world caveat: not every Alpaca endpoint is consistent — some market-data numeric fields come as JSON numbers (e.g. bar OHLC). Prices for display/analytics can tolerate floats; money you move or store must not. Know which field you're touching.
2. Round/truncate before sending — and know the direction
Alpaca generally accepts 2 decimal places for cash amounts and up to 9 for fractional share qty/notional. If you send more precision than allowed, you risk rejection or silent rounding on their side.
Rule: explicitly round/truncate to the target precision before the API call, using a deliberate rounding mode.
- For money you're moving out / charging, truncate (round down) to 2 dp so you never move more than intended. (e.g.
floor(amount * 100) / 100.) - Pick the rounding mode consciously (
ROUND_DOWNvsROUND_HALF_UP) — don't inherit whatever the default float formatting does. - Re-round after every arithmetic step that could reintroduce precision (e.g. computing
amount * percentagefor a split allocation), not just at the end.
# splitting a deposit across holdings — round each slice down, track remainder
slice = truncate(total * (pct / 100), 2)
3. Fractional shares
qtyandnotionalsupport up to 9 decimal places.qtyXORnotional— never both (seealpaca-broker-trading-orders).- Don't reconstruct
qtyfromnotional / priceand send it — passnotionaland let Alpaca compute the fill. Round-tripping through a price you fetched introduces drift.
4. Storage
- Store money in your DB as fixed-point decimal, not float. A practical pattern is generous precision/scale, e.g.
DECIMAL(20, 8)— wide enough for multi-currency and fractional, with headroom beyond Alpaca's 2-dp cash so you never lose data you received. - Store what Alpaca sent verbatim alongside any converted/derived values. If you truncate to 2 dp for the API call but received more precision back, keep both — it makes reconciliation and audits possible.
- Keep an explicit currency column; Alpaca is multi-currency on some rails (funding wallet) even though most is USD.
5. Multi-currency notes
- Most Broker/trading flows are USD; journals default to USD.
- The funding wallet rail supports many currencies (
USD,EUR,JPY, …) and carries FX fees. When you touch it, never assume USD — read and store thecurrency, and treat FX amounts as decimals end-to-end.
6. Checklist
- [ ] Money fields parsed from strings into a decimal type; serialized back to strings.
- [ ] No binary floats anywhere in the move-money path.
- [ ] Amounts rounded/truncated to the allowed precision before the call, with an intentional rounding mode (round down for outgoing money).
- [ ] Re-round after each intermediate computation.
- [ ] DB columns are fixed-point decimal with headroom; raw Alpaca values stored verbatim.
- [ ] Explicit currency tracked.
Related skills: order qty/notional rules → alpaca-broker-trading-orders; journal/transfer amounts → alpaca-broker-journals, alpaca-broker-funding-transfers; reconciling stored vs Alpaca values → alpaca-broker-reconciliation-idempotency.
当前收录版本
1.0.0
安全与评测信息
质量评测
满分100 · 来自 SkillPi LAB 实验室的评测报告。
亮点
- 针对 Alpaca 券商金额精度问题,提供专业的数值处理规范,解决金融场景下的核心痛点
- 涵盖 decimal vs float、精度控制、舍入策略、存储建议等关键内容,实用性强
待提升项
-
description写错位置 原报告严重程度:轻微
frontmatter 中 description 字段为空,实质描述内容位于 skill_body 内部
改进建议:建议将核心描述移至 frontmatter 的 description 字段,以便平台正确识别触发条件
亮点
- description 明确指出 'Alpaca券商金额精度专用技能',触发词精准
待提升项
-
缺少When to Use章节 原报告严重程度:轻微
文档结构清晰但未提供显式的 'When to Use' 使用场景说明
改进建议:建议增加 'When to Use' 章节,明确说明适用场景和触发条件
亮点
- 文档结构清晰,分 6 个章节,每节有具体规则、代码示例、表格对比
- frontmatter 完整,单文件未超长
待提升项
-
工具来源未明确说明 原报告严重程度:轻微
提供了多语言实现建议但未明确说明工具来源(如 decimal.js 的版本或安装方式)
改进建议:建议补充关键工具库的来源、版本或安装说明,提升执行可靠性
亮点
- 提供了多语言的具体实现建议(Python decimal、JS decimal.js、Go shopspring/decimal、Java BigDecimal)
- 覆盖了主要异常场景(精度超限、舍入方向、存储类型)
取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。
正文静态检测
100 / 100 · skillpi-20261123-no-r3-v1
正文未命中当前规则。
分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。
权限与使用前检查
根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。
未从主文档识别到上述常见操作,不能据此判断无需权限或没有风险。
文档引用的域名或地址
这些地址可能用于文档链接或示例,不是已批准的联网清单。使用前核对实际目的地及发送的数据。
- github.com
安全评级与访问范围
safe · 静态证据核验,不代表运行安全保证。
来源文档未说明。
使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。
用户讨论
还没有已核实的点评。