Example #1
0
def test():
    for stock in stocks:
        day = get_stock_history_by_date(stock, '2015-07-24')

        rate = (day['close'] - day['open']) / day['open'] * 100
        if abs(rate) > 9:
            name = get_stock_name_from_mongo(stock)
            print u'{} {} {}'.format(name, stock, rate)
Example #2
0
def find_rate():
    rank = []

    for stock in stocks:
        try:
            first_open = get_stock_history_by_date(stock, '2015-07-09')['low']
            last_close = get_stock_history_by_date(stock, '2015-07-24')['close']

            r = rate(last_close, first_open)
            rank.append((stock, r))
        except:
            continue

    ranked = sorted(rank, key=lambda r: r[1])
    for rn, rr in ranked:
        name = get_stock_name_from_mongo(rn)
        print u'{} {} {}'.format(name, rn, rr)
Example #3
0
def find_sline():
    for stock in stocks:
        if not stock.startswith('002'):
            continue

        days = get_stock_days(stock)

        if days.count() < 10:
            continue

        high = None
        low = None
        now = None

        for day in days:
            if day['close'] == 0.0:
                continue

            if (not high) or (high['close'] < day['close']):
                high = day

            if (not low) or (low['close'] > day['close']):
                low = day

            if day['date'] == "2015-11-06":
                now = day

        if high and low and now:
            name = get_stock_name_from_mongo(stock)
            print u'{}\t{}\t{}\t{}\t{}'.format(high['close'], low['close'], now['close'], stock, name)

            # high_rate = (high['close'] - now['close']) / now['close'] * 100
            # low_rate = (now['close'] - low['close']) / low['close'] * 100
            #
            # s_line = low['close'] + (high['close'] - low['close']) / 8
            #
            # if now['close'] < s_line:
            #     name = get_stock_name_from_mongo(stock)
            #     print u"{} {} {}".format(s_line, stock, name)
        else:
            pass