Example #1
0
def find():
    count = 0
    rank = []
    for stock in get_all_stock():
        price = get_stock_price(stock)

        # today, yesterday, current, high, low
        today = float(price[1])
        yesterday = float(price[2])
        current = float(price[3])
        high = float(price[4])
        low = float(price[5])
        volume = float(price[8])
        name = price[0].split('"')[-1]

        if today == '0.00':
            continue

        r = rate(current, yesterday)

        buy = int(price[10]) + int(price[12]) + int(price[14]) + int(price[16]) + int(price[18])
        sell = int(price[20]) + int(price[22]) + int(price[24]) + int(price[26]) + int(price[28])

        if sell == 0:
            bs = float(buy) / float(1)
        else:
            bs = float(buy) / float(sell)

        if volume > 0:
            buy_rate = buy / volume

        ###############

        if r > 9.9:
            count += 1
        else:
            if name.find(u'δΈ­') == 0:
                print u'{} {} {}'.format(stock, name, r)

    print count
Example #2
0
    "_id" : ObjectId("55b0d687e694aa0dbaa6779d"),
    "stock" : "600000.SS",
    "date" : "2015-07-22",
    "open" : 16.33,
    "close" : 16.16,
    "high" : 16.38,
    "low" : 16.15,
    "volume" : 120352700,
    "adj" : 16.16
}

'''

from util import get_stock_name_from_mongo, get_all_stock, get_stock_history_by_date, rate, get_stock_days, is_stop_now, calc_s_line

stocks = get_all_stock()


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)


def count_avg_s_line():
    all = []
    for stock in stocks:
__author__ = 'yu'

from datetime import datetime, timedelta
from rong import get_rong_sz
from util import get_all_stock, c


if __name__ == '__main__':
    for stock in get_all_stock():
        if stock.startswith('000') or stock.startswith('002'):
            day = datetime.now()+timedelta(days=-1)
            if day.weekday() == 6:
                day = datetime.now()+timedelta(days=-3)
            elif day.weekday() == 5:
                day = datetime.now()+timedelta(days=-2)

            date = day.strftime('%Y-%m-%d')
            result = get_rong_sz(stock[:6], date)
            if result:
                code, name, rongzi_buy, rongzi_balance, rongquan_sell_liang, rongquan_balance_liang, rongquan_balance, rong_all_balance = result
                print code

                c.history.update({
                    'date': date,
                    'stock': stock
                }, {
                    '$set': {
                        'rongzi_buy': rongzi_buy,
                        'rongzi_balance': rongzi_balance,
                        'rongquan_sell_liang': rongquan_sell_liang,
                        'rongquan_balance_liang': rongquan_balance_liang,