Available modules

Submodules

stockdex.config module

stockdex.digrin_interface module

Module to extract data from Digrin website

class stockdex.digrin_interface.DigrinInterface(ticker: str = '', isin: str = '', security_type: Literal['stock', 'etf', 'cryptocurrency', 'index', 'commodity'] = 'stock')[source]

Bases: TickerBase

property digrin_assets_vs_liabilities: DataFrame

Get assets vs liabilities for the ticker

Returns: pd.DataFrame: A pandas DataFrame including the assets vs liabilities visible in the digrin website for the ticker

property digrin_cash_and_debt: DataFrame

Get cash and debt for the ticker

Returns: pd.DataFrame: A pandas DataFrame including the cash and debt visible in the digrin website for the ticker

property digrin_cost_of_revenue: DataFrame

Get cost of revenue for the ticker

Returns: pd.DataFrame: A pandas DataFrame including the cost of revenue visible in the digrin website for the ticker

property digrin_dgr10: DataFrame

Get dgr10 for the ticker

Returns: pd.DataFrame: A pandas DataFrame including the dgr10 visible in the digrin website for the ticker

property digrin_dgr3: DataFrame

Get dgr3 for the ticker

Returns: pd.DataFrame: A pandas DataFrame including the dgr3 visible in the digrin website for the ticker

property digrin_dgr5: DataFrame

Get dgr5 for the ticker

Returns: pd.DataFrame: A pandas DataFrame including the dgr5 visible in the digrin website for the ticker

property digrin_dividend: DataFrame

Get dividends for the ticker

Args: period (str): The period for the dividends

Returns: pd.DataFrame: A pandas DataFrame including the dividends visible in the digrin website for the ticker

property digrin_expenses: DataFrame

Get expenses for the ticker

Returns: pd.DataFrame: A pandas DataFrame including the expenses visible in the digrin website for the ticker

property digrin_free_cash_flow: DataFrame

Get free cash flow for the ticker

Returns: pd.DataFrame: A pandas DataFrame including the free cash flow visible in the digrin website for the ticker

property digrin_net_income: DataFrame

Get net income for the ticker

Returns: pd.DataFrame: A pandas DataFrame including the net income visible in the digrin website for the ticker

property digrin_payout_ratio: DataFrame

Get payout ratio for the ticker

Returns: pd.DataFrame: A pandas DataFrame including the payout ratio visible in the digrin website for the ticker

property digrin_price: DataFrame

Get price for the ticker

Returns: pd.DataFrame: A pandas DataFrame including the price visible in the digrin website for the ticker

property digrin_shares_outstanding: DataFrame

Get shares outstanding for the ticker

Returns: pd.DataFrame: A pandas DataFrame including the shares outstanding visible in the digrin website for the ticker

property digrin_stock_splits: DataFrame

Get stock splits for the ticker

Returns: pd.DataFrame: A pandas DataFrame including the stock splits visible in the digrin website for the ticker

property digrin_upcoming_estimated_earnings: DataFrame

Get upcoming estimated earnings for the ticker

Returns: pd.DataFrame: A pandas DataFrame including the upcoming estimated earnings visible in the digrin website for the ticker

plot_digrin_assets_vs_liabilities(show_plot: bool = True) line | bar[source]

Plot the assets vs liabilities for the ticker

Args:

show_plotbool

If the plot should be shown or not. If dash is used, this should be set to False Default is True (show the plot)

Returns:

Union[px.line, px.bar]: The plotly figure

plot_digrin_cash_and_debt(show_plot: bool = True) line | bar[source]

Plot the cash and debt for the ticker

Args:

show_plotbool

If the plot should be shown or not. If dash is used, this should be set to False Default is True (show the plot)

Returns:

Union[px.line, px.bar]: The plotly figure

plot_digrin_cost_of_revenue(show_plot: bool = True) line | bar[source]

Plot the cost of revenue for the ticker

Args:

show_plotbool

If the plot should be shown or not. If dash is used, this should be set to False Default is True (show the plot)

Returns:

Union[px.line, px.bar]: The plotly figure

plot_digrin_dividend(show_plot: bool = True) line | bar[source]

