示例#1
0
def lowest_manager_sort():
    #lowest_codes = filte_lowest_from_google(lowest_detail)
    # best = list(set(manager_buy_codes) & set(lowest_codes))
    #lowest_percent_sort = sorted([i for i in lowest_detail if i['code'] in lowest_codes],key=lambda x:x['L%'])
    lowest = []

    for i in lowest_google_detail:
        code = i['code']
        # sale_price = i['price'] + (i['H'] - i['price'])/2
        # profit = int((sale_price / i['price'] -1)*100)
        low = i['L']
        price = price_now.get(code, 10000)
        i['price'] = price
        lowest_percent_now = int(float(price - low) * 100 / low)
        i['L%'] = lowest_percent_now
        avg_200_percent = int(price / i['Avg'] * 100 - 100)
        i['Avg%'] = avg_200_percent
        left = price - i['L']
        right = i['H'] - price
        i['P%'] = 10000
        if right + left:
            i['P%'] = int(right / price * 100)
        # i['sale'] = sale_price
        # i['P%'] = profit
        # i['MB'] = manager_buy.get(i['code'], 10000)
        # i['MS'] = manager_sale.get(i['code'], 10000)
        # i['MTP'] = manager_5days_buy_dict[i['code']]['total_price']
        # i['date'] = manager_5days_buy_dict[i['code']]['date']
        # i['Avg'] = manager_5days_buy_dict[i['code']]['avg']
        i['TOR'] = turn_over_ratio.get(i['code'], 10000)
        i['LB'] = quantity_relative_ratio.get(i['code'], 10000)
        # i['FL'] = rise_top.get(i['code'], -10000)
        #        i['IF%'] = in_flow_ratio.get(i['code'], 10000)
        i['NMC'] = stock_size.get(i['code'], 0)
        i['CH'] = change_ratio.get(i['code'], 10000)
        i['CH5'] = week_change.get(i['code'], 10000)
        i['CH30'] = month_change.get(i['code'], 10000)
        i['CH90'] = quarter_change.get(i['code'], 10000)
        i['PE'] = pe_ratio.get(code, 10000)
        i['OPEN'] = open_price.get(code, 10000)
        # print json.dumps(i)
        #   if i['P%'] != 10000 and i['L%'] < 61.8 and i['PE'] > 0 and i['PE'] <100 and i['P%'] > 50:
        # i['LB'] != 10000 and i['TOR'] != 10000 and
        #  and i['CH'] < 5 and i['CH'] > -5:
        # and i['Avg%'] < 20:
        # and i['P%'] > 20:
        # and i['MB'] != 10000 i['TOR'] != 10000 and  :
        # and i['price'] /i['MB'] < 1.2:
        #      print i['L']
        lowest.append(i)
    #       print lowest[-1]['L']
    #         lowest_50.append(i)

    lowest_P = sorted(lowest, key=lambda x: x['P%'], reverse=True)
    print 'bull stock from sina:'
    sina_codes = list(set(bull_code + b_point_code))
    sina_lowest = [
        i for i in lowest_P
        if i['code'] in bull_code and i['L%'] < 100 and i['P%'] > 30
    ]  # and i['OPEN'] < 3 and i['OPEN'] > -3 and i['CH5']<10 and i['CH5']>0]
    table_util.print_list(sina_lowest, [
        'code', 'L', 'L%', 'P%', 'price', 'Avg%', 'TOR', 'LB', 'NMC', 'CH',
        'CH5', 'CH30', 'CH90', 'PE', 'OPEN'
    ])
    print 'sgcx from tencent:'
    tencent_lowest = [
        i for i in lowest_P
        if i['code'] in sgcx_code and i['L%'] < 100 and i['P%'] > 30
    ]
    table_util.print_list(tencent_lowest, [
        'code', 'L', 'L%', 'P%', 'price', 'Avg%', 'TOR', 'LB', 'NMC', 'CH',
        'CH5', 'CH30', 'CH90', 'PE', 'OPEN'
    ])
