Value positions from a daily price feed
A position was a share count. An instrument now carries a market symbol and the last close fetched for it, so Wealth and the dashboard report cash plus market value instead of cash alone. The symbol is chosen by hand and never derived: one ISIN lists on several exchanges in different currencies, and a price from the wrong listing misstates wealth without failing any check. The refresh refuses a quote whose currency differs from the instrument's, keeps the previous quote when a symbol cannot be priced, and counts an instrument with no symbol as unpriced - naming it in a check and leaving it out of every total, because cost is not value. The quote belongs to the job: saving an instrument can neither set nor erase it, and changing the symbol discards it. Two things the provider forced. It answers HTTP 429 to every request whose User-Agent names a programming language, so the client identifies as a browser; without that header the first call of the day fails. Its closes are 32-bit floats widened to 64 - 165.26 arrives as 165.25999450683594 - so a figure is rounded to seven significant digits, which is what 24 mantissa bits carry; eight would have stored 165.25999 as a price. Accepted quotes are written in one commit against a revision re-read after the fetches, and nothing is committed when no quote changed. The automatic run starts shortly after launch and repeats daily on its own timer, so a sync backoff cannot delay it and prices arrive with no bank connected. Verified against live quotes end to end: 80 shares at 125.45 and 40 at 165.26 on 6000.00 cash report 22646.40 with one holding named as unpriced; giving that holding a symbol through the UI moves the figure to 23530.50, and a second refresh leaves the revision untouched.
This commit is contained in:
+49
-9
@@ -497,6 +497,45 @@ instrument that already exists. The name is editable display text; the ISIN is
|
||||
identity and cannot be changed. Crypto is held under the ISIN-shaped identifier
|
||||
the broker issues for it, so it needs no separate identity scheme.
|
||||
|
||||
Market prices and valuation
|
||||
---------------------------
|
||||
An instrument carries an optional market symbol, which is the listing its price
|
||||
is read from, and the last quote fetched for it with the day that quote closed.
|
||||
The symbol is set by hand and never derived: one ISIN lists on several exchanges
|
||||
in different currencies, an ISIN search returns the wrong one often enough to
|
||||
matter, and a price from the wrong listing misstates wealth without failing any
|
||||
check. A quote whose currency differs from the instrument's is refused and not
|
||||
stored.
|
||||
|
||||
The quote belongs to the price job. Saving an instrument can neither set it nor
|
||||
erase it; changing the symbol discards it, because the stored price belongs to
|
||||
the previous listing. A symbol that cannot be priced keeps its last quote and is
|
||||
reported as a failure, so the failure mode is a stale figure with a visible
|
||||
date, never a wrong one. An instrument with no symbol is counted as unpriced,
|
||||
named in the report, and excluded from every total: cost is not value, and
|
||||
substituting it would report a number the journal cannot support.
|
||||
|
||||
A quote is a rate, not money: money holds four decimal places, while a unit
|
||||
price can need more. Quotes are therefore stored at the share count's eight-
|
||||
place precision, and a provider figure is rounded to seven significant digits
|
||||
before it is stored. Seven is what a 32-bit float carries, and the provider's
|
||||
closes are 32-bit floats widened to 64: 165.26 arrives as 165.25999450683594,
|
||||
and rounding at eight would preserve 165.25999 as though it were a price.
|
||||
|
||||
The provider is an undocumented, unauthenticated endpoint, and it refuses any
|
||||
request whose User-Agent names a programming language, so the client sends a
|
||||
browser agent; without it every fetch answers HTTP 429 on the first call. Runs
|
||||
are paced, fetches are bounded and never follow redirects, and no response text
|
||||
reaches an error message. The automatic run starts shortly after launch and
|
||||
repeats daily. Nothing is committed when no quote changed.
|
||||
|
||||
A holding's value is its share count times its quote, rounded half away from
|
||||
zero to money's four places. Positions is that value summed per account, wealth
|
||||
is cash plus positions, and result is value plus everything the position
|
||||
returned less everything put into it - the outcome to date, realised and not.
|
||||
None of these figures are read from the DuckDB index: the report is recomputed
|
||||
from the journal so it can be checked against a broker's own screen.
|
||||
|
||||
A broker reuses one reference across every leg of an economic event: the cash
|
||||
and position sides of a corporate action arrive with the same reference byte for
|
||||
byte, and the position leg's zero amount does not even differ in direction.
|
||||
@@ -589,13 +628,14 @@ does not.
|
||||
Checks that fail mean the journal disagrees with itself: row arithmetic, cash
|
||||
never negative, holdings never negative. A negative holding means a position was
|
||||
closed that was never opened in the imported data, so the export is partial or a
|
||||
sign is wrong. Checks that only note: fee and tax recorded but not applied, and
|
||||
deposits or withdrawals with no counterpart in another account.
|
||||
sign is wrong. Checks that only note: fee and tax recorded but not applied,
|
||||
deposits or withdrawals with no counterpart in another account, and holdings
|
||||
left out of the wealth figure for want of a quote.
|
||||
|
||||
Out of scope, deliberately: market prices, market value, net worth over time,
|
||||
FIFO lot accounting, realised gains, Vorabpauschale, and currency conversion. A
|
||||
position's "invested" figure is cash in less cash out, not a cost basis: a depot
|
||||
transfer moves a position with no cash at all, and a sale returns cash without
|
||||
Out of scope, deliberately: intraday prices, net worth over time, FIFO lot
|
||||
accounting, realised gains, Vorabpauschale, and currency conversion. A position's
|
||||
"invested" figure is cash in less cash out, not a cost basis: a depot transfer
|
||||
moves a position with no cash at all, and a sale returns cash without
|
||||
identifying which lot it closed.
|
||||
|
||||
Canonical files and recovery
|
||||
@@ -696,9 +736,9 @@ Boundaries and verification
|
||||
---------------------------
|
||||
There are no splits, budgets, tax/invoice/receipt processing, login/multi-user
|
||||
support, arbitrary SQL or natural-language query execution. Investment support
|
||||
covers positions and cash, not valuation: no market prices, market value,
|
||||
net worth over time, FIFO lots, realised gains, Vorabpauschale or currency
|
||||
conversion.
|
||||
covers positions, cash and a daily closing price per instrument: no intraday
|
||||
prices, net worth over time, FIFO lots, realised gains, Vorabpauschale or
|
||||
currency conversion.
|
||||
Natural-language query DSL and Sankey exploration remain explicitly later work.
|
||||
There is no browser-to-bank credential handling or payment initiation.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user