Documentation
¶
Overview ¶
Package flexstmt parses IBKR Flex query statements into typed records for the post-trade reconciliation engine (internal-docs/design/post-trade-truth.md). Pure parsing: no I/O, no policy, no matching. Statement content is untrusted broker data — everything is extracted through typed attributes, an unknown cash-transaction type lands in Uncategorized rather than being dropped, and nothing in a statement can carry an instruction anywhere.
Index ¶
Constants ¶
const ( // CategoryFlow is an external capital flow (deposit/withdrawal) — // the lines the declared ledger must account for. CategoryFlow = "flow" // CategoryClassified is a known non-flow line (dividend, interest, // fee, tax, …): legitimate P&L, excluded from flow matching by type. CategoryClassified = "classified" // CategoryUncategorized is a line type this parser does not know. // Always surfaced as an exception downstream, never silently dropped. CategoryUncategorized = "uncategorized" )
Cash-transaction categories after classification.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CashLine ¶
type CashLine struct {
// ID is the broker transactionID when present, else a stable hash of
// the line's identifying attributes. Restatements supersede by ID.
ID string
Category string // flow | classified | uncategorized
Type string // raw Flex type attribute
Currency string
// Amount is nil when the statement omitted the amount attribute. An
// explicit zero remains a present value.
Amount *float64
// AmountBase is Amount converted at the statement's fxRateToBase;
// nil when the statement carried no amount or no usable rate (never
// fabricated).
AmountBase *float64
ValueDate time.Time // settleDate when present, else dateTime's day
Description string
}
CashLine is one classified cash-transaction line.
type Statement ¶
type Statement struct {
AccountID string
FromDate time.Time
ToDate time.Time
WhenGenerated time.Time
Cash []CashLine
Transfers []Transfer
Equity []EquityRow
}
Statement is one parsed Flex statement.
type Transfer ¶
type Transfer struct {
ID string
Direction string // IN | OUT
Date time.Time
// CashTransfer is nil when the statement omitted the cashTransfer
// attribute. An explicit zero remains a present value.
CashTransfer *float64
AmountBase *float64
Description string
}
Transfer is one position/cash transfer (ACATS, internal). Treated as a flow candidate downstream; a transfer with no computable base amount is an uncategorized exception, not a guess.