Administrator
2023-03-28 c7b6f5be3e5850bbf66db5363e634c57ff9ca876
server.py
@@ -103,8 +103,12 @@
                type = -1
                try:
                    type = data_process.parseType(_str)
                except:
                    print(_str)
                except Exception as e:
                    if str(e).find("Unterminated string starting") > -1:
                        _str = _str.replace("\n", "")
                        type = data_process.parseType(_str)
                    else:
                        print(_str)
                return_str = "OK"
                if type == 0:
                    try:
@@ -281,37 +285,44 @@
                        bad_codes = set()
                        # 获取昨日收盘价
                        for code in codes:
                            # 如果涨停价是空值就需要设置昨日收盘价格
                            if gpcode_manager.get_limit_up_price(code) is None:
                                juejin.re_set_price_pres([code], True)
                        # 获取60天最大记录
                        for code in codes:
                            need_get_volumn = False
                            if code not in global_util.max60_volumn or global_util.max60_volumn.get(code) is None:
                                need_get_volumn = True
                            if not need_get_volumn and code_nature_analyse.CodeNatureRecordManager.get_nature(
                                    code) is None:
                                need_get_volumn = True
                            if need_get_volumn:
                                volumes_data = juejin.get_volumns_by_code(code, 150)
                                volumes = juejin.parse_max_volume(volumes_data[:60], code_nature_analyse.is_new_top(
                                    gpcode_manager.get_limit_up_price(code), volumes_data[:60]))
                                logger_first_code_record.info("{} 获取到首板60天最大量:{}", code, volumes)
                                code_volumn_manager.set_histry_volumn(code, volumes[0], volumes[1], volumes[2])
                                # 判断K线形态
                                is_has_k_format, msg = code_nature_analyse.is_has_k_format(
                                    gpcode_manager.get_limit_up_price(code), volumes_data)
                                if not is_has_k_format:
                                    logger_first_code_record.info("{}首板K线形态不好,{}", code, msg)
                                    # 股性不好,就不要加入
                                    bad_codes.add(code)
                                    # 加入禁止交易代码
                                    l2_trade_util.forbidden_trade(code)
                                code_nature_analyse.set_record_datas(code,
                                                                     gpcode_manager.get_limit_up_price(code),
                                                                     volumes_data)
                        gpcode_manager.FirstCodeManager.add_record(codes)
                        if new_add_codes:
                            gpcode_manager.set_first_gp_codes_with_data(juejin.JueJinManager.get_gp_latest_info(codes))
                            # 加入首板历史记录
                            gpcode_manager.FirstCodeManager.add_record(new_add_codes)
                            logger_first_code_record.info("新增首板:{}", new_add_codes)
                            # 获取60天最大记录
                            for code in codes:
                                need_get_volumn = False
                                if code not in global_util.max60_volumn or global_util.max60_volumn.get(code) is None:
                                    need_get_volumn = True
                                if not need_get_volumn and code_nature_analyse.CodeNatureRecordManager.get_nature(
                                        code) is None:
                                    need_get_volumn = True
                                if need_get_volumn:
                                    volumes_data = juejin.get_volumns_by_code(code, 150)
                                    volumes = juejin.parse_max_volume(volumes_data[:60], code_nature_analyse.is_new_top(
                                        gpcode_manager.get_limit_up_price(code), volumes_data[:60]))
                                    logger_first_code_record.info("{} 获取到首板60天最大量:{}", code, volumes)
                                    code_volumn_manager.set_histry_volumn(code, volumes[0], volumes[1], volumes[2])
                                    # 判断K线形态
                                    is_has_k_format, msg = code_nature_analyse.is_has_k_format(
                                        gpcode_manager.get_limit_up_price(code), volumes_data)
                                    if not is_has_k_format:
                                        logger_first_code_record.info("{}首板K线形态不好,{}", code, msg)
                                        # 股性不好,就不要加入
                                        bad_codes.add(code)
                                        # 加入禁止交易代码
                                        l2_trade_util.forbidden_trade(code)
                                    code_nature_analyse.set_record_datas(code,
                                                                         gpcode_manager.get_limit_up_price(code),
                                                                         volumes_data)
                            # 移除代码
                            listen_codes = gpcode_manager.get_listen_codes()
