예제 #1
0
def calculate():
    url = 'http://www.google.com/'
    timeout = 2
    try:
        _ = requests.get(url, timeout=timeout)
        symbol = (request.form['ticketSymbol'])
        try:
            data = YahooFinancials(symbol)
            date = datetime.datetime.now(tzlocal())
            timezone = str(time.asctime(time.localtime(time.time())))
            strftime = date.strftime("%Z")
            financials = data.get_stock_quote_type_data()
            name = str(financials.get(symbol).get('longName'))
            sym = financials.get(symbol).get('symbol')
            current = str(data.get_current_price())
            currentchange = str(round(data.get_current_change(), 2))
            percentchange = str(
                round(data.get_current_percent_change() * 100, 2)) + '%'
            return render_template('output.html',
                                   symbol=symbol,
                                   data=data,
                                   timezone=timezone,
                                   strftime=strftime,
                                   financials=financials,
                                   name=name,
                                   sym=sym,
                                   current=current,
                                   currentchange=currentchange,
                                   percentchange=percentchange)
        except:
            return 'INVALID SYMBOL'
    except:
        return 'NO INTERNET CONNECTION'
def update_volume_watchlist_stock_dict(stock):
    global stocks_dict
    #global temp
    global daily_avg_change

    stock_yahoo_obj = YahooFinancials(stock.symbol)
    stock_volume_increase_ratio = compare_stock_relative_volume_to_avg(stock_yahoo_obj)
    stock_price_change = stock_yahoo_obj.get_current_percent_change()
    stock_price_change = str(round((stock_price_change * 100 ),2))+'%'
    current_stock_price = round(stock_yahoo_obj.get_current_price(),2)
    stocks_dict[stock.symbol] = [stock.eps_growth,stock.net_income_growth,stock.sales_growth,stock_volume_increase_ratio,stock_price_change,current_stock_price]
예제 #3
0
def run_yahoo_stocks(stock_symbol):
    global technically_valid_stocks_heap
    global breakout_stocks_heap
    print(stock_symbol)
    yahoo_stock = YahooFinancials(stock_symbol)
    candidate_stock = CandidateStock(
        stock_symbol, round(yahoo_stock.get_current_percent_change() * 100, 2))

    if validate_stock_technically(yahoo_stock):
        heappush(technically_valid_stocks_heap, candidate_stock)
        if detect_breakout(yahoo_stock, 1.2, 0.02):
            heappush(breakout_stocks_heap, candidate_stock)
예제 #4
0
def details(request, slug):
    stocks = Stock.objects.filter(slug=slug).first()
    name = stocks.stock_name
    date = stocks.stock_date
    quant = stocks.stock_quant
    p_price = stocks.stock_cb
    slug = slug
    yahoo_financials = YahooFinancials(name)
    gain_loss = round(yahoo_financials.get_current_percent_change() * 100, 3)
    return render(
        request, 'details.html', {
            'slug': slug,
            'name': name,
            'date': date,
            'quant': quant,
            'p_price': p_price,
            'gain_loss': gain_loss
        })
예제 #5
0
from yahoofinancials import YahooFinancials
from servertools import SlackComm

stonk = '6098.T'

yf = YahooFinancials(stonk)

price = yf.get_current_price()
change = yf.get_current_change()
pct_change = yf.get_current_percent_change()

scom = SlackComm('viktor')

jpyusd = 1 / 104.48
units = 100
strike_price = 4542
msg = f'{units:,.0f} shares of `{stonk}` are now worth *`{(price - strike_price) * jpyusd * units:+,.2f}`* USD' \
      f' more than when you got it'

blocks = [
    scom.bkb.make_context_section(
        f':trending_up_and_down: time for stonk updates !'),
    scom.bkb.make_block_section(msg),
    scom.bkb.make_context_section([
        f'JPY/USD: {jpyusd:.4f}, strike price: {strike_price}, current price: {price}'
    ])
]

scom.st.send_message('C01M49M5EEM', message='stonk update', blocks=blocks)