示例#2
0
def lowest_manager_sort():
    # lowest_codes = filte_lowest_from_google(lowest_detail)
    # best = list(set(manager_buy_codes) & set(lowest_codes))
    # lowest_percent_sort = sorted([i for i in lowest_detail if i['code'] in lowest_codes],key=lambda x:x['L%'])
    lowest = []

    for i in lowest_google_detail:
        code = i["code"]
        # sale_price = i['price'] + (i['H'] - i['price'])/2
        # profit = int((sale_price / i['price'] -1)*100)
        low = i["L"]
        price = price_now.get(code, 10000)
        i["price"] = price
        lowest_percent_now = int(float(price - low) * 100 / low)
        i["L%"] = lowest_percent_now
        avg_200_percent = int(price / i["Avg"] * 100 - 100)
        i["Avg%"] = avg_200_percent
        left = price - i["L"]
        right = i["H"] - price
        i["P%"] = 10000
        if right + left:
            i["P%"] = int(right / price * 100)
        # i['sale'] = sale_price
        # i['P%'] = profit
        # i['MB'] = manager_buy.get(i['code'], 10000)
        # i['MS'] = manager_sale.get(i['code'], 10000)
        # i['MTP'] = manager_5days_buy_dict[i['code']]['total_price']
        # i['date'] = manager_5days_buy_dict[i['code']]['date']
        # i['Avg'] = manager_5days_buy_dict[i['code']]['avg']
        i["TOR"] = turn_over_ratio.get(i["code"], 10000)
        i["LB"] = quantity_relative_ratio.get(i["code"], 10000)
        # i['FL'] = rise_top.get(i['code'], -10000)
        #        i['IF%'] = in_flow_ratio.get(i['code'], 10000)
        i["NMC"] = stock_size.get(i["code"], 0)
        i["CH"] = change_ratio.get(i["code"], 10000)
        i["CH5"] = week_change.get(i["code"], 10000)
        i["CH30"] = month_change.get(i["code"], 10000)
        i["CH90"] = quarter_change.get(i["code"], 10000)
        i["PE"] = pe_ratio.get(code, 10000)
        i["OPEN"] = open_price.get(code, 10000)
        # print json.dumps(i)
        #   if i['P%'] != 10000 and i['L%'] < 61.8 and i['PE'] > 0 and i['PE'] <100 and i['P%'] > 50:
        # i['LB'] != 10000 and i['TOR'] != 10000 and
        #  and i['CH'] < 5 and i['CH'] > -5:
        # and i['Avg%'] < 20:
        # and i['P%'] > 20:
        # and i['MB'] != 10000 i['TOR'] != 10000 and  :
        # and i['price'] /i['MB'] < 1.2:
        #      print i['L']
        lowest.append(i)
    #       print lowest[-1]['L']
    #         lowest_50.append(i)

    lowest_P = sorted(lowest, key=lambda x: x["P%"], reverse=True)
    print "bull stock from sina:"
    sina_codes = list(set(bull_code + b_point_code))
    sina_lowest = [
        i for i in lowest_P if i["code"] in bull_code and i["L%"] < 100 and i["P%"] > 30
    ]  # and i['OPEN'] < 3 and i['OPEN'] > -3 and i['CH5']<10 and i['CH5']>0]
    table_util.print_list(
        sina_lowest,
        ["code", "L", "L%", "P%", "price", "Avg%", "TOR", "LB", "NMC", "CH", "CH5", "CH30", "CH90", "PE", "OPEN"],
    )
    print "sgcx from tencent:"
    tencent_lowest = [i for i in lowest_P if i["code"] in sgcx_code and i["L%"] < 100 and i["P%"] > 30]
    table_util.print_list(
        tencent_lowest,
        ["code", "L", "L%", "P%", "price", "Avg%", "TOR", "LB", "NMC", "CH", "CH5", "CH30", "CH90", "PE", "OPEN"],
    )
示例#3
0
def check_manager_transaction(choice):
    # choice 1 for buy, 2 for sale
    # check manager sale, we sale
    # manager_codes would be sale or buy codes

    hold_codes = []
    hold_detail = []
    with open('hold.txt', 'r') as fb:
        lines = fb.readlines()
        for i in lines:
            line = json.loads(i)
            # print line['code']
            hold_codes.append(line['code'])
            hold_detail.append(line)
    with open('candidate.txt', 'r') as fb:
        lines = fb.readlines()
        for i in lines:
            code = i.split()[1]
            hold_codes.append(code)
            hold_detail.append({'code': code})
    # should_transaction = set(hold_codes) & set(manager_codes)
    # if choice == 1:
    #     # print 'Manager buy num : %d' % len(manager_codes)
    #     print 'My hold: %s\n' % hold_codes
    #     print "buy More stock today:"
    #     for i in should_transaction:
    #         print i
    #     print '#' * 40 +'\n'

    # else:
    #     print 'Manager sales num : %d' % len(manager_codes)
    # print 'My hold: %s\n' % hold_codes
    my_hold = []
    for i in lowest_google_detail:
        code = i['code']
        for j in hold_detail:
            if code == j['code']:
                lowest = i['L']
                price_hold = j.get('price', 10000)
                price = price_now.get(code, 10000)
                i['price'] = price
                lowest_percent_now = int(float(price - lowest) * 100 / lowest)
                i['L%'] = lowest_percent_now
                avg_200_percent = int(price / i['Avg'] * 100 - 100)
                i['Avg%'] = avg_200_percent
                profit_now = int((price / price_hold) * 100 - 100)
                i['P%_now'] = profit_now
                # sale_price = price_hold + (i['H'] - price_hold)/2
                sale_price = price_hold * 1.05
                profit = int((sale_price / i['price'] - 1) * 100)
                i['sale'] = int(sale_price * 100) / 100.0
                left = price - i['L']
                right = i['H'] - price
                i['P%'] = int(right / price * 100)
                i['TOR'] = turn_over_ratio.get(code, 10000)
                i['LB'] = quantity_relative_ratio.get(code, 10000)
                # i['IF%'] = in_flow_ratio.get(code, 10000)
                i['NMC'] = stock_size.get(code, 0)
                i['CH'] = change_ratio.get(code, 10000)
                i['CH5'] = week_change.get(code, 10000)
                i['CH30'] = month_change.get(code, 10000)
                i['CH90'] = quarter_change.get(code, 10000)
                i['PE'] = pe_ratio.get(code, 10000)
                i['OPEN'] = open_price.get(code, 10000)
                if price / price_hold < 2:
                    my_hold.append(i)
    print 'my hold stock:'
    table_util.print_list(my_hold, [
        'code', 'L%', 'P%', 'L', 'price', 'H', 'sale', 'Avg%', 'P%_now', 'TOR',
        'LB', 'NMC', 'CH', 'CH5', 'CH30', 'CH90', 'OPEN', 'PE'
    ])
    #short = bull_code + b_point_code
    #keep = [i for i in my_hold if i['code'] in short]
    #table_util.print_list(keep, ['code', 'L%', 'P%', 'L', 'price', 'H', 'sale',
    #                                'Avg%', 'P%_now', 'TOR', 'LB', 'NMC', 'CH', 'CH5', 'CH30', 'CH90', 'PE'])
    # print "Sale stock today:"
    # for i in should_transaction:
    #     print i
    print '#' * 40 + '\n'
