alpaca-broker-money-precision-sh-r1uewy

Alpaca券商金额精度专用技能,辅助 AI Agent 在涉及 Alpaca 券商的金额精度相关任务中高效处理和判断。

安装方式

先用 Prompt 核对来源与依赖。也可下载安装包。

用 AI 助手安装

复制提示词,让助手先核对固定版本和依赖。

查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "alpaca-broker-money-precision-sh-r1uewy":https://skillpi.com/zh/skills/deepskill-ff30ebd4ec41b32562c75622ddd33c288703ce11a9bb6ef22c8b9853e34206b0。安装前核对上游来源和版本:https://skillhub.cn/skills/user_3c6cb52e/alpaca-broker-money-precision-sh-r1uewy。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。

来源与配置

skillhub.cn

配置方式待核实

请查看原始来源中的适用工具、依赖和权限要求。

安装实测待补充

Alpaca券商金额精度专用技能,辅助 AI Agent 在涉及 Alpaca 券商的金额精度相关任务中高效处理和判断。

0 下载

介绍来源: third_party · user_3c6cb52e · 1.0.0 参考来源

SkillPi 解读

能完成的任务
翻译待完成,请参阅来源文档。
实测状态
未测试

文件浏览

在原站浏览文件 ↗

原始 SKILL.md

打开原文 ↗
Frontmatter
name: Alpaca券商金额精度
slug: alpaca-broker-money-precision
version: 1.0.0
displayName: Alpaca券商金额精度
description: >
  Alpaca券商金额精度专用技能,帮助AI Agent高效完成相关任务。
summary: "Alpaca券商金额精度专用技能,帮助AI Agent高效完成相关任务。"
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-png"

Alpaca — 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-integration first.

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_DOWN vs ROUND_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 * percentage for 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

  • qty and notional support up to 9 decimal places.
  • qty XOR notional — never both (see alpaca-broker-trading-orders).
  • Don't reconstruct qty from notional / price and send it — pass notional and 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 the currency, 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 实验室的评测报告。

场景价值65/100

亮点

  • 针对 Alpaca 券商金额精度这一具体痛点,提供实用的金融计算解决方案
  • 内容专业性强,适合量化交易场景
触发精准85/100

亮点

  • 触发词精准完整,明确指向 Alpaca 券商金额精度处理
  • 边界清晰,不易与其他 Skill 混淆
结构规范90/100

待提升项

  • 缺少 When to Use 章节 原报告严重程度:轻微

    文档结构完整但缺少明确的 When to Use 使用场景说明章节

    改进建议:建议添加 When to Use 章节,明确说明在哪些具体场景下使用此 Skill

亮点

  • 文档结构清晰,分章节详细说明各个精度处理要点
  • 包含实用的检查清单和代码示例
  • frontmatter 完整,版本信息清晰
执行可靠88/100

亮点

  • 提供了多语言的 decimal 类型使用建议,工具来源明确
  • 覆盖了主要的精度处理异常场景
  • 给出了具体的舍入模式和实现建议
证据可验 (前四项均值)82/100

取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。

正文静态检测

100 / 100 · skillpi-20261123-no-r3-v1

正文未命中当前规则。

分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。

权限与使用前检查

根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。

未从主文档识别到上述常见操作,不能据此判断无需权限或没有风险。

文档引用的域名或地址

这些地址可能用于文档链接或示例,不是已批准的联网清单。使用前核对实际目的地及发送的数据。

  • github.com

本站展示提示不会授予权限。涉及文件改动、密钥、外部发送或费用时,仍由你使用的工具按需确认。

安全评级与访问范围

safe · 静态证据核验,不代表运行安全保证。

使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。