Plot the dividend for the ticker

Args:

show_plotbool

If the plot should be shown or not. If dash is used, this should be set to False Default is True (show the plot)

Returns:

Union[px.line, px.bar]: The plotly figure

plot_digrin_expenses(show_plot: bool = True) line | bar[source]

Plot the expenses for the ticker

Args:

show_plotbool

If the plot should be shown or not. If dash is used, this should be set to False Default is True (show the plot)

Returns:

Union[px.line, px.bar]: The plotly figure

plot_digrin_free_cash_flow(show_plot: bool = True) line | bar[source]

Plot the free cash flow for the ticker

Args:

show_plotbool

If the plot should be shown or not. If dash is used, this should be set to False Default is True (show the plot)

Returns:

Union[px.line, px.bar]: The plotly figure

plot_digrin_net_income(show_plot: bool = True) line | bar[source]

Plot the net income for the ticker

Args:

show_plotbool

If the plot should be shown or not. If dash is used, this should be set to False Default is True (show the plot)

Returns:

Union[px.line, px.bar]: The plotly figure

plot_digrin_price(show_plot: bool = True) line | bar[source]

Plot the price for the ticker

Args:

show_plotbool

If the plot should be shown or not. If dash is used, this should be set to False Default is True (show the plot)

Returns:

Union[px.line, px.bar]: The plotly figure

plot_digrin_shares_outstanding(show_plot: bool = True) line | bar[source]

Plot the shares outstanding for the ticker

Args:

show_plotbool

If the plot should be shown or not. If dash is used, this should be set to False Default is True (show the plot)

Returns:

Union[px.line, px.bar]: The plotly figure

stockdex.exceptions module

Module for custom exceptions

exception stockdex.exceptions.FieldNotExists(available_fields: list, message: str = 'Field does not exist', given_field: str = None)[source]

Bases: Exception

The exception to be shown when a field is called that does not exist in the dataframe

exception stockdex.exceptions.NoDataError(message: str = 'No data found')[source]

Bases: Exception

exception stockdex.exceptions.NoISINError(message: str = 'No ISIN provided')[source]

Bases: Exception

exception stockdex.exceptions.WrongDataSource(given_source: str = None)[source]

Bases: Exception

The exception to be shown when a method is called on the wrong data source

exception stockdex.exceptions.WrongSecurityType(message: str = 'Wrong security type', valid_types: list = None, given_type: str = None)[source]

Bases: Exception

The exception to be shown when a method is called on the wrong security type

stockdex.justetf_interface module

Module for extracting ETF data from JustETF website

class stockdex.justetf_interface.JustETF(ticker: str = '', isin: str = '', security_type: Literal['stock', 'etf', 'cryptocurrency', 'index', 'commodity'] = 'etf')[source]

Bases: TickerBase

property justetf_basics: DataFrame

Get the baisc information of the ETF

columns may include: - Fund size - Fund domicile - Legal structure - Replication

Args:

isin (str): ISIN of the ETF

Returns:

pd.DataFrame: DataFrame containing the basic information of the ETF

property justetf_description: str

Get the description of the ETF

property justetf_general_info: DataFrame

Get the general information of the ETF genral information includes TER, distribution policy, replication method, etc.

property justetf_holdings_companies: DataFrame

Get the top 10 holdings of the ETF by companies

columns may include: - company name - shares in percent

Args:

isin (str): ISIN of the ETF

Returns:

pd.DataFrame: DataFrame containing the holdings of the ETF

property justetf_holdings_countries: DataFrame

Get the top 10 holdings of the ETF by countries

columns may include: - country name - shares in percent

Args:

isin (str): ISIN of the ETF

Returns:

pd.DataFrame: DataFrame containing the holdings of the ETF

property justetf_holdings_sectors: DataFrame

Get the top 10 holdings of the ETF by sectors

columns may include: - sector name - shares in percent

Args:

isin (str): ISIN of the ETF

Returns:

pd.DataFrame: DataFrame containing the holdings of the ETF

property justetf_price: DataFrame

Get the basic pricing information of the ETF return data frame with columns:

  • price

  • currency

  • date

  • time

  • exchange

  • daily_change

  • daily_change_percent

  • buy|sell

  • spread

