diff --git a/gamestonk_terminal/README.md b/gamestonk_terminal/README.md index 1d5366352f5..c8400316050 100644 --- a/gamestonk_terminal/README.md +++ b/gamestonk_terminal/README.md @@ -247,6 +247,8 @@ Command|Description|Source `ftd` |display fails-to-deliver data [SEC](https://www.sec.gov) `shortview` |shows price vs short interest volume [Stockgrid](https://stockgrid.io) `darkpos` |net short vs position [Stockgrid](https://stockgrid.io) +`supplier` |list of suppliers [csimarket](https://csimarket.com) +`customer` |list of customers [csimarket](https://csimarket.com)   diff --git a/gamestonk_terminal/due_diligence/README.md b/gamestonk_terminal/due_diligence/README.md index 6c572fed877..c3db5073bac 100644 --- a/gamestonk_terminal/due_diligence/README.md +++ b/gamestonk_terminal/due_diligence/README.md @@ -34,7 +34,10 @@ This menu aims to help in due-diligence of a pre-loaded stock, and the usage of * shows price vs short interest volume [Stockgrid] * [darkpos](#darkpos) * net short vs position [Stockgrid] - +* [supplier](#supplier) + * list of suppliers [csimarket] +* [customer](#customer) + * list of customers [csimarket] ## news @@ -235,3 +238,23 @@ Shows Net Short Vol. vs Position. [Source: Stockgrid] darkpos_raw +## supplier + +```text +usage: supplier +``` + +List of suppliers from ticker provided. [Source: CSIMarket] + +supplier + + +## customer + +```text +usage: customer +``` + +List of customer from ticker provided. [Source: CSIMarket] + +customer diff --git a/gamestonk_terminal/due_diligence/csimarket_view.py b/gamestonk_terminal/due_diligence/csimarket_view.py new file mode 100644 index 00000000000..6dc74c9e278 --- /dev/null +++ b/gamestonk_terminal/due_diligence/csimarket_view.py @@ -0,0 +1,92 @@ +"""Stockgrid DD View""" +__docformat__ = "numpy" + +import argparse +from typing import List +from bs4 import BeautifulSoup +import requests +from gamestonk_terminal.helper_funcs import ( + parse_known_args_and_warn, +) + + +def suppliers(ticker: str, other_args: List[str]): + """Print suppliers from ticker provided + + Parameters + ---------- + ticker: str + Ticker to select suppliers from + other_args : List[str] + Argparse arguments + + """ + parser = argparse.ArgumentParser( + prog="supplier", + add_help=False, + description="List of suppliers from ticker provided. [Source: CSIMarket]", + ) + try: + ns_parser = parse_known_args_and_warn(parser, other_args) + if not ns_parser: + return + + url_supply_chain = f"https://csimarket.com/stocks/competitionNO3.php?supply&code={ticker.upper()}" + text_supplier_chain = BeautifulSoup(requests.get(url_supply_chain).text, "lxml") + + l_supplier = list() + for supplier in text_supplier_chain.findAll( + "td", {"class": "plavat svjetlirub dae al"} + ): + l_supplier.append(supplier.text) + + if l_supplier: + print("List of Suppliers: " + ", ".join(l_supplier) + "\n") + else: + print("No suppliers found.\n") + + except Exception as e: + print(e, "\n") + + +def customers(ticker: str, other_args: List[str]): + """Print customers from ticker provided + + Parameters + ---------- + ticker: str + Ticker to select customers from + other_args : List[str] + Argparse arguments + + """ + parser = argparse.ArgumentParser( + prog="customer", + add_help=False, + description="List of customers from ticker provided. [Source: CSIMarket]", + ) + try: + ns_parser = parse_known_args_and_warn(parser, other_args) + if not ns_parser: + return + + url_customer_chain = ( + f"https://csimarket.com/stocks/custexNO.php?markets&code={ticker.upper()}" + ) + text_customer_chain = BeautifulSoup( + requests.get(url_customer_chain).text, "lxml" + ) + + l_customer = list() + for customer in text_customer_chain.findAll( + "td", {"class": "plava svjetlirub"} + ): + l_customer.append(customer.text) + + if l_customer: + print("List of Customers: " + ", ".join(l_customer) + "\n") + else: + print("No customers found.\n") + + except Exception as e: + print(e, "\n") diff --git a/gamestonk_terminal/due_diligence/dd_controller.py b/gamestonk_terminal/due_diligence/dd_controller.py index 3c01943fd35..d0cc6e7f28f 100644 --- a/gamestonk_terminal/due_diligence/dd_controller.py +++ b/gamestonk_terminal/due_diligence/dd_controller.py @@ -18,6 +18,7 @@ from gamestonk_terminal.due_diligence import finra_view from gamestonk_terminal.due_diligence import sec_view from gamestonk_terminal.due_diligence import stockgrid_dd_view as sg_view from gamestonk_terminal.due_diligence import finnhub_view +from gamestonk_terminal.due_diligence import csimarket_view from gamestonk_terminal import feature_flags as gtff from gamestonk_terminal.helper_funcs import get_flair from gamestonk_terminal.menu import session @@ -49,6 +50,8 @@ class DueDiligenceController: "ftd", "shortview", "darkpos", + "supplier", + "customer", ] def __init__(self, ticker: str, start: str, interval: str, stock: DataFrame): @@ -120,6 +123,8 @@ class DueDiligenceController: print(" ftd fails-to-deliver data [SEC]") print(" shortview price vs short interest volume [Stockgrid.io]") print(" darkpos net short vs position [Stockgrid.io]") + print(" supplier list of suppliers [csimarket]") + print(" customer list of customers [csimarket]") print("") def switch(self, an_input: str): @@ -234,6 +239,14 @@ class DueDiligenceController: """Process darkpos command""" sg_view.darkpos(self.ticker, other_args) + def call_supplier(self, other_args: List[str]): + """Process supplier command""" + csimarket_view.suppliers(self.ticker, other_args) + + def call_customer(self, other_args: List[str]): + """Process customer command""" + csimarket_view.customers(self.ticker, other_args) + def menu(ticker: str, start: str, interval: str, stock: DataFrame): """Due Diligence Menu