Models
The shares app has two models: the concrete asset type Share
and its dividend records.
Share
Concrete subclass of Item – Share
joins the core_item table via Django multi-table inheritance, so
the symbol / type / is_discontinued fields come from
BaseItem and the four boolean
is_share / is_index / is_etf / is_coin methods
implement the polymorphic dispatch used across the app.
The update_cache override invalidates the share-specific
transaction-performance / profit-performance cache keys and
re-warms them by re-running Performance so the next request
doesn’t have to pay the cache-miss cost.
-
class richy.shares.models.Share(id, symbol, type, is_discontinued, item_ptr)[source]
Bases: Item
-
Share.update_cache()[source]
Updates cached values cached by:
Dividend
A dividend record for a Share. Inherits all fields from
BaseDividend and adds only the share
foreign key. Records are downloaded by
get_dividends() (which wraps the
rug library); shares with no dividends produce an empty list.
Field semantics:
ex_date – the first date on which a stock is traded without
the right to receive the next dividend payment (equals the
record_date since 2024).
record_date – the day a company finalizes which shareholders
receive the dividend.
payment_date – the date the dividend is paid out.
yield_value – dividend in %.
amount_value – dividend as a value in currency.
-
class richy.shares.models.Dividend(id, ex_date, payment_date, record_date, yield_value, amount_value, share)[source]
Bases: BaseDividend