コード例 #1
0
def short_stock_basic(stock):
    """
    短线股票基本面分析
    :return:
    """
    stock_info = get_stock_info(stock)
    try:
        famc = float(stock_info["stock_facm"])
        active_pe = float(stock_info["stock_pe_active"])
        static_pe = float(stock_info["stock_pe_static"])

        if active_pe >= 300 or active_pe < 0:
            active_pe = 300.0
    except Exception:
        print u'[info]股票代码有误或网络错误。'
    stock_basic_score = 1

    # 市值分析
    if famc >= 5000:
        stock_basic_score *= 0.91
        stock_basic_info = u"公司市值巨大,"
    elif 5000 > famc >= 2000:
        stock_basic_score *= 0.92
        stock_basic_info = u"公司市值很大,"
    elif 2000 > famc >= 1000:
        stock_basic_score *= 0.95
        stock_basic_info = u"公司市值较大,"
    elif 1000 > famc >= 500:
        stock_basic_score *= 0.98
        stock_basic_info = u"公司市值适中,"
    elif 500 > famc >= 100:
        stock_basic_score *= 1.06
        stock_basic_info = u"公司市值适中,"
    elif 100 > famc >= 50:
        stock_basic_score *= 1.2
        stock_basic_info = u"公司市值较小,"
    elif 50 > famc >= 10:
        stock_basic_score *= 1.1
        stock_basic_info = u"公司市值很小,"
    elif famc <= 10:
        stock_basic_score *= 0.95
        stock_basic_info = u"公司市值极小,"

    # 市盈率分析
    if active_pe > 190:
        stock_basic_score *= 0.93
        stock_basic_info += u"市盈率>190,"
    elif 190 >= active_pe > 150:
        stock_basic_score *= 0.95
        stock_basic_info += u"市盈率150~190,"
    elif 150 >= active_pe > 60:
        stock_basic_score *= 1.02
        stock_basic_info += u"市盈率60~150,"
    elif 60 >= active_pe > 20:
        stock_basic_score *= 1.05
        stock_basic_info += u"市盈率20~60,"
    elif 20 >= active_pe > 10:
        stock_basic_score *= 1.02
        stock_basic_info += u"市盈率10~20,"
    elif 10 >= active_pe > 5:
        stock_basic_score *= 0.98
        stock_basic_info += u"市盈率5~10,"
    elif active_pe < 5:
        stock_basic_score *= 0.95
        stock_basic_info += u"市盈率<5,"

    if stock_basic_score >= 1.2:
        stock_basic_info += u"短线投资基本面较好"
    elif 1.2 > stock_basic_score >= 1.1:
        stock_basic_info += u"短线投资基本面较好"
    elif 1.1 > stock_basic_score >= 1.05:
        stock_basic_info += u"短线投资基本面一般"
    elif 1.05 > stock_basic_score >= 0.95:
        stock_basic_info += u"短线投资基本面一般"
    elif 0.95 > stock_basic_score >= 0.85:
        stock_basic_info += u"短线投资基本面较差"
    elif 0.85 > stock_basic_score:
        stock_basic_info += u"短线投资基本面较差"

    stock_info['basic_score'] = stock_basic_score
    stock_info['basic_info'] = stock_basic_info

    return stock_info
コード例 #2
0
def mid_stock_basic(stock):
    """
    中线股票基本面分析
    :param stock:
    :return:
    """
    stock_info = get_stock_info(stock)
    try:
        famc = float(stock_info["stock_facm"])
        active_pe = float(stock_info["stock_pe_active"])
        static_pe = float(stock_info["stock_pe_static"])

        if active_pe >= 300 or active_pe < 0:
            active_pe = 300.0
    except Exception:
        print u'[info]股票代码有误或网络错误。'
    stock_basic_score = 1
    stock_basic_info = ""

    # 市值分析
    if famc >= 5000:
        stock_basic_score *= 0.95
        stock_basic_info = u"公司市值巨大,"
    elif 5000 > famc >= 2000:
        stock_basic_score *= 0.96
        stock_basic_info = u"公司市值很大,"
    elif 2000 > famc >= 1000:
        stock_basic_score *= 0.97
        stock_basic_info = u"公司市值较大,"
    elif 1000 > famc >= 500:
        stock_basic_score *= 0.98
        stock_basic_info = u"公司市值略大,"
    elif 500 > famc >= 100:
        stock_basic_score *= 1.02
        stock_basic_info = u"公司市值适中,"
    elif 100 > famc >= 50:
        stock_basic_score *= 0.99
        stock_basic_info = u"公司市值较小,"
    elif 50 > famc >= 10:
        stock_basic_score *= 0.95
        stock_basic_info = u"公司市值很小,"
    elif famc <= 10:
        stock_basic_score *= 0.88
        stock_basic_info = u"公司市值极小,"

    # 市盈率分析
    if active_pe > 150:
        stock_basic_score *= 0.8
        stock_basic_info += u"市盈率>150,"
    elif 150 >= active_pe > 60:
        stock_basic_score *= 0.85
        stock_basic_info += u"市盈率>60,"
    elif 60 >= active_pe > 20:
        stock_basic_score *= 0.9
        stock_basic_info += u"市盈率20~60,"
    elif 20 >= active_pe > 10:
        stock_basic_score *= 1
        stock_basic_info += u"市盈率10~20,"
    elif 10 >= active_pe > 5:
        stock_basic_score *= 1.1
        stock_basic_info += u"市盈率5~10,"
    elif active_pe < 5:
        stock_basic_score *= 1.2
        stock_basic_info += u"市盈率<5,"

    if stock_basic_score >= 1.2:
        stock_basic_info += u"中线投资价值极大"
    elif 1.2 > stock_basic_score >= 1.1:
        stock_basic_info += u"中线投资价值较大"
    elif 1.1 > stock_basic_score >= 1.05:
        stock_basic_info += u"略有中线投资价值"
    elif 1.05 > stock_basic_score >= 0.95:
        stock_basic_info += u"中线投资价值一般"
    elif 0.95 > stock_basic_score >= 0.85:
        stock_basic_info += u"中线投资价值较差"
    elif 0.85 > stock_basic_score:
        stock_basic_info += u"不建议中线投资该股票"
    stock_info['basic_score'] = stock_basic_score
    stock_info['basic_info'] = stock_basic_info

    return stock_info