Front‐End Views and Functions - supertypeai/sectors-kb GitHub Wiki

This section focuses on the views that are directly utilized by the front-end application.

Growth Forecast

For every front-end features that use growth forecast data which source of growth forecast data can be obtained through idx_company_report table - company_growth_forecasts column and company_value_forecasts column, idx_company_forecast table, and idx_company_growth_forecast view. There are some conditions for the data especially for the eps_growth and eps_estimates value.

  • eps_growth: For every eps_growth that has value 1 or -1, it should be changed to NULL in the front-end.
  • eps_estimates: For every eps_estimates that has value 0, it should be changed to Null in the front-end.

For the bar chart in each company future section, it should be stated that there is no data available (in addition the tooltips too) if the eps_estimates value is 0.

idx_sector_reports - Reference

idx_company_report - Reference

RPC Functions

  • get_idx_market_cap(): Get the total market cap across all active companies in IDX
  • get_idx_pe(): Get the weighted avg of PE (weighted by their respective market cap), unweighted avg of PE, and median of PE across all active companies in IDX
  • get_idx_resilience(): Get the weighted average of maximum drawdown (weighted by their respective market cap), median of maximum drawdown, weighted average of RSD (weighted by their respective market cap), and median of RSD in the last 365 days across all active companies in IDX. Note: RSD is the relative standard deviation of the daily closing price.
  • get_market_cap_rank(in_symbol): Get the input company's market cap rank across all active IDX companies. Example arg for in_symbol: 'BBCA.JK'
  • get_peers_company(p_symbol): Get financial information about the peer companies in the same group of sector, sub_sector, industry, and sub_industry as the input company. For each group, the top 9 companies with the highest market cap and the input company are returned. Example arg for p_symbol: 'BBCA.JK'. Example response:
{"companies":[
    {"group":["sector","sub_sector"],
     "pb_mrq":0.822825036039708,
     "pe_ttm":10.2536555074538,
     "symbol":"PGAS.JK", 
     ...},
    ...
    ],
"group_name":{"sector":"Energy","industry":"Coal","sub_sector":"Oil, Gas & Coal","sub_industry":"Coal Production"}}
  • get_peers_and_idx_valuation_summary(p_sub_sector): Get the minimum, maximum, q1, median and q3 of PB, PE, PS and get the median EV/Revenue accross all active companies in the input subsector. Example arg for p_sub_sector_slug: 'basic-materials'.
  • get_idx_growth_forecasts(): Get the weighted average of growth forecasts (EPS growth and revenue growth) across all active companies in IDX. Returns a JSON array containing a list of objects, each object represents the growth forecast for a specific year (estimate_year). Result example:
[
{"base_year": the year of the annual report for which the base eps and revenue is obtained
"estimate_year": the year for which the forecasted eps and revenue is obtained
"eps_growth": the growth of forecasted eps vs the base eps
"revenue_growth": the growth of forecasted revenue vs the base revenue},
{...}
]
  • get_idx_peers_growth_and_forecasts(p_sector, p_sub_sector): This function retrieves comprehensive growth metrics and forecasts for active companies in IDX, with optional filtering by subsector or sector. Features: Calculates the Q1, median, and Q3 of forecasted revenue growth (latest available revenue forecast compared to the latest annual financial report). Growth Forecasts: Provides a weighted average of growth forecasts (EPS growth and revenue growth) across all active companies, grouped by estimate_year. Input Arguments: p_sector: Specify a sector to get growth metrics and forecasts for companies within that sector. Example: 'Energy'. p_subsector_slug: Specify a subsector to get growth metrics and forecasts for companies within that subsector. Example: 'basic-materials'. Output: Returns a JSON array containing: Growth Metrics: Q1, median, Q3 for revenue growth. Growth Forecasts: A list of objects, each representing forecasted growth for a specific year (estimate_year). Each object includes: Weighted average of EPS growth. Weighted average of revenue growth.
  • get_top_subsector_mcap_change_1w(top_n): Get the top-n subsectors with the highest market cap change in 1-week period. Example arg for top_n: 10
  • get_subsector_total_volume(start_date, end_date, sub_sector_slug): Calculates the total volume of stock trading for a specified date range and sub-sector. Example arg for start_date: '2023-12-01', end_date: '2023-12-25', sub_sector_slug: 'basic-materials'
  • get_top_subsector_mcap_change_1w(top_n): Get the top n subsectors with the highest market cap change in 1 week. Example arg for top_n: 10
  • get_peers_yield_ttm(p_subsector_slug): Get the median of trailing twelve months dividend yield across active companies in the input subsector. Companies that do not give any dividends in the last twelve months are excluded. Example arg for p_subsector_slug: 'basic-materials'
  • get_idx_yield_ttm(): Get the median of trailing twelve months dividend yield across active companies in IDX. Companies that do not give any dividends in the last twelve months are excluded.
  • get_top_gainers(n int): Returns a json returning top n symbols for highest positive change in price for each period of: 1d, 7d, 14d, 30d, 365. It will only include companies with market cap over 5e12.
  • get_top_losers(n int): Returns a json returning top n symbols for highest negative change in price for each period of: 1d, 7d, 14d, 30d, 365. It will only include companies with market cap over 5e12.
  • get_top_gainers_abs_mcap_30d(n): Get the top n symbols with the highest positive absolute mcap change over the past 30 days, filtered with a minimum market capitalization of 5T IDR. Example arg for n: 10. get_top_gainers_abs_mcap_7d(n int) is also available.
  • get_top_losers_abs_mcap_30d(n): Get the top n symbols with the highest negative absolute mcap change over the past 30 days, filtered with a minimum market capitalization of 5T IDR. Example arg for n: 10. get_top_losers_abs_mcap_7d(n int) is also available.
  • get_idx_mcap_change_ytd(): Get the percentage change in IDX market cap from the start of the year.
  • get_idx_mcap_change_30d(): Get the percentage change in IDX market cap over the past 30 days. get_idx_mcap_change_7d() is also available.
  • get_idx_mcap_data_1m(): Get the IDX market cap in the last 30 days.
  • get_idx_most_traded_1d(n int): Get the stock with the highest volume in the past 1 day.
  • get_idx_most_traded(start_date date, end_date date, n_stock int, adjusted=True): Returns top n most traded stocks based on volume multiplied by close price (or volume only if adjusted is set to False). The returned value will be n stocks for every trading days between start_date and end_date.
  • get_idx_most_traded(n_days int, n_stock int, adjusted=True): Returns top n_stock most traded stocks based on volume multiplied by close price (or volume only if adjusted is set to False). The returned value will be n_stocks for the latest n_days trading days.
  • get_top_mcap_gainers(n int): Returns a json returning top n symbols for highest positive change in market cap for each period of: 7d, 14d, 30d. It will only include companies with market cap over 5e12.
  • get_top_mcap_losers(n int): Returns a json returning top n symbols for highest neagtive change in market cap for each period of: 7d, 14d, 30d. It will only include companies with market cap over 5e12.
  • get_idx_volume(start_date date, end_date date): Calculates and returns the total trading volume for each day within a specified date range, ordered by date
  • get_idx_volume(n_days int): Calculate the total trading volume for each of the latest n_days trading days
  • get_stock_watchlist(symbols text[]): Get the data needed to populate stock tables in watchlist page.
  • get_news_by_user_vote(user_id int): Get all the news which a user upvotes