Ejemplo n.º 1
0
def get_stock_data(
        tickers=get_sp500_tickers(), path='pinance_data/{}.pickle',
        update=False):
    for symbol in tickers:
        if update:
            print("Reading data for ticker " + symbol['ticker'])
            stock = Pinance(symbol['ticker'])
            stock.get_quotes()
            stock.get_news()

            stock_data = stock.quotes_data
            stock_news = stock.news_data

            data = {
                'ticker': symbol['ticker'],
                'data': stock_data,
                'news': stock_news
            }

            write_to_pickle(data, path.format(symbol['ticker']))

        else:
            with open(path.format(symbol['ticker']), 'rb') as handle:
                data = pickle.load(handle)

        yield data
Ejemplo n.º 2
0
from pinance import Pinance
import pandas as pd

stock1 = 'HDFC'
stock2 = 'HDFC.NS'

first = Pinance(stock1)
second = Pinance(stock2)

first.get_quotes()
second.get_quotes()

second.get_news()

df1 = pd.DataFrame(data=first.quotes_data, index=[0])
df2 = pd.DataFrame(data=second.quotes_data, index=[0])
df1 = (df1.T)
df2 = (df2.T)
df1.to_excel("DataQuality\hdfc.xls")
df2.to_excel("DataQuality\hdfcNS.xls")

df3 = pd.DataFrame(data=second.news_data, index=[0])
df3 = (df3.T)

df3.to_excel(r"DataQuality\news.xls")