Charts#

Matplotlib charts#

Some charts are rendered server-side (matplotlib / seaborn) by richy.core.charts. Each chart has its own class for clarity. Charts are exported as SVG by default.

BaseChart#

Common base for all matplotlib chart classes. Provides the style helper material(), the ticker formatter timestamp_to_date(), and the SVG export.

class richy.core.charts.BaseChart[source]#

Bases: object

Common class for all chart classes.

BaseChart.export(format='svg')[source]#

Exports the currently being rendered chart in the given format.

Parameters:

format (str) – Format the chart is gonna be exported in.

Returns:

Chart as bytes.

Return type:

io.BytesIO

Manager#

Concrete renderer that produces matplotlib outputs. Currently exposes a per-item performance() chart (horizontal bar showing percentage change over 5d / 1m / 3m / 6m / YTD / 1y) and an internal linear_regression() helper.

class richy.core.charts.Manager[source]#

Bases: BaseChart

Manager.performance(item)[source]#

Generates performance chart for following time spans:

  • 5 days

  • 1 month

  • 3 months

  • 6 months

  • YTD

  • Year

Parameters:

item (richy.core.models.Item) – Item the performance chart is gonna be generated for.

Returns:

Generated chart as bytes.

Return type:

io.BytesIO

Highcharts charts#

Interactive Highcharts (JavaScript) charts. Each class builds a Highcharts options / series dict that the template hands off to the highcharts Vue component.

The classes are grouped below by where they appear in the UI.

Transaction charts#

Charts used across the Transactions views (overview, basic stats, per-transaction detail).

class richy.core.charts.TransactionOverviewChart(user, df)[source]#

Bases: object

Highcharts transaction overview chart used in transaction open overview pages.

TransactionsBasicChart is the shared base for the next two column / pie chart variants and provides the get_investments / get_revenues / get_market_values data-shaping helpers used by both.

class richy.core.charts.TransactionsBasicChart(df, pile)[source]#

Bases: object

class richy.core.charts.TransactionsBasicColumnChart(df, pile)[source]#

Bases: TransactionsBasicChart

Highcharts transaction basic charts for each type and currency - investment vs. market value column chart.

class richy.core.charts.TransactionBasicPieChart(df, pile)[source]#

Bases: TransactionsBasicChart

Highcharts transaction basic charts for each type and currency - profits column chart.

class richy.core.charts.TransactionDetailColumnChart(df)[source]#

Bases: object

Highcharts transaction detail column chart for a specified transaction.

Dashboard and coin overview#

Top-of-funnel summary charts – the dashboard’s net-worth pie and the coin-list staking ratio pie.

class richy.core.charts.DashboardMarketValueRatioPieChart[source]#

Bases: object

Highcharts dashboard market value ratio pie chart on a dashboard.

class richy.core.charts.OpenStakingsRatioPieChart(user)[source]#

Bases: object

Staking pie chart used on coin list page.

Item-detail charts#

Per-item visualizations used on the item-detail page (and reused across shares / ETFs / indexes / coins): annual performance candles, drawdown timeline, and historical ATH periods.

class richy.core.charts.PerformanceChart(item)[source]#

Bases: object

Highcharts candle chart of item performance year by year.

class richy.core.charts.DrawdownChart(item)[source]#

Bases: object

Drawdown chart for item detail page.

class richy.core.charts.AthPeriodsChart(item)[source]#

Bases: object

Highcharts ATH periods chart.

Share-specific charts#

Highcharts builders used exclusively by the share Financials view. Each class reads from one or more Asset records (populated by Scraper) and returns a Highcharts options dict ready for the template’s Vue component.

class richy.core.charts.ShareRevenueEarningsEpsChart(user_item)[source]#

Bases: object

Highcharts Revenue and Earnings (and EPS) chart for shares.

ShareRevenueEarningsEpsChart.get_data()[source]#

Fetches and converts revenues + earnings + eps data from the database to pandas dataframe sorted by date in descending order.

Also return EPS rows except “announcement date” column sorted by date - in descending order.

Returns:

Dataframe with “revenues” and “earnings” series and data as index and EPS rows.

Return type:

tuple

static ShareRevenueEarningsEpsChart.get_options(df)[source]#

Compiles Highcharts chart options which is later passed to highcarts vue component.

Parameters:

df (pd.DataFrame) – Dataframe with earings and revenues returned by self.get_data().

Returns:

Highcharts options as a dict.

Return type:

dict

class richy.core.charts.ShareEpsChart[source]#

Bases: object

Highcharts EPS chart for shares.

ShareEpsChart.get_options(rows)[source]#

Compiles Highcharts chart options (which is later passed to highcarts vue component) with data sorted by date (first column).

Parameters:

rows (list) – Table EPS rows without headers and Announcement date column.

Returns:

Highcharts option dict.

Return type:

dict

class richy.core.charts.ShareAnalystRatingsChart(user_item)[source]#

Bases: object

Highcharts analyst ratings chart for shares.

ShareAnalystRatingsChart.get_options()[source]#

Compiles Highcharts chart options (which is later passed to highcarts vue component) for each ratings record in the database.

Returns:

List of Highcharts option dicts.

Return type:

list

class richy.core.charts.SharePriceRatingsChart(user_item)[source]#

Bases: object

Highcharts Price ratings chart for shares.

SharePriceRatingsChart.get_options(rows)[source]#

Compiles Highcharts options (which is later passed to highcharts vue component) for price ratings.

Parameters:

rows (list) – Table price ratings rows.

Returns:

Highcharts option object.

Return type:

dict