Models#

The etfs app has two models: the concrete asset type Etf and its dividend records.

Etf#

Concrete subclass of Item via Django multi-table inheritance. Adds an indexes many-to-many to Index so an ETF can be tagged with the indexes it tracks.

Holdings (the ETF’s underlying basket) live as JSON on ItemData under the holdings key and are accessed exclusively through the two helpers below – never via ItemData directly.

The update_cache override invalidates the ETF-specific transaction-performance / profit-performance cache keys and re-warms them by re-running Performance.

class richy.etfs.models.Etf(id, symbol, type, is_discontinued, item_ptr)[source]#

Bases: Item

Etf.set_holdings(data)[source]#
Etf.get_holdings()[source]#
Etf.update_cache()[source]#

Updates cached values cached by:

  • self.get_last_days_change(…)

  • self.get_sma(…)

  • self.get_ath()

  • self.get_drawdown()

  • self.get_52_weeks_low_high()

  • ItemWithPrices.refresh()

Dividend#

A dividend record for an Etf. Inherits all fields from BaseDividend and adds only the etf foreign key. Records are downloaded by get_dividends() (which wraps the rug library); ETFs with no dividends produce an empty list.

Field semantics:

  • ex_date – the first date on which the ETF is traded without the right to receive the next dividend payment (equals the record_date since 2024).

  • record_date – the day the fund 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.etfs.models.Dividend(id, ex_date, payment_date, record_date, yield_value, amount_value, etf)[source]#

Bases: BaseDividend