Returns:

pd.DataFrame: DataFrame containing the pricing information

property justetf_wkn: str

Get the WKN of the ETF

stockdex.lib module

stockdex.lib.check_security_type(security_type: str, valid_types: str | list) None[source]

Check if the security type is valid

stockdex.lib.get_user_agent()[source]
stockdex.lib.plot_dataframe(dataframe: DataFrame, title: str, barmode: str = 'group', logaritmic: bool = False, template: str = 'plotly', y_axis_title: str = 'Amount', x_axis_title: str = 'Date', draw_line_chart: bool = False, show_plot: bool = True) None[source]

Plot a DataFrame using Plotly Express

Parameters:
  • dataframe (pd.DataFrame) – The DataFrame to plot

  • title (str) – The title of the plot

  • barmode (str) – The barmode of the plot default: “group”

  • logaritmic (bool) – If the y-axis should be logaritmic default: False

  • template (str) – The template of the plot. One of plotly, plotly_white, plotly_dark, ggplot2, seaborn, simple_white, none default: “plotly”#

  • y_axis_title (str) – The title of the y-axis default: “Amount”

  • x_axis_title (str) – The title of the x-axis default: “Date”

  • draw_line_chart (bool) – If the plot should be a line chart and not bar. For charts that have too many data points, it is recommended to use line charts instead of bar charts as it is easier to read. default: False (bar chart)

  • show_plot (bool) – If the plot should be shown. Setting this to False will only return the plot object. Can be used to save the plot to a file or construct complex dashboards with multiple plots. default: True

stockdex.lib.plot_multiple_categories(ticker: str, figures: List[bar | line], app_port: int = 8050) None[source]

Plot multiple categories in a single Dash app.

Parameters:
  • figures (List[Union[px.bar, px.line]]) – A list of Plotly Express bar or line objects

  • app_port (int) – The port to run the Dash app on default: 8050

stockdex.macrotrends_interface module

Module for interfacing with the Macrotrends website.

class stockdex.macrotrends_interface.MacrotrendsInterface(ticker: str = '', isin: str = '', security_type: Literal['stock', 'etf', 'cryptocurrency', 'index', 'commodity'] = 'stock')[source]

Bases: TickerBase

Interface for interacting with the Macrotrends website.

property full_name: str

Retrieve the full name of the security.

property macrotrends_balance_sheet: DataFrame

Retrieve the balance sheet for the given ticker.

property macrotrends_cash_flow: DataFrame

Retrieve the cash flow statement for the given ticker.

property macrotrends_ebitda_margin: DataFrame

Retrieve the EBITDA margin for the given ticker.

property macrotrends_gross_margin: DataFrame

Retrieve the gross margin for the given ticker.

property macrotrends_income_statement: DataFrame

Retrieve the income statement for the given ticker.

property macrotrends_key_financial_ratios: DataFrame

Retrieve the key financial ratios for the given ticker.

property macrotrends_net_margin: DataFrame

Retrieve the net profit margin for the given ticker.

property macrotrends_operating_margin: DataFrame

Retrieve the operating margin for the given ticker.

property macrotrends_pre_tax_margin: DataFrame

Retrieve the pre-tax margin for the given ticker.

plot_macrotrends_balance_sheet(fields_to_include: list = ['Cash On Hand', 'Total Assets', 'Total Liabilities'], group_by: Literal['field', 'timeframe'] = 'timeframe', show_plot: bool = True) line | bar[source]

Plot the balance sheet for the given ticker.

Args:

show_plotbool

If the plot should be shown or not. If dash is used, this should be set to False Default is True (show the plot)

Returns:

Union[px.line, px.bar]: The plotly figure

plot_macrotrends_cash_flow(fields_to_include: list = ['Net Income\\/Loss', 'Common Stock Dividends Paid', 'Net Long-Term Debt'], group_by: Literal['field', 'timeframe'] = 'timeframe', show_plot: bool = True) None[source]

Plot the cash flow statement for the given ticker.

Args:

show_plotbool

If the plot should be shown or not. If dash is used, this should be set to False Default is True (show the plot)

