Ejemplo n.º 1
0
 def __init__(self, screen ):
     self.screen = screen
     pending_tickers = self.get_pending_tickers()
     url = make_finviz_url( screen )
     pretty_html = get_pretty_html( url )
     self.tickers = []
     counter = 0
     max_len = random.randrange(6, 7) 
     while find_between( pretty_html, '<a href="quote.ashx?t=', '&amp;' ):
         if counter > max_len:
             break        
         ticker = find_between( pretty_html, '<a href="quote.ashx?t=', '&amp;' )
         pretty_html = pretty_html.replace('<a href="quote.ashx?t=','',1)
         if ticker in pending_tickers:
             continue
         if ticker in excluded_tickers:
             continue
         print "testing ticker " + ticker
         # only take tickers older than 25 days
         age = get_ticker_article_age( ticker )
         if is_old_enough( age ):
             self.tickers.append( ticker )
             counter = counter + 1
Ejemplo n.º 2
0
#!/usr/bin/env python

import check_ticker_age

# successful returns
# expect False
age = check_ticker_age.get_ticker_article_age( 'BIP' )
assert( False == check_ticker_age.is_old_enough( age ) )
# expect True
age = check_ticker_age.get_ticker_article_age( 'AIZ' )
assert( check_ticker_age.is_old_enough( age ) )

# no articles # expect True
age = check_ticker_age.get_ticker_article_age( 'BTI' )
assert( check_ticker_age.is_old_enough( age ) )

# bad ticker
try:
    age = check_ticker_age.get_ticker_article_age( 'TURDS' )
except Exception as error:
    print "TICKER NOT FOUND!"
    assert( error.args[0] == "TICKER NOT FOUND!" )