3.2 KiB
MODIFIED Requirements
Requirement: Read failures cannot masquerade as empty portfolios
HTTP, authentication, malformed schema, identity mismatch and numeric conversion errors SHALL fail the read. Requests SHALL have bounded timeouts. Only a valid response with no nonzero positions SHALL produce an empty result. Present mark prices SHALL be positive and finite; an explicitly absent mark SHALL preserve positions and quantities with unavailable price-dependent valuations.
Scenario: Missing mark price
- WHEN a valid mark response has no mark price for a held position
- THEN the position and its TWAP quantities remain present with unknown USD valuations
- AND affected aggregate valuations remain unknown
Scenario: Rejected access or invalid price
- WHEN an HTTP request is rejected or a present mark price is invalid
- THEN the read fails instead of returning an empty or partial portfolio
Scenario: Empty account
- WHEN a valid trader snapshot has no subaccounts or no nonzero positions
- THEN an empty result is returned without market-price or TWAP requests
Scenario: Public API rate limit
- WHEN the shared adapter issues requests for PROD and TEST
- THEN request starts SHALL be spaced at least one second apart
- AND HTTP 429 SHALL fail the lookup and establish a shared cooldown from Retry-After (seconds or HTTP date, 60 seconds fallback)
- AND lookups during cooldown SHALL fail without external calls, with no immediate retry
ADDED Requirements
Requirement: Read precise TWAP snapshots for held markets
The reader SHALL read official TWAP snapshots through its existing paced transport and associate orders by authority, PDA, subaccount and market identity. Only orders with actual fills and remaining children on an existing position SHALL be exposed. Quantities SHALL use exact lot conversion and explicit/legacy dust semantics. Unavailable size inputs SHALL remain unknown. Existing mark prices SHALL be reused without Ticker reads.
Scenario: Explicit and legacy dust
- WHEN total children are 5, regular size 10 lots and explicit dust count/size are 2/3
- THEN total size is 36 lots and the fourth child is 3 lots
- AND legacy zero dust count with size 3 instead represents four regular children and a final 3-lot child
Scenario: Identity mismatch or unfilled order
- WHEN authority/PDA/subaccount/asset identities disagree or an order has no fills
- THEN disagreement fails the read, while a valid unfilled order is absent from returned positions' TWAP data
Requirement: TWAP time estimates disclose their slot assumption
The reader SHALL estimate future execution times from snapshot slot, due slot and cooldown using a documented nominal slot duration and response observation time. Completion SHALL derive from remaining executions, never expiry. Already-due schedules, invalidated completion schedules and unrepresentable estimates SHALL remain unavailable instead of predicting fills.
Scenario: Expiry before planned completion
- WHEN the scheduled final child lies beyond the order's expiry
- THEN the reader does not provide that schedule as an estimated completion time