Exemplo n.º 1
0
def lookup(stock):
    stock_data.append(finviz.get_stock(stock))

    analyst_raw = {}
    analyst_raw['symbol'] = stock
    analyst_raw['info'] = finviz.get_analyst_price_targets(stock)
    analyst_data.append(analyst_raw)
Exemplo n.º 2
0
def database_function(UI, symbol):

    analyst_ratings = finviz.get_analyst_price_targets(symbol)
    infos = finviz.get_stock(symbol)

    wv, mv = infos['Volatility'].split(" ")[0], infos['Volatility'].split(
        " ")[1]
    dic = [
        symbol, infos['Price'], infos['Target Price'], infos['P/E'],
        infos['Change'], infos['Perf Week'], infos['Perf Month'],
        infos['Perf Quarter'], infos['Perf Half Y'], infos['Perf Year'], wv, mv
    ]

    for i in range(len(UI.info)):
        UI.info[i]["text"] = dic[i]

    vol = float(mv.strip("%")) * 0.158745

    price = float(infos['Price'])
    price_1, price_2 = database(symbol, 900, price, vol)

    for j in range(max(len(analyst_ratings), 5)):
        a = analyst_ratings[j]
        te = "Date: {}  Analyst: {}   Rating: {}  Price from: {} to {}".format(
            a["date"], a["analyst"], a["rating"], a["price_from"],
            a["price_to"])
        UI.ratings[j]["text"] = te

    # UI.Labels["text"] = " Symbol: {}    Last Price: {}    Weekly Volitality: {}%  Monthly Volitality: {}%".format(symbol, cur_price,vol,day_vol)

    #UI.status['text'] ="Downloading options data"

    UI.loadoptions(symbol, price_1, price_2, price)

    UI.Data["state"] = "normal"
Exemplo n.º 3
0
def analyst_df(ticker: str) -> DataFrame:
    """[summary]

    Parameters
    ----------
    ticker : str
        Stock ticker

    Returns
    -------
    DataFrame
        [description]
    """

    try:
        d_finviz_analyst_price = finviz.get_analyst_price_targets(ticker)
        df_fa = pd.DataFrame.from_dict(d_finviz_analyst_price)
        df_fa.set_index("date", inplace=True)
    except Exception as e:
        print(e)
        print(
            "Encountered a potential connectivity issue trying to access Finviz."
        )

    return df_fa
Exemplo n.º 4
0
def get_price_targets(ticker):
    try:
        targets = finviz.get_analyst_price_targets(ticker)
        targets = pd.DataFrame(targets)
        targets.columns = [
            'Date', 'Category', 'Analyst', 'Rating', 'Price From', 'Price To'
        ]
        targets = targets.set_index('Date')
        return targets
    except Exception as e:
        return e
Exemplo n.º 5
0
def analyst_df(s_ticker: str) -> DataFrame:
    try:
        d_finviz_analyst_price = finviz.get_analyst_price_targets(s_ticker)
        df_fa = pd.DataFrame.from_dict(d_finviz_analyst_price)
        df_fa.set_index("date", inplace=True)
    except Exception as e:
        print(e)
        print(
            "Encountered a potential connectivity issue trying to access Finviz."
        )

    return df_fa
Exemplo n.º 6
0
def get_analyst_data(ticker: str) -> DataFrame:
    """Get analyst data. [Source: Finviz]

    Parameters
    ----------
    ticker : str
        Stock ticker

    Returns
    -------
    df_fa: DataFrame
        Analyst price targets
    """
    d_finviz_analyst_price = finviz.get_analyst_price_targets(ticker)
    df_fa = pd.DataFrame.from_dict(d_finviz_analyst_price)
    df_fa.set_index("date", inplace=True)

    return df_fa
Exemplo n.º 7
0
def analyst(l_args, s_ticker):
    parser = argparse.ArgumentParser(
        prog='analyst',
        description=
        """Print analyst prices and ratings of the company. The following fields
                                     are expected: date, analyst, category, price from, price to, and rating.
                                     [Source: Finviz]""")

    (ns_parser, l_unknown_args) = parser.parse_known_args(l_args)

    if l_unknown_args:
        print(
            f"The following args couldn't be interpreted: {l_unknown_args}\n")
        return

    d_finviz_analyst_price = finviz.get_analyst_price_targets(s_ticker)
    df_fa = pd.DataFrame.from_dict(d_finviz_analyst_price)
    df_fa.set_index("date", inplace=True)
    print(df_fa)
    print("")
Exemplo n.º 8
0
          'openInterest', 'percentChange', 'ask', 'bid','volume', 'lastTradeDate', ]

    res, dates = get_first_option(symbol)

    ls = []
    print("Processing date:",
          "{: %Y-%m-%d}".format(datetime.fromtimestamp(dates[0] + 1)))
    add_options_to_list(res, ls)

    #now add the remaining ones.
    for i in range(1, len(dates)):
        print("Processing date:",
              "{: %Y-%m-%d}".format(datetime.fromtimestamp(dates[i] + 1)))
        res = get_option(symbol, dates[i])
        add_options_to_list(res, ls)

    df = pd.DataFrame(ls, columns=cols)
    df.to_csv(symbol + "_options.csv", index=False)


# symbol = sys.argv[1]

# get_all_options(symbol)

import finviz

print(finviz.get_analyst_price_targets('AAPL'))

# print(finviz.get_stock('AMD'))

# print(finviz.get_news('AAPL')[-5:])
Exemplo n.º 9
0
from main import Portfolio
import finviz
import json

portfolio1 = Portfolio("StockFund")
portfolio1.addStocks('TSLA', 4)
portfolio1.addStocks('CAT', 1)
print(str(portfolio1.name))
portfolio1.calculateEarnings(portfolio1.stocks)

finvizResults = str(
    finviz.get_analyst_price_targets('CAT')[0]['date']) + ", Firm: " + str(
        finviz.get_analyst_price_targets('CAT')[0]
        ['analyst']) + ", Rating: " + str(
            finviz.get_analyst_price_targets('CAT')[0]['rating'])

print(finvizResults)
#print(finvizResults['Price'])
Exemplo n.º 10
0
import sys

sys.path.insert(0, 'finviz')
import finviz

result = finviz.get_analyst_price_targets(sys.argv[1])
for x in range(len(result)):
    print(result[x])
Exemplo n.º 11
0
def analyst_df(s_ticker: str) -> DataFrame:
    d_finviz_analyst_price = finviz.get_analyst_price_targets(s_ticker)
    df_fa = pd.DataFrame.from_dict(d_finviz_analyst_price)
    df_fa.set_index("date", inplace=True)

    return df_fa
Exemplo n.º 12
0
 def response():
     return finviz.get_analyst_price_targets(ticker)