Returns:

Union[px.line, px.bar]: The plotly figure

plot_macrotrends_income_statement(fields_to_include: list = ['Revenue', 'Income After Taxes'], group_by: Literal['field', 'timeframe'] = 'timeframe', show_plot: bool = True) line | bar[source]

Plot the income statement for the given ticker.

Args:

show_plotbool

If the plot should be shown or not. If dash is used, this should be set to False Default is True (show the plot)

Returns:

Union[px.line, px.bar]: The plotly figure

stockdex.nasdaq_interface module

Interface for NASDAQ stock data

class stockdex.nasdaq_interface.NASDAQInterface(ticker: str = '', isin: str = '', security_type: Literal['stock', 'etf', 'cryptocurrency', 'index', 'commodity'] = 'stock')[source]

Bases: TickerBase

property forecast_peg_rate: DataFrame

Get the forecast price to earning growth rate for the stock

Returns:

pd.DataFrame: Forecast price to earning growth rate data

property price_to_earnings_ratio: DataFrame

Get the price to earnings ratio for the stock

Returns:

pd.DataFrame: Price to earnings ratio data

property quarterly_earnings_forecast: DataFrame

Get quarterly earnings forecast for the stock

Returns:

pd.DataFrame: Quarterly earnings forecast data The columns might include: - Fiscal Quarter End - Consensus EPS* Forecast - High EPS* Forecast - Low EPS* Forecast - Number Of Estimates - Over The Last 4 Weeks Number Of Revisions - Up - Over The Last 4 Weeks Number Of Revisions - Down

property quarterly_earnings_surprise: DataFrame

Get quarterly earnings for the stock

Returns:

pd.DataFrame: Quarterly earnings surprise data The columns might include: - ‘Fiscal Quarter End’ - ‘Date Reported’ - ‘Earnings Per Share*’ - ‘Consensus EPS* Forecast’ - ‘% Surprise’

property yearly_earnings_forecast: DataFrame

Get yearly earnings for the stock

Returns:

pd.DataFrame: Yearly earnings data The columns might include: - Fiscal Year End - Consensus EPS* Forecast - High EPS* Forecast - Low EPS* Forecast - Number Of Estimates - Over The Last 4 Weeks Number Of Revisions - Up - Over The Last 4 Weeks Number Of Revisions - Down

stockdex.sankey_charts module

Module to draw sankey charts

class stockdex.sankey_charts.SankeyCharts(ticker: str)[source]

Bases: TickerBase

plot_sankey_chart(frequency: Literal['annual', 'quarterly'] = 'annual', period_ago: int = 0) None[source]

Main function to plot the sankey chart

Args:

frequency: str

The frequency of the data to be used. It can be either “annual” or “quarterly”. Default is “annual”

period_ago: int

The period to go back. Default is 0. if a non zero value, e.g. 3 is provided, the data for 3 periods ago will be used (annual or quarterly based on the frequency)

Returns:

None

stockdex.selenium_interface module

class stockdex.selenium_interface.selenium_interface(use_custom_user_agent: bool = False)[source]

Bases: object

click_on_element(xpath: str, driver: WebDriver, wait_time: int = 3)[source]

Method that clicks on an element

get_html_content(url: str) str[source]

Method to fetch the HTML content of a webpage using Selenium

Args:

url (str): URL of the webpage

Returns:

str: HTML content of the webpage in prettified format

just_etf_get_html_after_click(url: str, button_xpath: str) BeautifulSoup[source]

Opens a webpage, clicks a button and returns the updated HTML. It is specifically designed for JustETF module.

Args:

url (str): The URL of the page to load. button_xpath (str): The XPath of the button to click. wait_time (int): The time to wait after clicking for the page to update.

Returns:

BeautifulSoup: Parsed HTML after the button click.

stockdex.ticker module

class stockdex.ticker.Ticker(ticker: str = '', isin: str = '', security_type: Literal['stock', 'etf', 'cryptocurrency', 'index', 'commodity'] = 'stock')[source]

Bases: YahooAPI, JustETF, DigrinInterface, YahooWeb, MacrotrendsInterface, SankeyCharts

