示例#1
0
def ticker_object(pytestconfig):
    global ticker_symbol

    ticker_symbol = pytestconfig.getoption("--ticker").upper()
    ticker_symbol_object = ticker.get_ticker(ticker_symbol)
    assert ticker_symbol_object is not None
    return ticker_symbol_object
示例#2
0
def get_cash_burn_number(ticker_symbol):
    global most_recent_cash_flow
    ticker_symbol_object = ticker.get_ticker(
        ticker_symbol)  # Gets the ticker_symbol object so you can access the various objects
    balance_sheet_data_frame = balance_sheet.get_balance_sheet_data(ticker_symbol_object, 'a')
    cash_flow_data_frame = cash_flow_page.get_cash_flow_data(ticker_symbol_object, 'a')

    cash_and_cash_equivalents = balance_sheet.get_cash_and_expenses(balance_sheet_data_frame,ticker_symbol)

    """
    because balance sheet does not have a TTM.## if the size of the cash flow data frame > balance sheet select
    the most recent year(not TTM)
    """
    try:
        if cash_flow_data_frame.shape[0] > balance_sheet_data_frame.shape[0]:
            most_recent_cash_flow = cash_flow_page.get_most_recent_cash_flow_total(cash_flow_data_frame, -2)

        cash_burn = cash_flow_page.calculate_cash_burn(cash_and_cash_equivalents, most_recent_cash_flow)

        ticker_symbol_name = get_stock_name(ticker_symbol)
        if cash_burn < 0:
            print(f'{ticker_symbol_name} is already running out of money. Their cash burn is:{cash_burn:,.1f} months')
        else:
          print(f'It will take {cash_burn:,.1f} months before {ticker_symbol_name} runs out of money')
    except Exception as e:
        print(f'yikes, seems like I cannot get the cash burn for {ticker_symbol} because "{e}"')
示例#3
0
def get_company_sector(ticker_symbol):
    try:
        ticker_symbol_object = ticker.get_ticker(
            ticker_symbol)  # Gets the ticker_symbol object so you can access the various objects
        company_sector = company_profile.get_company_sector(ticker_symbol_object, ticker_symbol)
        return company_sector
    except TypeError:
        return error_message
示例#4
0
def get_stock_name(ticker_symbol_symbol):
    try:
        ticker_symbol_object = ticker.get_ticker(
            ticker_symbol_symbol)  # Gets the ticker_symbol object so you can access the various objects
        stock_name = price_data.get_company_name(ticker_symbol_object, ticker_symbol_symbol)
        return stock_name
    except TypeError:
        return error_message
示例#5
0
    def plot_revenue(self, container, ticker_symbol, frequency):
        ticker_object = ticker.get_ticker(
            ticker_symbol
        )  # Gets the ticker object so you can access the various objects
        earnings_data = earning.get_earnings_data(ticker_object)
        company_name = price_data.get_company_name(ticker_object,
                                                   ticker_symbol)

        data = self.get_freqency(earnings_data, ticker_symbol, frequency)
        earnings_data_frame = pd.DataFrame(data)
        dates = earnings_data_frame['date'].astype(str)
        revenue = earnings_data_frame['revenue']
        revenue = revenue / 100  # This scales the earnings value to Millions or Billions depends on how you want to read the chart

        ax = self.fig.add_subplot(111)
        yLabelText = "Amount in $"
        graph_title = company_name + " " + 'Revenue'
        ax.set_title(graph_title)
        ax.set_xlabel('Period')
        ax.set_ylabel(yLabelText)

        ax.get_yaxis().set_major_formatter(
            matplotlib.ticker.FuncFormatter(lambda x, p: format(int(x), ',')))

        ax.bar(dates, revenue,
               color=['r' if v < 0 else 'g'
                      for v in revenue])  ## adding color to bar graphs
        for i, v in enumerate(revenue):
            ax.text(i,
                    v * 0.75,
                    f'${v:,.0f}',
                    fontweight='bold',
                    va='center',
                    ha='center')  ## printing values into the bar graphs

        legend_handles = [
            Line2D([0], [0],
                   linewidth=0,
                   marker='o',
                   markerfacecolor=color,
                   markersize=12,
                   markeredgecolor='none') for color in ['g', 'r']
        ]
        ax.legend(legend_handles, ['positive revenue', 'negative revenue'])

        # ax.legend()

        if not self.canvas:
            self.canvas = FigureCanvasTkAgg(self.fig, container)
            self.canvas.get_tk_widget().pack(side="top",
                                             fill="both",
                                             expand=True)
        self.canvas.draw_idle()
