Skip to content

Quote Module

Module for parsing quote header data from a yahoo finance page.

clean_quote_name

def clean_quote_name(value: str) -> str

Remove the symbol and strip whitespace from the company name.

Arguments:

  • value str - A company name string parsed from the quote header portion of any yahoo finance page.

Example:

Input Output
Apple Inc. (AAPL) Apple Inc.

Returns:

  • str - Company name with the ticker symbol removed.

Quote

Represents all the data parsed from the quote header section of a yahoo finance page.

Attributes:

  • name str - Company name.
  • close float - Close price.
  • change float - Dollar change in price.
  • percent_change float - Percent change in price.

Notes:

This class inherits from the pydantic BaseModel which allows for the use of .json() and .dict() for serialization to json strings and dictionaries.

  • .json() - Serialize to a JSON object.
  • .dict() - Serialize to a dictionary.

parse_quote_header_info

def parse_quote_header_info(html: HTML) -> Optional[Quote]

Parse and clean html elements from the quote header info portion of a yahoo finance page.

Arguments:

  • html HTML - An HTML object containing quote header info data ready to be parse.

Returns:

  • Quote - Quote object containing the parsed quote header data if successfully parsed.
  • None - No quote header info data present in the HTML.