alpaca-broker-money-precision

Handle money and numeric precision correctly in Alpaca API integrations.

4|Updated Aug 28, 2026
One-click install
npx skills add https://github.com/alan-d-smith/synthetix-alpha --skill alpaca-broker-money-precision-alan-d-smith
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: alpaca-broker-money-precision
Source: https://github.com/alan-d-smith/synthetix-alpha/tree/main/.agents/skills/alpaca-broker-money-precision
Command: npx skills add https://github.com/alan-d-smith/synthetix-alpha --skill alpaca-broker-money-precision-alan-d-smith

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Financial bugs from floating-point arithmetic are silent and expensive. This Skill prevents precision loss, rounding errors, and rejected API calls when handling monetary amounts, order quantities, and prices through the Alpaca API. ## Core Features & Use Cases - Decimal-Safe Parsing: Parse Alpaca's string-encoded money fields into decimal types instead of binary floats, across Python, TypeScript, Go, and Java. - Deliberate Rounding Rules: Round or truncate amounts to Alpaca's allowed precision (2 dp for cash, 9 dp for fractional shares) before sending, with intentional rounding modes. - Safe Storage Patterns: Store money as fixed-point decimal in databases, keep raw Alpaca values verbatim, and track explicit currency for multi-currency funding wallets. - Use Case: When splitting a deposit across multiple holdings, truncate each slice to 2 decimal places and track the remainder so you never move more money than intended. ## Quick Start Apply the Alpaca money precision rules to review my order placement code for float usage and rounding mistakes.

Frequently Asked Questions about alpaca-broker-money-precision

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I handle money values from the Alpaca API in Python?▼

Parse Alpaca's string-encoded money fields with decimal.Decimal, never float, and serialize back to strings when sending requests. Alpaca returns prices and amounts as JSON strings specifically to avoid binary float precision loss.

How many decimal places does Alpaca allow for orders?▼

Alpaca accepts 2 decimal places for cash amounts and up to 9 decimal places for fractional share qty and notional values. Round or truncate to the target precision before the API call to avoid rejection or silent rounding.

Should I use qty or notional for fractional share orders?▼

Use either qty or notional, never both. Pass notional directly and let Alpaca compute the fill rather than reconstructing qty from notional divided by a fetched price, which introduces drift.

Why does my Alpaca order get rejected for precision errors?▼

Rejections happen when amounts carry more decimal places than allowed or when binary floats introduce rounding artifacts. Explicitly truncate outgoing money to 2 decimal places with an intentional rounding mode before sending.

How should I store Alpaca money values in a database?▼

Store money as fixed-point decimal such as DECIMAL(20, 8), never float, and keep the raw values Alpaca sent verbatim alongside any converted values. Include an explicit currency column since some Alpaca rails are multi-currency.