alpaca-broker-money-precision-sh-r1uewy

Specialized skill for Alpaca broker monetary precision, assisting AI agents to efficiently handle and assess tasks related to monetary precision for the Alpaca brokerage.

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "alpaca-broker-money-precision-sh-r1uewy" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-ff30ebd4ec41b32562c75622ddd33c288703ce11a9bb6ef22c8b9853e34206b0. Verify the upstream source and version against https://skillhub.cn/skills/user_3c6cb52e/alpaca-broker-money-precision-sh-r1uewy before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

skillhub.cn

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

Specialized skill for Alpaca broker monetary precision, assisting AI agents to efficiently handle and assess tasks related to monetary precision for the Alpaca brokerage.

0 Downloads

Introduction source: third_party · user_3c6cb52e · 1.0.0 Reference

SkillPi interpretation

Tasks
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.
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
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.

Current listing version

1.0.0

Verify the source revision ↗

Safety and assessment details

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value65/100

Highlights

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

Highlights

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

Areas to improve

  • 缺少 When to Use 章节 Reported severity: Minor

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

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

Highlights

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

Highlights

  • 提供了多语言的 decimal 类型使用建议,工具来源明确
  • 覆盖了主要的精度处理异常场景
  • 给出了具体的舍入模式和实现建议
Evidence Verifiability (mean of the first four)82/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

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

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

These common operations were not identified in the main document. This does not mean no permissions or risks exist.

Domains or addresses referenced in the document

These addresses may be documentation links or examples, not an approved network allowlist. Verify actual destinations and outgoing data before use.

  • github.com

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.