Item#

Percentage change#

Pecentage change from day 0 to day 1 but also from day 0 to day 5 can be calculated with get_last_days_perc_change() method. This method seeks for last known price and a price that suits the “days ago” criterium. When a price for “days ago” criterium cannot be found (missing data because that date is weekend) method searches for nearest price before “days ago” date.

Method also caches the result.

Compounded change#

Method can also calculate compounded change based on all open deposit transactions. The method for calculation is weighted average.

Item.get_last_days_perc_change(days, no_cache=False, compounded=False)#

Calculates change in price in percents between last known price (today) and “today - days param” day.

In case of compounded change function works with open transactions. Takes the calculated percentage change and every found transaction and calculates it’s real gain/loss and it’s investment. Based on these 2 values for each transaction a weighted average is calculated.

Parameters:
  • days (int) – Number of days to go in past.

  • no_cache (bool) – If true cache is not used (value is forced to be calculated).

  • compounded (bool) – If true calculates compounded change based on deposit transactions.

Returns:

Percentage diff since “past” (today - days param) to today.

Return type:

int

ItemData#

A model where additional Item related data are stored. Data are stored as JSON object under certaik keys:

  • basic_info - basic info for all items (displayed on item detail page)

  • holdings - list of ETF holdings - ETFs only

Warning

ItemData model should never been accessed directly. There are methods in Item model and in ancestors. See methods like:

  • Item.set_basic_info()

  • Item.get_basic_info()