Ejemplo n.º 1
0
def getStockInfoList(ticker_symbol_list):
    stock = YahooFinancials(ticker_symbol_list)
    stock_info = stock.get_stock_price_data()
    return_info = dict()
    result = dict()

    weeks_ago = (datetime.datetime.today() -
                 datetime.timedelta(days=14)).strftime('%Y-%m-%d')
    tomorrow = (datetime.datetime.today() +
                datetime.timedelta(days=1)).strftime('%Y-%m-%d')
    stock_price = stock.get_historical_stock_data(weeks_ago, tomorrow, "daily")

    for i in range(len(ticker_symbol_list)):
        fullname = stock_info[ticker_symbol_list[i]]['longName']
        return_info['symbol'] = ticker_symbol_list[i]
        return_info['company'] = fullname
        return_info['quantity'] = 0
        for j in range(5):
            return_info.setdefault('dates', []).append(stock_price[
                ticker_symbol_list[i]]['prices'][j]['formatted_date'])
            return_info.setdefault('prices', []).append(
                stock_price[ticker_symbol_list[i]]['prices'][j]['close'])
        result.setdefault('stocks', []).append(return_info)
        return_info = {}

    return result
Ejemplo n.º 2
0
def get_stock_prices():
    global stock_dict
    global stream
    while True:
        print("#### UPDATING STOCK PRICES")
        current = YahooFinancials(stocks)
        stock_dict = current.get_stock_price_data()
        print("#### DONE UPDATING STOCK PRICES")
        time.sleep(600)
Ejemplo n.º 3
0
def defaultapi(ticker):
    tick = YF(ticker)
    print(tick.get_stock_summary_data())
    print(mark)
    print(tick.get_stock_quote_type_data())
    print(mark)
    print(tick.get_stock_price_data())
    print(mark)
    print(tick.get_current_price())
    print(mark)
    print(tick.get_dividend_rate())
    try:
        r = tick._cache.keys()
    except AttributeError:
        pass
    else:
        print(mark)
        print(r)
Ejemplo n.º 4
0
def extraction(output_data, WATCHLIST):

    # Run Yahoo API with 1 indexes at a time.
    # can run multiple as well
    n = 1

    for category in WATCHLIST:
        category_name = category.pop(0)
        output_data.append(category_name)

        while len(category) > 0:
            index_to_search = category[0:n]
            category = category[n:]

            process_from_yahoo = YahooFinancials(index_to_search)
            result_data = process_from_yahoo.get_stock_price_data()

            extract(output_data, result_data)

        # append an empty column to use that to add a row in excel
        output_data.append(" ")
Ejemplo n.º 5
0
print(t)
yesterday = today - datetime.timedelta(days=1)
y = str(yesterday.year) + '-' + str(yesterday.month) + '-' + str(yesterday.day)
print(y)
# open file a read contents to a list
f = open(str(path) + 'StockList.txt.txt')
try:
    tickers = list(f)
finally:
    f.close()
# iterate list of tickers
for ticker in tickers:
    ticker = ticker.rstrip("\n")
    print('Ticker: ' + ticker)

    #tsla_df.head()p

    ticker_path = (str(path) + str(ticker) + '.csv')
    if os.path.exists(ticker_path):
        print("File exist")
    else:
        print("File does not exist pulling all historical data")
        yahoo_financials = YahooFinancials(ticker)
        yahoo_financials.get_stock_price_data(reformat=True)
        data = yahoo_financials.get_historical_price_data(
            start_date='1900-01-01', end_date=t, time_interval='daily')
        tsla_df = pd.DataFrame(data[ticker]['prices'])
        tsla_df = tsla_df.drop('date', axis=1).set_index('formatted_date')
        tsla_df.to_csv(ticker_path, header=True)
        tsla_df['close'][135]
        len(tsla_df)
Ejemplo n.º 6
0
import yahoo-finance

from yahoo_finance import Share
yahoo = Share('YHOO')
yahoo.get_price()
>>> print yahoo.get_open()
yahoo_finance.Share("SBI.NSE")
symbol = yahoo_finance.Share("GOOG")
google_data = symbol.get_historical("2019-06-01", "2019-06-30")
google_df = pd.DataFrame(google_data)

# Output data into CSV
google_df.to_csv("/home/username/google_stock_data.csv")

#
pip install yahoofinancials
from yahoofinancials import YahooFinancials

tech_stocks = ['AAPL', 'MSFT', 'INTC']
bank_stocks = ['WFC', 'BAC', 'C']
yahoo_financials_tech = YahooFinancials(tech_stocks)
yahoo_financials_banks = YahooFinancials(bank_stocks)
yahoo_financials_tech
ech_cash_flow_data_an = yahoo_financials_tech.get_financial_stmts('annual', 'cash')
bank_cash_flow_data_an = yahoo_financials_banks.get_financial_stmts('annual', 'cash')
banks_net_ebit = yahoo_financials_banks.get_ebit()
tech_stock_price_data = yahoo_financials_tech.get_stock_price_data()
daily_bank_stock_prices = yahoo_financials_banks.get_historical_price_data('2008-09-15', '2018-09-15', 'daily')
daily_bank_stock_prices
#https://pypi.org/project/yahoofinancials/
Ejemplo n.º 7
0
def pull_yahoo_data(stock_tickers):
    yahoo_list = []
    for i in stock_tickers:
        yh = YahooFinancials(i)
        yahoo_list.append(yh.get_stock_price_data())
    return yahoo_list