Expand description
Account builder for converting PortfolioBalance to types::Account.
This module provides the translation layer between:
PortfolioBalance(PortfolioService’s internal state for executed positions)types::Account(SPAN/margin calculation input)
The key insight is that PortfolioBalance stores positions keyed by full symbol (e.g., “BTC-20250131-100000-C”), while Account groups by underlying (e.g., “BTC”).
§Fail-Closed Design
This builder returns Result<Account, BuildAccountError> rather than silently
skipping unknown or missing data. If we cannot safely construct a complete
risk view, we return an error so callers can reject margin-sensitive operations.
Enums§
- Build
Account Error - Error type for account construction failures.
Functions§
- build_
account_ from_ balance - Build a
types::Accountfrom PortfolioService’s internal state. - expiry_
to_ years - Convert YYYYMMDD expiry to years-to-expiry from now.