Beispiel #1
0
def eval_stock(ticker):
    result = "Summary: "
    score = 0
    momentum = False
    if ystockquote.get_50_sma(ticker) > ystockquote.get_200_sma(ticker):
        result+="stock has momentum, 50 day moving avg is %s and 200 day is %s" % (ystockquote.get_50_sma(ticker),
        ystockquote.get_200_sma(ticker))
        score+=1
        momentum=True
    else:
        result+="Stock has no momentum, 50 day moving avg is %s and 200 day is %s" % (ystockquote.get_50_sma(ticker),
        ystockquote.get_200_sma(ticker))

    if float(ystockquote.get_1_year_target(ticker)) > (1.2 * float(ystockquote.get_todays_high(ticker))):
        result+=" 20% away from price target"
        score += 1

    #Short ratio of 5 or higher with positive momentum means investors may likely buy to cover soon
    if momentum==True and float(ystockquote.get_short_ratio(ticker)) > 3.0:
        score+=2

    result+= " \n short ratio is " + ystockquote.get_short_ratio(ticker)

    if float(ystockquote.get_eps(ticker))>.02*float(ystockquote.get_todays_high(ticker)):
        score+=1.5

    result += " \n EPS: " + ystockquote.get_eps(ticker) + " today's high is " + ystockquote.get_todays_high(ticker)

    result+= " \n , notes (if applicable)" + ystockquote.get_notes(ticker)
    return result, "Score is " + str(score)
 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))
Beispiel #4
0
        lines=my_file.readlines()

    for line in lines:
        #get rid of the new line syntax
        line=line.strip("',/\n[]")
        tickers.append(line)

    return tickers

print(store_tickers("tickers.csv"))



print (eval_stock('CSG'))

print (type(float(ystockquote.get_todays_high('GOOG'))))

print(ystockquote.get_short_ratio('LQMT'))


print(ystockquote.get_eps_estimate_current_year('GOOG'))
#trailing 12 months number
print(ystockquote.get_eps('GOOG'))
print(ystockquote.get_price_eps_estimate_current_year('GOOG'))



##Some of the methods available
name = ystockquote.get_company_name('GOOG')

mktcap = ystockquote.get_market_cap('GOOG')
def get_todays_high(symbol):
    cur_price = ystockquote.get_todays_high(symbol)
    if ('N/A' == cur_price):
        return 0.1
    else:
        return cur_price
Beispiel #6
0
def get_todays_high(symbol):
	cur_price = ystockquote.get_todays_high(symbol)
        if('N/A' == cur_price):
                return 0.1
        else:
                return cur_price
Beispiel #7
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)