示例#6
0
    def plot_net_income(self, container, ticker_symbol, Frequency):
        ticker_object = ticker.get_ticker(
            ticker_symbol
        )  ## Gets the ticker object so you can access the various objects
        income_statements_data_drame = income.get_income_statement(
            ticker_object, Frequency)
        income_statement = income.get_net_income(income_statements_data_drame)
        company_name = priceData.get_company_name(ticker_object, ticker_symbol)
        dates = date.get_dates(income_statements_data_drame)
        income_statement_title = 'Net income'

        ax = self.fig.add_subplot(111)

        yLabelText = "Net Income in $"
        graph_title = company_name + " " + income_statement_title
        ax.set_title(graph_title)
        ax.set_xlabel('Period')
        ax.set_ylabel(yLabelText)

        ax.get_yaxis().set_major_formatter(
            matplotlib.ticker.FuncFormatter(lambda x, p: format(int(x), ',')))

        ax.bar(dates,
               income_statement,
               color=['r' if v < 0 else 'g' for v in income_statement])
        for i, v in enumerate(income_statement):
            ax.text(i,
                    v * 0.75,
                    f'${v:,.0f}',
                    fontweight='bold',
                    va='center',
                    ha='center',
                    color='#0A0A0A')

        legend_handles = [
            Line2D([0], [0],
                   linewidth=0,
                   marker='o',
                   markerfacecolor=color,
                   markersize=12,
                   markeredgecolor='none') for color in ['g', 'r']
        ]
        ax.legend(legend_handles,
                  ['positive net income', 'negative net income'])

        if not self.canvas:
            self.canvas = FigureCanvasTkAgg(self.fig, container)
            self.canvas.get_tk_widget().pack(side="top",
                                             fill="both",
                                             expand=True)
        self.canvas.draw_idle()
示例#7
0
    def plotCashGraph(self, container, ticker_symbol, frequency):
        ticker_object = ticker.get_ticker(
            ticker_symbol
        )  ## Gets the ticker object so you can access the various objects
        cash_flow_data_frame = cash_flow_page.get_cash_flow_data(
            ticker_object, frequency)
        free_cash_flow = cash_flow_page.get_free_cash_flow(
            cash_flow_data_frame)
        company_name = price_data.get_company_name(ticker_object,
                                                   ticker_symbol)
        dates = date.get_dates(cash_flow_data_frame)
        cash_flow_graph_title = 'Free Cash Flow'

        ax = self.fig.add_subplot(111)

        yLabelText = "Free Cash Flow in $"
        graphTitle = company_name + " " + cash_flow_graph_title
        ax.set_title(graphTitle)
        ax.set_xlabel('Period')
        ax.set_ylabel(yLabelText)

        ax.get_yaxis().set_major_formatter(
            matplotlib.ticker.FuncFormatter(lambda x, p: format(int(x), ',')))

        ax.bar(dates,
               free_cash_flow,
               color=['r' if v < 0 else 'g' for v in free_cash_flow])
        for i, v in enumerate(free_cash_flow):
            ax.text(i,
                    v * 0.75,
                    f'${v:,.0f}',
                    fontweight='bold',
                    va='center',
                    ha='center')

        legend_handles = [
            Line2D([0], [0],
                   linewidth=0,
                   marker='o',
                   markerfacecolor=color,
                   markersize=12,
                   markeredgecolor='none') for color in ['g', 'r']
        ]
        ax.legend(legend_handles, ['positive cash flow', 'negative cash flow'])

        if not self.canvas:
            self.canvas = FigureCanvasTkAgg(self.fig, container)
            self.canvas.get_tk_widget().pack(side="top",
                                             fill="both",
                                             expand=True)
        self.canvas.draw_idle()
