예제 #1
0
def makeVolumeUpHtml(stock_dic_list):
    
    KST=datetime.now(timezone('Asia/Seoul'))
    time_info = KST.strftime('%Y-%m-%d %H:%M')
    stock_html = "<head><link rel=\"stylesheet\" href=\"http://choicestock.cafe24.com/wp-content/themes/sparkling/style.css\"></head>"
    
    stock_html += "<span style=\"font-size: 10pt;\">금일의 거래폭발 랭킹</span><br>"\
    "<span style=\"font-size: 10pt;\">"+time_info+"기준 발행된 증권사 리서치 보고서 중 목표가와 현 주가의 괴리율이  큰 기업 중 거래량이 폭증한 종목 입니다.</span><br>"\
    "<br/>"\
    "&nbsp;" 
    
    pre_stockconsen_html =""
    
    count = 1
    catchedcount = 1
    for stock_dic in stock_dic_list:
                
        try:
            volume_ratio, stockdetailhtml = makeStockDetailHtml(stock_dic['stock_code'])
        except Exception as e:
            print '--- stack ---'
            traceback.print_stack()
            print '--- exec ---'
            traceback.print_exc()
            print 'stockdetail exception'
         
        if(Preference.getVolAgainstTime(volume_ratio)):
            catchedcount = catchedcount + 1
            stock_html += \
            "<hr style=\"border: double 1px black;\">"\
            "<span style=\"font-size: 10pt;\"><span style=\"font-size: 18pt;\"><strong><a href=\"https://finance.naver.com/item/main.nhn?code="+stock_dic['stock_code'].encode('UTF-8')+"\" target=\"_blank\">" +stock_dic['stock_name'].encode('UTF-8')+"</a></strong></span>("+stock_dic['stock_code'].encode('UTF-8')+") 현재가 : "+ stock_dic['now_price'].encode('UTF-8')+"("+stock_dic['now_updown_rate'].encode('UTF-8')+")<br>"\
            "<a href=\""+stock_dic['companyinfo_url'].encode('UTF-8')+"\">[기업]</a><a href=\""+stock_dic['report_url'].encode('UTF-8')+"\">[report]</a></span><br>"
                                         
            stock_html += "<span style=\"font-size: 10pt;\"><span style=\"font-size: 12pt;\"><strong>목표가 대비 현재가 : "+stock_dic['diff_rate'].encode('UTF-8')+"%</strong></span> (현재 "+stock_dic['now_price'].encode('UTF-8')+" / <strong>목표"+stock_dic['new_price'].encode('UTF-8')+"</strong>)</span><br>"\
            "<span style=\"font-size: 10pt;\">"+stock_dic['analyst_company'].encode('UTF-8')+"("+stock_dic['analyst_name'].encode('UTF-8')+") : "+stock_dic['update_date'].encode('UTF-8')+"</span><br>"\
            "<span style=\"font-size: 10pt;\">   - "+stock_dic['title'].encode('UTF-8')+"</span>"
            
            stock_html += stockdetailhtml
            
            try:
                pre_stockconsen_html=makePreSTOCKHtml(stock_dic['stock_code'])
                #print "."
            except Exception as e:
                print '--- stack ---'
                traceback.print_stack()
                print '--- exec ---'
                traceback.print_exc()
                print 'prestockhtml exception'
    
            stock_html += pre_stockconsen_html + '<br>'
            
        count = count+1
        if (count > Preference.getStockRankCount()):
            break
                
    stock_html += \
    "<br><br>"\
    "<hr style=\"border: double 1px black;\">"\
    "<span style=\"font-size: 10pt;\">증권 투자는 원금손실의 가능성에 유의하시고, 투자자 본인의 판단과 책임하에 최종 결정을 하셔야 합니다. </span><br>"\
    "<span style=\"font-size: 10pt;\">본 자료는 어떠한 경우에도 증권투자 결과에 대한 법적 책임소재의 증빙자료로 사용될 수 없습니다.</span><br>"    
    
    return catchedcount, stock_html
예제 #2
0
def makeUpturnStockHtml(stock_dic_list):

    KST = datetime.now(timezone('Asia/Seoul'))
    time_info = str(KST.strftime('%Y-%m-%d %H:%M'))

    stock_html = "<span style=\"font-size: 11pt;\">"+time_info+" 목표가 상향 특징주.</span><br>"\
    "<br/>"\
    "&nbsp;"

    pre_stockconsen_html = ""

    count = 1
    for stock_dic in stock_dic_list:

        stock_html_head = ""
        stock_html_head += ""\
        "<hr style=\"border: double 1px black;\">"\
        "<span style=\"font-size: 10pt;\"><span style=\"font-size: 18pt;\"><strong><a href=\"https://finance.naver.com/item/main.nhn?code="+stock_dic['stock_code']+"\" target=\"_blank\">" +stock_dic['stock_name']+"</a></strong></span>("+stock_dic['stock_code']+") 현재가 : "+ stock_dic['now_price']+"("+stock_dic['now_updown_rate']+")<br>"\
        "<a href=\""+stock_dic['companyinfo_url']+"\"> [기업]</a><a href=\""+stock_dic['report_url']+"\">[report]</a></span><br>"

        stock_html_head += "<strong>상승률  : " + stock_dic[
            'upper_rate'] + "%</strong> (<strong>신규" + stock_dic[
                'new_price'] + "</strong> / 이전 " + stock_dic[
                    'old_price'] + ")</span><br>"
        stock_html_head += "<strong>목표가 대비 현재가 : "
        stock_html_head += makeMarkTagStart('70', stock_dic['diff_rate'],
                                            'DIFF_RATE', '')
        stock_html_head += stock_dic['diff_rate'] + "%</strong>"
        stock_html_head += makeMarkTagEnd()
        stock_html_head += "(현재 "+stock_dic['now_price']+" / <strong>목표"+stock_dic['new_price']+"</strong>)</span><br>"\
        "<span style=\"font-size: 10pt;\">"+stock_dic['analyst_company']+"("+stock_dic['analyst_name']+") : "+stock_dic['update_date']+"</span><br>"\
        "<span style=\"font-size: 10pt;\"> - "+stock_dic['title']+"</span>"

        try:
            volume_ratio, detail_html = makeStockDetailHtml(
                stock_dic['stock_code'], stock_dic)

            if (Preference.getVolAgainstTime(volume_ratio)):

                #종목이 하나라도 잡히면 True로 세팅.
                ResultVO.setIsCatched(True)

                stock_html += stock_html_head
                stock_html += detail_html

                ##이전 목표주가 가져오기
                pre_stockconsen_html = makePreSTOCKHtml(
                    stock_dic['stock_code'])
                stock_html += pre_stockconsen_html + '<br>'

            else:
                print("거래량 미달로 PASS")

        except Exception as e:
            print('--- stack ---')
            traceback.print_stack()
            print('--- exec ---')
            traceback.print_exc()
            print('prestockhtml exception')
        #print "."

        print('Making Upturn HTML Complete')
        count = count + 1

    return stock_html