Class for the Ticker

stockdex.ticker_base module

Base class for ticker objects to inherit from

class stockdex.ticker_base.TickerBase[source]

Bases: object

find_parent_by_text(soup: BeautifulSoup, tag: str, text: str, condition: dict = {}, skip: int = 0) None | str[source]

Method that finds the parent of a tag by its text from a BeautifulSoup object

Args:

soup: BeautifulSoup

The BeautifulSoup object to search

tag: str

The tag to search for

text: str

The text to search for

condition: dict

The condition to search for

skip: int

The number of elements to skip before returning the parent

Returns:

Union[None, str]: The parent of the tag if it exists, None otherwise

get_response(url: str) Response[source]

Send an HTTP GET request to the website

Args:

url: str

The URL to send the HTTP GET request to

Returns:

requests.Response

The response from the website

logger = <Logger stockdex.ticker_base (WARNING)>
request_headers = {'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36'}

stockdex.yahoo_api_interface module

Module to retrieve stock data from Yahoo Finance API The main Ticker class inherits from this class

class stockdex.yahoo_api_interface.YahooAPI(ticker: str = '', isin: str = '', security_type: Literal['stock', 'etf', 'cryptocurrency', 'index', 'commodity'] = 'stock', data_source: Literal['yahoo_web', 'yahoo_api', 'justetf', 'digrin'] = 'yahoo_api')[source]

Bases: TickerBase

build_url(frequency: str, period1: datetime, period2: datetime, desired_entity: str) str[source]

Build the URL for the income statement, balance sheet, and cash flow statement

Args:

frequency: str

The frequency of the data to retrieve valid values are “annual”, “quarterly”

period1: datetime

The start date of the data to retrieve

period2: datetime

The end date of the data to retrieve

desired_entity: str

The entity to retrieve the data for

Returns:

str: The URL to retrieve the data from

extract_dataframe(response, format='fmt') DataFrame[source]

Extract the dataframes from the response

Args:

response: dict

The response from the API

format: str

The format of the data to retrieve

Returns:

pd.DataFrame: The data in a dataframe

five_years_ago = datetime.datetime(2020, 3, 6, 6, 25, 54, 391360)
plot_yahoo_api_balance_sheet(frequency: Literal['annual', 'quarterly'] = 'annual', period1: datetime = datetime.datetime(2020, 3, 6, 6, 25, 54, 391360), period2: datetime = datetime.datetime(2025, 3, 6, 6, 25, 54, 391360), group_by: Literal['timeframe, field'] = 'timeframe', fields_to_include: list = ['TotalAssets', 'TotalDebt'], show_plot: bool = True) line | bar[source]

Plots the balance sheet for the stock using matplotlib grouped bar chart

Parameters:
  • frequency (str) – The frequency of the data to retrieve valid values are “annual”, “quarterly”

  • period1 (datetime) – The start date of the data to retrieve

  • period2 (datetime) – The end date of the data to retrieve

  • group_by (str) – The group by parameter

  • fields_to_include (list) – The fields to include in the chart in the x-axis

  • show_plot (bool) – If the plot should be shown or not. If dash is used, this should be set to False Default is True (show the plot)

  • Returns

  • ----------------

  • Union[px.line (The plotly figure) –

  • px.bar] (The plotly figure) –

plot_yahoo_api_cash_flow(frequency: Literal['annual', 'quarterly'] = 'annual', period1: datetime = datetime.datetime(2020, 3, 6, 6, 25, 54, 391360), period2: datetime = datetime.datetime(2025, 3, 6, 6, 25, 54, 391360), group_by: Literal['timeframe, field'] = 'timeframe', fields_to_include: list = ['OperatingCashFlow', 'FreeCashFlow'], show_plot: bool = True) line | bar[source]

Plots the cash flow statement for the stock using matplotlib grouped bar chart

