Exemplo n.º 1
0
    def scrape_balance_sheet(self):
        soup = get_soup(f"{self.base_url}/{self.url_symbol}/financials/balance-sheet")

        # Fetch the price from the top of the page
        price = None
        intraday_price = soup.find("h2", {"class": "intraday__price"})
        if intraday_price:
            price = (
                intraday_price.get_text(strip=True).replace("$", "").replace("€", "")
            )
            if price.isdecimal():
                if price is not None and price != "":
                    price = float(locale.atof(price))
            else:
                price = None
            # TODO - Take the price and convert it a USD value based on country codes
            #   p = British pound?

        total_assets_dict = MWScraper.financials_search(soup, "Total Assets")
        total_liabilities_dict = MWScraper.financials_search(soup, "Total Liabilities")
        return {
            "price": price,
            "assets": total_assets_dict["item"],
            "liabilities": total_liabilities_dict["item"],
        }
Exemplo n.º 2
0
 def scrape_profile(self):
     soup = get_soup(f"{self.base_url}/{self.url_symbol}/company-profile")
     return {
         "curr_ratio": MWScraper.profile_search(soup, "Current Ratio"),
         "pe_ratio": MWScraper.profile_search(soup, "P/E Current"),
         "pb_ratio": MWScraper.profile_search(soup, "Price to Book Ratio"),
         "sector": MWScraper.profile_search(soup, "Sector"),
     }
Exemplo n.º 3
0
 def scrape_quote(self):
     soup = get_soup(f"{self.base_url}/{self.url_symbol}")
     return {
         "div_yield": YFScraper.search_div_yield(soup),
         "eps": YFScraper.quote_search(soup, "EPS_RATIO-value"),
         "mkt_cap": YFScraper.quote_search(soup, "MARKET_CAP-value"),
         "pe_ratio": YFScraper.quote_search(soup, "PE_RATIO-value"),
     }
Exemplo n.º 4
0
 def scrape_summary(self):
     soup = get_soup(f"{self.base_url}/{self.url_symbol}/")
     raw_dividend_yield = soup.find(
         text="Yield"
     ).parent.next_sibling.next_sibling.contents[0]
     dividend_yield = raw_dividend_yield[: len(raw_dividend_yield) - 1]
     return {
         "div_yield": dividend_yield,
     }
Exemplo n.º 5
0
 def scrape_key_stats(self):
     output_dict = {}
     soup = get_soup(f"{self.base_url}/{self.url_symbol}/key-statistics")
     output_dict["bvps"] = YFScraper.key_stats_search(
         soup, "Book Value Per Share", True)
     output_dict["curr_ratio"] = YFScraper.key_stats_search(
         soup, "Current Ratio", True)
     output_dict["payout_ratio"] = YFScraper.key_stats_search(
         soup, "Payout Ratio", False)
     return output_dict
Exemplo n.º 6
0
 def scrape_financials(self):
     soup = get_soup(f"{self.base_url}/{self.url_symbol}/financials")
     eps_dict = MWScraper.financials_search(soup, "EPS (Basic)")
     sales_dict = MWScraper.financials_search(soup, "Sales/Revenue")
     diluted_shares = MWScraper.financials_search(soup, "Diluted Shares Outstanding")
     return {
         "eps": eps_dict.get("item"),
         "eps_list": eps_dict["item_list"],
         "sales": sales_dict["item"],
         "sales_list": sales_dict["item_list"],
         "mw_data_range": eps_dict["year_list"],
         "diluted_shares": diluted_shares.get("item"),
     }
Exemplo n.º 7
0
    def scrape_cash_flow(self):
        soup = get_soup(f"{self.base_url}/{self.url_symbol}/financials/cash-flow")
        dividend_dict = MWScraper.financials_search(soup, "Cash Dividends Paid - Total")

        # Marketwatch seems to list all dividends as negative, so adjust values
        dividend = None
        if dividend_dict["item"] is not None:
            dividend = abs(dividend_dict["item"])

        dividend_list = None
        if dividend_dict["item_list"] is not None:
            dividend_list = [
                abs(i) if i is not None else i for i in dividend_dict["item_list"]
            ]

        return {"dividend": dividend, "dividend_list": dividend_list}
Exemplo n.º 8
0
    def scrape_balance_sheet(self):
        soup = get_soup(f"{self.base_url}/{self.url_symbol}/financials/balance-sheet")
        # Fetch the price from the top of the page
        price = None
        intraday_price = soup.find("h3", {"class": "intraday__price"})
        if intraday_price:
            price = (
                intraday_price.get_text(strip=True).replace("$", "").replace("€", "")
            )
            if price is not None and price != "":
                price = float(locale.atof(price))

        total_assets_dict = MWScraper.financials_search(soup, "Total Assets")
        total_liabilities_dict = MWScraper.financials_search(soup, "Total Liabilities")
        return {
            "price": price,
            "assets": total_assets_dict["item"],
            "liabilities": total_liabilities_dict["item"],
        }