Ejemplo n.º 1
0
def getMarketData():
    tickers = 'AAPL'
    financials = YahooFinancials(tickers)

    #	company_stock_price = financials.get_stock_price_data() #gets stock price information

    historical_stock_prices_data = financials.get_historical_price_data(
        '2015-11-21', '2020-11-21',
        'daily')  #gets historical daily stock price of company
    #	get_Div_data(historical_stock_prices_data[tickers])
    get_stock_price_data(historical_stock_prices_data[tickers])

    #	company_balance_sheet_data_qt = financials.get_financial_stmts('quarterly', 'balance') #get balance sheet
    #	company_income_statement_data_qt = financials.get_financial_stmts('quarterly', 'income') #get income statement

    company_key_statistics_data = financials.get_key_statistics_data(
    )  #includes profit margins, forward eps, yearly change etc.
    #	get_forward_pe(company_key_statistics_data[tickers])
    #	get_trailing_eps(company_key_statistics_data[tickers])
    #	get_foward_eps(company_key_statistics_data[tickers])
    #	get_ytdReturn(company_key_statistics_data[tickers])

    company_earnings_data = financials.get_stock_earnings_data(
    )  #historical eps only for 1 year span
    #	get_earnings_data(company_earnings_data[tickers])

    company_dividend_yield = financials.get_dividend_yield(
    )  #current dividends yield
    company_dividend = financials.get_dividend_rate()  #current dividends rate
    company_avg_div_yield_1year = financials.get_annual_avg_div_yield(
    )  #average 1 year div yield
    company_avg_div_yield_5year = financials.get_five_yr_avg_div_yield(
    )  #average 5 year div yield
    company_eps = financials.get_earnings_per_share()  #current eps
    company_pe = financials.get_pe_ratio()  #current pe ratio
    company_beta = financials.get_beta()  #current beta
    company_current_stock_price = financials.get_current_price(
    )  #current stock price

    company_revenue = financials.get_total_revenue()  #current company revenue
    company_operating_income = financials.get_operating_income(
    )  #current company operating income
    company_net_income = financials.get_net_income()  #current net income

    company_yearly_high = financials.get_yearly_high()  #get yearly high
    company_yearly_low = financials.get_yearly_low()  #get yearly low
    company_moving_50 = financials.get_50day_moving_avg(
    )  #50 day moving average of stock
    company_moving_200 = financials.get_200day_moving_avg(
    )  #200 day moving average of stock
Ejemplo n.º 2
0
async def stock(ctx, ticker, info):
    yahoo_financials = YahooFinancials(ticker)
    if (info == "current"):
        await ctx.send(ticker.upper() + " current share price: $" +
                       str(yahoo_financials.get_current_price()))
    if (info == "open"):
        await ctx.send(ticker.upper() + " share price at opening: $" +
                       str(yahoo_financials.get_open_price()))
    if (info == "prevclose"):
        await ctx.send(ticker.upper() + " share priced at previous close: $" +
                       str(yahoo_financials.get_prev_close_price()))
    if (info == "cap"):
        await ctx.send(ticker.upper() + " market cap: $" +
                       str("{:,}".format(yahoo_financials.get_market_cap())))
    if (info == "dailylow"):
        await ctx.send(ticker.upper() + " daily low: $" +
                       str(yahoo_financials.get_daily_low()))
    if (info == "dailyhigh"):
        await ctx.send(ticker.upper() + " daily high: $" +
                       str(yahoo_financials.get_daily_high()))
    if (info == "yearlow"):
        await ctx.send(ticker.upper() + " yearly low: $" +
                       str(yahoo_financials.get_yearly_low()))
    if (info == "yearhigh"):
        await ctx.send(ticker.upper() + " yearly high: $" +
                       str(yahoo_financials.get_yearly_high()))
    if (info == "rev"):
        await ctx.send(ticker.upper() + " total revenue: $" +
                       str("{:,}".format(yahoo_financials.get_total_revenue()))
                       )
    if (info == "net"):
        await ctx.send(ticker.upper() + " net income: $" +
                       str("{:,}".format(yahoo_financials.get_net_income())))
    if (info == "op"):
        await ctx.send(
            ticker.upper() + " operating income: $" +
            str("{:,}".format(yahoo_financials.get_operating_income())))
    if (info == "profit"):
        await ctx.send(ticker.upper() + " gross profit: $" +
                       str("{:,}".format(yahoo_financials.get_gross_profit())))
)  # creating list with names of S&P 500 companies corresponding industries

# data.Sector.value_counts() # counts number of unique industries

data.drop(
    ['Name'], axis=1,
    inplace=True)  # drop extra column with full name of S&P 500 companies
data = data.set_index('Symbol')  # set ticker column as index

# importing income statement data for S&P 500 companies
from yahoofinancials import YahooFinancials

yahoo_financials = YahooFinancials(list_names)

# pullling operating income data for most recent year reported
minilist_opinc = yahoo_financials.get_operating_income()
minilist_opinc_df = pd.Series(minilist_opinc).to_frame('op_inc')
print(minilist_opinc_df)

# pulling operating expense data for most recent year reported
minilist_opex = yahoo_financials.get_total_operating_expense()
minilist_opex_df = pd.Series(minilist_opex).to_frame('op_ex')
print(minilist_opex_df)

# pulling total revenue data for most recent year reported
minilist_rev = yahoo_financials.get_total_revenue()
minilist_rev_df = pd.Series(minilist_rev).to_frame('rev')
print(minilist_rev_df)

mergeddf = minilist_opinc_df.join(
    minilist_opex_df