Parameters:
  • frequency (str) – The frequency of the data to retrieve valid values are “annual”, “quarterly”

  • period1 (datetime) – The start date of the data to retrieve

  • period2 (datetime) – The end date of the data to retrieve

  • group_by (str) – The group by parameter

  • fields_to_include (list) – The fields to include in the chart in the x-axis

  • show_plot (bool) – If the plot should be shown or not. If dash is used, this should be set to False Default is True (show the plot)

  • Returns

  • ----------------

  • Union[px.line (The plotly figure) –

  • px.bar] (The plotly figure) –

plot_yahoo_api_financials(frequency: Literal['annual', 'quarterly'] = 'annual', period1: datetime = datetime.datetime(2020, 3, 6, 6, 25, 54, 391360), period2: datetime = datetime.datetime(2025, 3, 6, 6, 25, 54, 391360), group_by: Literal['timeframe, field'] = 'timeframe', fields_to_include: list = ['TotalRevenue', 'EBITDA', 'TotalExpenses', 'NetIncomeCommonStockholders', 'NetIncome'], show_plot: bool = True) line | bar[source]

Plots the financials for the stock using matplotlib grouped bar chart

Parameters:
  • frequency (str) – The frequency of the data to retrieve valid values are “annual”, “quarterly”

  • period1 (datetime) – The start date of the data to retrieve

  • period2 (datetime) – The end date of the data to retrieve

  • group_by (str) – The group by parameter

  • fields_to_include (list) – The fields to include in the chart in the x-axis

  • show_plot (bool) – If the plot should be shown or not. If dash is used, this should be set to False Default is True (show the plot)

  • Returns

  • ----------------

  • Union[px.line (The plotly figure) –

  • px.bar] (The plotly figure) –

plot_yahoo_api_income_statement(frequency: Literal['annual', 'quarterly'] = 'annual', period1: datetime = datetime.datetime(2020, 3, 6, 6, 25, 54, 391360), period2: datetime = datetime.datetime(2025, 3, 6, 6, 25, 54, 391360), group_by: Literal['timeframe, field'] = 'timeframe', fields_to_include: list = ['TotalRevenue', 'EBITDA', 'TotalExpenses', 'NetIncomeCommonStockholders', 'NetIncome'], show_plot: bool = True) line | bar[source]

Plots the income statement for the stock using matplotlib grouped bar chart

Parameters:
  • frequency (str) – The frequency of the data to retrieve valid values are “annual”, “quarterly”

  • period1 (datetime) – The start date of the data to retrieve

  • period2 (datetime) – The end date of the data to retrieve

  • group_by (str) – The group by parameter

  • fields_to_include (list) – The fields to include in the chart in the x-axis

  • show_plot (bool) – If the plot should be shown or not. If dash is used, this should be set to False Default is True (show the plot)

  • Returns

  • ----------------

  • Union[px.line (The plotly figure) –

  • px.bar] (The plotly figure) –

today = datetime.datetime(2025, 3, 6, 6, 25, 54, 391360)
yahoo_api_balance_sheet(frequency: Literal['annual', 'quarterly'] = 'annual', format: Literal['fmt', 'raw'] = 'fmt', period1: datetime = datetime.datetime(2020, 3, 6, 6, 25, 54, 391360), period2: datetime = datetime.datetime(2025, 3, 6, 6, 25, 54, 391360)) DataFrame[source]

Get the balance sheet for the stock

Args:

frequency (str): The frequency of the data to retrieve valid values are “annual”, “quarterly”

format (str): The format of the data to retrieve valid values are “fmt”, “raw” if “fmt” is used, the data will be in a human readable format, e.g. 1B if “raw” is used, the data will be in a raw format, e.g. 1000000000

period1 (datetime): The start date of the data to retrieve default is five years ago as that is the maximum period the API supports data retrieval for

period2 (datetime): The end date of the data to retrieve default is the current date

Returns:

pd.DataFrame: The balance sheet data

yahoo_api_cash_flow(frequency: Literal['annual', 'quarterly'] = 'annual', format: Literal['fmt', 'raw'] = 'fmt', period1: datetime = datetime.datetime(2020, 3, 6, 6, 25, 54, 391360), period2: datetime = datetime.datetime(2025, 3, 6, 6, 25, 54, 391360)) DataFrame[source]

Get the cash flow statement for the stock

Args:

frequency (str): The frequency of the data to retrieve valid values are “annual”, “quarterly”

