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:
@@ -104,6 +104,16 @@ type Instrument struct {
|
||||
ISIN string `json:"isin"`
|
||||
Name string `json:"name"`
|
||||
Currency string `json:"currency"`
|
||||
// Symbol is the market listing this security is quoted under. One ISIN maps
|
||||
// to several listings in different currencies, and taking the wrong one
|
||||
// silently misstates wealth, so it is chosen once by hand and never
|
||||
// guessed. Without it the holding stays unpriced.
|
||||
Symbol string `json:"symbol,omitempty"`
|
||||
// Quote is the last known unit price and QuotedAt the day it is from, both
|
||||
// filled by the daily price job and hand-editable. A quote is a rate, not
|
||||
// money: a crypto unit price needs more than money's four places.
|
||||
Quote Quantity `json:"quote,omitempty"`
|
||||
QuotedAt string `json:"quoted_at,omitempty"`
|
||||
}
|
||||
|
||||
type Facts struct {
|
||||
|
||||
Reference in New Issue
Block a user