示例#8
0
    def plotCashToEarnings(self, container, ticker_symbol, frequency):
        ticker_object = ticker.get_ticker(
            ticker_symbol
        )  # Gets the ticker object so you can access the various objects
        income_statements_data_frame = income.get_income_statement(
            ticker_object, frequency)
        net_income = income.get_net_income(income_statements_data_frame)
        cash_flow_data_frame = cash_flow_page.get_cash_flow_data(
            ticker_object, frequency)
        operating_cash_flow = cash_flow_page.get_operating_cash_flow(
            cash_flow_data_frame)

        company_name = price_data.get_company_name(ticker_object,
                                                   ticker_symbol)
        all_dates = dates.get_dates(cash_flow_data_frame)

        if operating_cash_flow.iloc[-1] > net_income.iloc[-1]:
            print(f'{company_name} has high quality earnings')
        else:
            print(f'{company_name} has low quality earnings')

        title = 'Cash Based Earnings'

        ax = self.fig.add_subplot(111)
        yLabelText = "Amount in $"
        graph_title = company_name + " " + title
        ax.set_title(graph_title)
        ax.set_xlabel('Period')
        ax.set_ylabel(yLabelText)

        ax.get_yaxis().set_major_formatter(
            matplotlib.ticker.FuncFormatter(lambda x, p: format(int(x), ',')))

        ax.plot(all_dates,
                operating_cash_flow,
                '-o',
                label='Cash From Operations')
        ax.plot(all_dates, net_income, '-o', label='Net Income')

        ax.legend()

        if not self.canvas:
            self.canvas = FigureCanvasTkAgg(self.fig, container)
            self.canvas.get_tk_widget().pack(side="top",
                                             fill="both",
                                             expand=True)
        self.canvas.draw_idle()
示例#9
0
    def plot_debt_graph(self, container, ticker_symbol, frequency):
        ticker_object = ticker.get_ticker(
            ticker_symbol
        )  ## Gets the ticker object so you can access the various objects
        balance_sheet_data_frame = balancesheet.get_balance_sheet_data(
            ticker_object, frequency)
        long_term_debt = balancesheet.get_long_term_debt(
            balance_sheet_data_frame)
        company_name = price_data.get_company_name(ticker_object,
                                                   ticker_symbol)
        dates = date.get_dates(balance_sheet_data_frame)
        graph_title = 'Long Term Debt'

        ax = self.fig.add_subplot(111)

        yLabelText = "Long term Debt $"
        graph_title = company_name + " " + graph_title
        ax.set_title(graph_title)
        ax.set_xlabel('Period')
        ax.set_ylabel(yLabelText)

        ax.get_yaxis().set_major_formatter(
            matplotlib.ticker.FuncFormatter(lambda x, p: format(int(x), ',')))

        ax.bar(dates, long_term_debt, color='r')
        for i, v in enumerate(long_term_debt):
            ax.text(i,
                    v * 0.75,
                    f'${v:,.0f}',
                    fontweight='bold',
                    va='center',
                    ha='center')

        if not self.canvas:
            self.canvas = FigureCanvasTkAgg(self.fig, container)
            self.canvas.get_tk_widget().pack(side="top",
                                             fill="both",
                                             expand=True)
        self.canvas.draw_idle()
示例#10
0
def get_profit_margin(ticker_symbol):
    ticker_symbol_object = ticker.get_ticker(
        ticker_symbol)  # Gets the ticker_symbol object so you can access the various objects
    profit_margin = statistics_tab.get_profit_margins(ticker_symbol_object, ticker_symbol)

    return profit_margin
示例#11
0
def get_return_on_equity(ticker_symbol):
    ticker_symbol_object = ticker.get_ticker(
        ticker_symbol)  # Gets the ticker_symbol object so you can access the various objects
    return_on_equity = statistics_tab.get_return_on_equity(ticker_symbol_object, ticker_symbol)

    return return_on_equity
示例#12
0
def get_debt_to_equity(ticker_symbol):
    ticker_symbol_object = ticker.get_ticker(
        ticker_symbol)  # Gets the ticker_symbol object so you can access the various objects
    debt_to_equity_ratio = statistics_tab.get_debt_to_equity(ticker_symbol_object, ticker_symbol)

    return debt_to_equity_ratio
示例#13
0
def get_pe_ratio(ticker_symbol_symbol):
    ticker_symbol_object = ticker.get_ticker(
        ticker_symbol_symbol)  # Gets the ticker_symbol object so you can access the various objects
    pe_ratio = summary_page.get_pe_ratio(ticker_symbol_object, ticker_symbol_symbol)

    return pe_ratio
示例#14
0
def get_eps(ticker_symbol_symbol):
    ticker_symbol_object = ticker.get_ticker(
        ticker_symbol_symbol)  # Gets the ticker_symbol object so you can access the various objects
    eps = summary_page.earnings_per_share(ticker_symbol_object, ticker_symbol_symbol)
    return eps
示例#15
0
def get_current_stock_price(ticker_symbol_symbol):
    ticker_symbol_object = ticker.get_ticker(
        ticker_symbol_symbol)  # Gets the ticker_symbol object so you can access the various objects
    current_stock_price = price_data.get_current_stock_price(ticker_symbol_object, ticker_symbol_symbol)

    return current_stock_price