format (str): The format of the data to retrieve valid values are “fmt”, “raw” if “fmt” is used, the data will be in a human readable format, e.g. 1B if “raw” is used, the data will be in a raw format, e.g. 1000000000

period1 (datetime): The start date of the data to retrieve default is five years ago as that is the maximum period the API supports data retrieval for

period2 (datetime): The end date of the data to retrieve default is the current date

Returns:

pd.DataFrame: The cash flow statement data

property yahoo_api_current_trading_period: DataFrame

Get the current trading period for the stock

yahoo_api_financials(frequency: Literal['annual', 'quarterly'] = 'annual', format: Literal['fmt', 'raw'] = 'fmt', period1: datetime = datetime.datetime(2020, 3, 6, 6, 25, 54, 391360), period2: datetime = datetime.datetime(2025, 3, 6, 6, 25, 54, 391360)) DataFrame[source]

Get the financials for the stock

Args:

frequency (str): The frequency of the data to retrieve valid values are “annual”, “quarterly”

format (str): The format of the data to retrieve valid values are “fmt”, “raw” if “fmt” is used, the data will be in a human readable format, e.g. 1B if “raw” is used, the data will be in a raw format, e.g. 1000000000

period1 (datetime): The start date of the data to retrieve default is five years ago as that is the maximum period the API supports data retrieval for

period2 (datetime): The end date of the data to retrieve default is the current date

Returns:

pd.DataFrame: The financials data

yahoo_api_income_statement(frequency: Literal['annual', 'quarterly'] = 'annual', format: Literal['fmt', 'raw'] = 'fmt', period1: datetime = datetime.datetime(2020, 3, 6, 6, 25, 54, 391360), period2: datetime = datetime.datetime(2025, 3, 6, 6, 25, 54, 391360)) DataFrame[source]

Get the income statement for the stock

Args:

frequency (str): The frequency of the data to retrieve valid values are “annual”, “quarterly”

format (str): The format of the data to retrieve valid values are “fmt”, “raw” if “fmt” is used, the data will be in a human readable format, e.g. 1B if “raw” is used, the data will be in a raw format, e.g. 1000000000

period1 (datetime): The start date of the data to retrieve default is five years ago as that is the maximum period the API supports data retrieval for

period2 (datetime): The end date of the data to retrieve default is the current date

Returns:

pd.DataFrame: The income statement data

yahoo_api_price(range: Literal['1d', '5d', '1mo', '3mo', '6mo', '1y', '2y', '5y', '10y', 'ytd', 'max'] = '1d', dataGranularity: Literal['1m', '2m', '5m', '15m', '30m', '60m', '90m', '1h', '1d', '5d', '1wk', '1mo', '3mo'] = '1m') DataFrame[source]

Get the price data for the stock

Args:

range (str): The range of the price data to retrieve valid values are “1d”, “5d”, “1mo”, “3mo”, “6mo”, “1y”, “2y”, “5y”, “10y”, “ytd”, “max”

dataGranularity (str): The granularity of the data to retrieve (interval) valid values are “1m”, “2m”, “5m”, “15m”, “30m”, “60m”, “90m”, “1h”, “1d”, “5d”, “1wk”, “1mo”, “3mo”” # noqa: E501

Returns:

pd.DataFrame: The price data

stockdex.yahoo_web_interface module

Module for fetching data from Yahoo Finance website

class stockdex.yahoo_web_interface.YahooWeb(ticker: str = '', isin: str = '', security_type: Literal['stock', 'etf', 'cryptocurrency', 'index', 'commodity'] = 'stock')[source]

Bases: TickerBase

property yahoo_web_balance_sheet: DataFrame

Get balance sheet for the ticker

Returns: pd.DataFrame: A pandas DataFrame including the balance sheet visible in the Yahoo Finance statistics page for the ticker

property yahoo_web_calls: DataFrame

Get calls for the ticker

Returns: pd.DataFrame: A pandas DataFrame including the calls visible in the Yahoo Finance statistics page for the ticker

property yahoo_web_cashflow: DataFrame

Get cash flow for the ticker