示例#4
0
def check_manager_transaction(choice):
    # choice 1 for buy, 2 for sale
    # check manager sale, we sale
    # manager_codes would be sale or buy codes

    hold_codes = []
    hold_detail = []
    with open("hold.txt", "r") as fb:
        lines = fb.readlines()
        for i in lines:
            line = json.loads(i)
            # print line['code']
            hold_codes.append(line["code"])
            hold_detail.append(line)
    with open("candidate.txt", "r") as fb:
        lines = fb.readlines()
        for i in lines:
            code = i.split()[1]
            hold_codes.append(code)
            hold_detail.append({"code": code})
    # should_transaction = set(hold_codes) & set(manager_codes)
    # if choice == 1:
    #     # print 'Manager buy num : %d' % len(manager_codes)
    #     print 'My hold: %s\n' % hold_codes
    #     print "buy More stock today:"
    #     for i in should_transaction:
    #         print i
    #     print '#' * 40 +'\n'

    # else:
    #     print 'Manager sales num : %d' % len(manager_codes)
    # print 'My hold: %s\n' % hold_codes
    my_hold = []
    for i in lowest_google_detail:
        code = i["code"]
        for j in hold_detail:
            if code == j["code"]:
                lowest = i["L"]
                price_hold = j.get("price", 10000)
                price = price_now.get(code, 10000)
                i["price"] = price
                lowest_percent_now = int(float(price - lowest) * 100 / lowest)
                i["L%"] = lowest_percent_now
                avg_200_percent = int(price / i["Avg"] * 100 - 100)
                i["Avg%"] = avg_200_percent
                profit_now = int((price / price_hold) * 100 - 100)
                i["P%_now"] = profit_now
                # sale_price = price_hold + (i['H'] - price_hold)/2
                sale_price = price_hold * 1.05
                profit = int((sale_price / i["price"] - 1) * 100)
                i["sale"] = int(sale_price * 100) / 100.0
                left = price - i["L"]
                right = i["H"] - price
                i["P%"] = int(right / price * 100)
                i["TOR"] = turn_over_ratio.get(code, 10000)
                i["LB"] = quantity_relative_ratio.get(code, 10000)
                # i['IF%'] = in_flow_ratio.get(code, 10000)
                i["NMC"] = stock_size.get(code, 0)
                i["CH"] = change_ratio.get(code, 10000)
                i["CH5"] = week_change.get(code, 10000)
                i["CH30"] = month_change.get(code, 10000)
                i["CH90"] = quarter_change.get(code, 10000)
                i["PE"] = pe_ratio.get(code, 10000)
                i["OPEN"] = open_price.get(code, 10000)
                if price / price_hold < 2:
                    my_hold.append(i)
    print "my hold stock:"
    table_util.print_list(
        my_hold,
        [
            "code",
            "L%",
            "P%",
            "L",
            "price",
            "H",
            "sale",
            "Avg%",
            "P%_now",
            "TOR",
            "LB",
            "NMC",
            "CH",
            "CH5",
            "CH30",
            "CH90",
            "OPEN",
            "PE",
        ],
    )
    # short = bull_code + b_point_code
    # keep = [i for i in my_hold if i['code'] in short]
    # table_util.print_list(keep, ['code', 'L%', 'P%', 'L', 'price', 'H', 'sale',
    #                                'Avg%', 'P%_now', 'TOR', 'LB', 'NMC', 'CH', 'CH5', 'CH30', 'CH90', 'PE'])
    # print "Sale stock today:"
    # for i in should_transaction:
    #     print i
    print "#" * 40 + "\n"