@@ -376,7 +387,7 @@
                        gpcode_first_screen_manager.process_ticks(prices)
                    except Exception as e:
                        pass
                        logging.exception(e)
                elif type == 3:
                    # 交易成功信息
@@ -717,16 +728,17 @@
                # 获取最近2个交易日涨停代码
                elif type == 72:
                    day = tool.get_now_date_str()
                    last_day = juejin.JueJinManager.get_previous_trading_date(day)
                    data_list = list(hot_block_data_process.XGBHotBlockDataManager.list_all(day))
                    data_list_last = list(hot_block_data_process.XGBHotBlockDataManager.list_all(last_day))
                    data_list.extend(data_list_last)
                    codes_set = set()
                    if data_list:
                        for d in data_list:
                            if len(d[4]) > 6:
                                codes_set.add(d[3])
                    return_str = json.dumps({"code": 0, "data": list(codes_set)})
                    data_dict={}
                    for i in range(0, 2):
                        day = juejin.JueJinManager.get_previous_trading_date(day)
                        data_list = list(hot_block_data_process.XGBHotBlockDataManager.list_all(day))
                        codes_set = set()
                        if data_list:
                            for d in data_list:
                                if len(d[4]) > 6:
                                    codes_set.add(d[3])
                        data_dict[day] = list(codes_set)
                    return_str = json.dumps({"code": 0, "data": data_dict})
                elif type == 201:
                    # 加入黑名单
                    data = json.loads(_str)
@@ -891,29 +903,35 @@
        l2_listen_pos_health_manager.init_all(client_infos)
if __name__ == "__main__":
    codes = ["002153", "002253", "002351"]
    for code in codes:
        global_data_loader.load_zyltgb()
        limit_up_price = float(gpcode_manager.get_limit_up_price(code))
        volumes_data = juejin.get_volumns_by_code(code, 150)
        volumes_data = volumes_data[1:]
        volumes = juejin.parse_max_volume(volumes_data[:60],
                                          code_nature_analyse.is_new_top(gpcode_manager.get_limit_up_price(code),
                                                                         volumes_data[:60]))
        logger_first_code_record.info("{} 获取到首板60天最大量:{}", code, volumes)
        code_volumn_manager.set_histry_volumn(code, volumes[0], volumes[1], volumes[2])
        # 判断K线形态
        is_has_k_format, msg = code_nature_analyse.is_has_k_format(
            gpcode_manager.get_limit_up_price(code), volumes_data)
        if not is_has_k_format:
            logger_first_code_record.info("{}首板K线形态不好,{}", code, msg)
            # 加入禁止交易代码
            l2_trade_util.forbidden_trade(code)
if __name__ == "__main__1":
    cid, pid = gpcode_manager.get_listen_code_pos("000070")
    print(cid, pid)
        code_nature_analyse.set_record_datas(code,
                                             gpcode_manager.get_limit_up_price(code),
                                             volumes_data)
if __name__ == "__main__":
    codes = ["603655"]
    for code in codes:
        try:
            global_data_loader.load_zyltgb()
            limit_up_price = float(gpcode_manager.get_limit_up_price(code))
            volumes_data = juejin.get_volumns_by_code(code, 150)
            volumes = juejin.parse_max_volume(volumes_data[:60],
                                              code_nature_analyse.is_new_top(gpcode_manager.get_limit_up_price(code),
                                                                             volumes_data[:60]))
            logger_first_code_record.info("{} 获取到首板60天最大量:{}", code, volumes)
            code_volumn_manager.set_histry_volumn(code, volumes[0], volumes[1], volumes[2])
            # 判断K线形态
            is_has_k_format, msg = code_nature_analyse.is_has_k_format(
                gpcode_manager.get_limit_up_price(code), volumes_data)
            if not is_has_k_format:
                logger_first_code_record.info("{}首板K线形态不好,{}", code, msg)
                # 加入禁止交易代码
                l2_trade_util.forbidden_trade(code)
            code_nature_analyse.set_record_datas(code,
                                                 gpcode_manager.get_limit_up_price(code),
                                                 volumes_data)
        except:
            pass
        # code_nature_analyse.set_record_datas(code,
        #                                      limit_up_price,