Returns: pd.DataFrame: A pandas DataFrame including the cash flow visible in the Yahoo Finance statistics page for the ticker

property yahoo_web_corporate_governance: str

Get the description of the ticker

Returns: str: A string including the description of the ticker visible in the Yahoo Finance profile page for the ticker

property yahoo_web_description: str

Get the description of the ticker

Returns: str: A string including the description of the ticker visible in the Yahoo Finance profile page for the ticker

property yahoo_web_earnings_estimate: DataFrame

Get earnings estimate for the ticker

Returns:

pd.DataFrame: A pandas DataFrame including the earnings estimate visible in the Yahoo Finance statistics page for the ticker

property yahoo_web_earnings_history: DataFrame

Get earnings history for the ticker

Returns:

pd.DataFrame: A pandas DataFrame including the earnings history visible in the Yahoo Finance statistics page for the ticker

property yahoo_web_eps_revisions: DataFrame

Get EPS revisions for the ticker

Returns:

pd.DataFrame: A pandas DataFrame including the EPS revisions visible in the Yahoo Finance statistics page for the ticker

property yahoo_web_eps_trend: DataFrame

Get EPS trend for the ticker

Returns:

pd.DataFrame: A pandas DataFrame including the EPS trend visible in the Yahoo Finance statistics page for the ticker

property yahoo_web_financial_highlights: DataFrame

Get financial highlights for the ticker

Returns: pd.DataFrame: A pandas DataFrame including the financial highlights

yahoo_web_financials_table(url: str) DataFrame[source]

Get financials table from the Yahoo Finance website

Args:

url (str)

The URL of the website to scrape

Returns:

pd.DataFrame: A pandas DataFrame including the financials table

property yahoo_web_full_name: str

Get the full name of the ticker

Returns: str: A string including the full name of the ticker visible in the Yahoo Finance profile page for the ticker

property yahoo_web_growth_estimates: DataFrame

Get growth estimates for the ticker

Returns:

pd.DataFrame: A pandas DataFrame including the growth estimates visible in the Yahoo Finance statistics page for the ticker

property yahoo_web_income_stmt: DataFrame

Get income statement for the ticker

Returns: pd.DataFrame: A pandas DataFrame including the income statement visible in the Yahoo Finance statistics page for the ticker

property yahoo_web_key_executives: DataFrame

Get profile key executives for the ticker

Returns: pd.DataFrame: A pandas DataFrame including the profile key executives visible in the Yahoo Finance statistics page for the ticker

property yahoo_web_major_holders: DataFrame

Get major holders for the ticker

Returns: pd.DataFrame: A pandas DataFrame including the major holders visible in the Yahoo Finance statistics page for the ticker

property yahoo_web_puts: DataFrame

Get puts for the ticker

Returns: pd.DataFrame: A pandas DataFrame including the puts visible in the Yahoo Finance statistics page for the ticker

property yahoo_web_revenue_estimate: DataFrame

Get revenue estimate for the ticker

Returns:

pd.DataFrame: A pandas DataFrame including the revenue estimate visible in the Yahoo Finance statistics page for the ticker

property yahoo_web_summary: DataFrame

Get data for the ticker

Returns: pd.DataFrame: A pandas DataFrame including the data visible in the Yahoo Finance first page for the ticker

property yahoo_web_top_institutional_holders: DataFrame

Get top institutional holders for the ticker

Returns: pd.DataFrame: A pandas DataFrame including the top institutional holders visible in the Yahoo Finance statistics page for the ticker

property yahoo_web_top_mutual_fund_holders: DataFrame

Get top mutual fund holders for the ticker

Returns: pd.DataFrame: A pandas DataFrame including the top mutual fund holders visible in the Yahoo Finance statistics page for the ticker

property yahoo_web_trading_information: DataFrame

Get trading information for the ticker

Returns: pd.DataFrame: A pandas DataFrame including the trading information visible in the Yahoo Finance statistics page for the ticker

property yahoo_web_valuation_measures: DataFrame

Get valuation measures for the ticker

Returns: pd.DataFrame: A pandas DataFrame including the valuation measures visible in the Yahoo Finance statistics page for the ticker

Module contents