Ejemplo n.º 1
0
    def red_head_index(self, limit_setting, type='weekly', crawling_domain='yahoo'):
        ### Init ###
        category_search_list = []

        max_vol_times = limit_setting['max_vol_times']
        stock_categories = limit_setting['stock_categories']

        price_higher_limit = limit_setting['price_higher_limit']
        price_lower_limit = limit_setting['price_lower_limit']
        vol_lower_limit = limit_setting['vol_lower_limit']
        ###-init

        my_category_crawler = CategoryCrawler()
        my_histories_crawler = HistoriesCrawler()
        my_analysis = AnalysisUtils()

        for category_id in stock_categories:
            stock_items = my_category_crawler.get_stock_id(category_id)
            for stock_id in stock_items:
                print "==========%s==========" % (stock_id)
                stock = my_histories_crawler.get_price_histories(stock_id, type, crawling_domain)
                now_inf, some_inf = my_analysis.get_last_max_volume(stock, stock_id, type, max_vol_times)

                if len(now_inf) > 0 and len(some_inf) > 0:
                    ### limit ###
                    now_price = float(now_inf[0]['inf']['close'])
                    before_price = float(some_inf[0]['inf']['high'])
                    now_vol = int(now_inf[0]['inf']['volume'])

                    if (now_price < price_lower_limit) or (now_price > price_higher_limit) or (now_vol < vol_lower_limit) or (now_price < before_price):
                        continue
                    ###-limit

                    print now_inf
                    for a in some_inf:
                        print a
Ejemplo n.º 2
0
alert_line_times = 4

if __name__ == '__main__':
    if sys.argv > 1:
        stock_id = sys.argv[1]

        if sys.argv < 3:
            pv_type = 'weekly'
        else:
            pv_type = sys.argv[2]
    else:
        print "Please give me stock id!"
        sys.exit()

    my_analysis = AnalysisUtils()
    my_histories_crawler = HistoriesCrawler()

    stock_d = my_histories_crawler.get_price_histories(stock_id, 'daily')
    stock_user_type = my_histories_crawler.get_price_histories(stock_id, pv_type)
    now_inf, some_inf = my_analysis.get_last_max_volume(stock_user_type, stock_id, pv_type, alert_line_times)

    least_date = sorted(stock_d[stock_id]['data'], reverse=True)[0]
    now_price = stock_d[stock_id]['data'][least_date]['close']
    support_pressure_price = some_inf[0]['inf']['high']

    print "=====%s(%s)=====" % (stock_id, pv_type)
    print "Now price:[%s]" % now_price
    print "Alert price:%s" % support_pressure_price
    if now_price > support_pressure_price:
        print "*** > Buy ***"
        for alert_line in xrange(1, alert_line_times):