def test_get_all_alignment_new(self):
     """ Compare bulk 'all_info' values to individual values.
     Currently broken due to misalignment from invalid CSV in
     fields: f6, k3, and maybe j2, a5, b6.
     """
     symbol = 'GOOG'
     all_info = quote_properties.get_all(symbol)
     self.assertIsInstance(all_info, dict)
     self.assertEquals(
         all_info['PreviousClose'],
         ystockquote.get_previous_close(symbol))
     self.assertEquals(
         all_info['Volume'],
         ystockquote.get_volume(symbol))
     self.assertEquals(
         all_info['BidRealtime'],
         ystockquote.get_bid_realtime(symbol))
     self.assertEquals(
         all_info['AskRealtime'],
         ystockquote.get_ask_realtime(symbol))
     self.assertEquals(
         all_info['LastTradePriceOnly'],
         ystockquote.get_last_trade_price(symbol))
     self.assertEquals(
         all_info['Open'],
         ystockquote.get_today_open(symbol))
     self.assertEquals(
         all_info['DaysHigh'],
         ystockquote.get_todays_high(symbol))
     self.assertEquals(
         all_info['LastTradeDate'],
         ystockquote.get_last_trade_date(symbol))
 def test_get_all_alignment(self):
     """ Compare bulk 'all_info' values to individual values.
     Currently broken due to misalignment from invalid CSV in
     fields: f6, k3, and maybe j2, a5, b6.
     """
     symbol = 'GOOG'
     all_info = ystockquote.get_all(symbol)
     self.assertIsInstance(all_info, dict)
     self.assertEquals(
         all_info['previous_close'],
         ystockquote.get_previous_close(symbol))
     self.assertEquals(
         all_info['volume'],
         ystockquote.get_volume(symbol))
     self.assertEquals(
         all_info['bid_realtime'],
         ystockquote.get_bid_realtime(symbol))
     self.assertEquals(
         all_info['ask_realtime'],
         ystockquote.get_ask_realtime(symbol))
     self.assertEquals(
         all_info['last_trade_price'],
         ystockquote.get_last_trade_price(symbol))
     self.assertEquals(
         all_info['today_open'],
         ystockquote.get_today_open(symbol))
     self.assertEquals(
         all_info['todays_high'],
         ystockquote.get_todays_high(symbol))
     self.assertEquals(
         all_info['last_trade_date'],
         ystockquote.get_last_trade_date(symbol))
Example #3
0
def stock_properties(stock):
    """ Retrieves properties for a given stock and returns a 
    dictionary containing it. """
    stock_dict = {}
    stock_dict["stock_name"] = stock.name
    stock_dict["stock_ask_realtime"] = ystockquote.get_ask_realtime(stock.symbol)
    stock_dict["stock_today_open"] = ystockquote.get_today_open(stock.symbol)
    stock_dict["stock_volume"] = ystockquote.get_volume(stock.symbol)
    stock_dict["stock_change"] = ystockquote.get_change(stock.symbol)
    stock_dict["stock_change_percent"] = ystockquote.get_change_percent(stock.symbol)[1:-1]
    stock_dict["stock_todays_range"] = ystockquote.get_todays_range(stock.symbol)[1:-1]

    # Gets past dates
    stock_dict["historical_prices_dict"] = collections.OrderedDict(
        sorted(eval(stock.historical_prices).items(), key=lambda t: t[0])
    )

    return stock_dict
Example #4
0
import sys;
import ystockquote;
name = raw_input('Enter name of stock')
price=ystockquote.get_price(name)
o=float(ystockquote.get_today_open(name))
h=float(ystockquote.get_todays_high(name))
l=float(ystockquote.get_todays_low(name))
c=float(ystockquote.get_previous_close(name))
p=(h+c+l)/3
r3=h+2*(p-l)
r1=2*p-l
s1=2*p-h
r2=p+(r1-s1)
s2=p-(r1-s1)
s3=l-2*(h-p)
print ('Current price of '+name+' is '+price)
print ('Resistances are:')
print (r1,r2,r3)
print ('Supports are:')
print (s1,s2,s3)
#James Dutton
#ECE492 Final Project Driver
import numpy as num
import ystockquote as ys
import urllib

#get list of stocks
F = open("stocks.txt", "r")
#create lists used throughout program
stocks = []
stockOpen = []
stockClose = []
stockDChange = []

#create list from stock document, use rstrip to remove \n
#for i in F:
#   stocks.append(i.rstrip())

#  stockDChange.append((ys.get_change(i.rstrip())))
#for i in 30:
#   stockOpen[i] = stockDchange[i] + ys.get_price()
print ys.get_today_open('GOOG')
Example #6
0
#testgui.py
# import gui lib
from Tkinter import *
import tkFont
import time

import  pywapi
import string

import ystockquote

Sapple  = "AAPL:  " + ystockquote.get_today_open('AAPL') + "\n"
Sgoogle = "GOOGL: " + ystockquote.get_today_open('GOOGL') + "\n"
Snike   = "NKE:   " + ystockquote.get_today_open('NKE') + "\n"
Sgopro  = "GPRO:  " + ystockquote.get_today_open('GPRO') + "\n"
Stesla  = "TSLA:  " + ystockquote.get_today_open('TSLA')


#get date & time set for init
dateNow = time.strftime("Today: %A %d. %B %Y\n")
timeNow = time.strftime("%I:%M%p")

#get weather set for init
weather_com_result = pywapi.get_weather_from_weather_com('12866',units="imperial")
WeatherNow = "It is " + string.lower(weather_com_result['current_conditions']['text']) + " and " + weather_com_result['current_conditions']['temperature'] + u"\N{DEGREE SIGN}F now in Saratoga Springs, NY.\n"



#create window
root = Tk()
# window settings