| | |
| | | # 保存K线形态 |
| | | @classmethod |
| | | def save_k_format(cls, code, k_format): |
| | | RedisUtils.setex(cls.__get_redis(),f"k_format-{code}", tool.get_expire(), json.dumps(k_format)) |
| | | RedisUtils.setex(cls.__get_redis(), f"k_format-{code}", tool.get_expire(), json.dumps(k_format)) |
| | | |
| | | @classmethod |
| | | def get_k_format(cls, code): |
| | |
| | | # 保存股性 |
| | | @classmethod |
| | | def save_nature(cls, code, natures): |
| | | RedisUtils.setex(cls.__get_redis(),f"code_nature-{code}", tool.get_expire(), json.dumps(natures)) |
| | | RedisUtils.setex(cls.__get_redis(), f"code_nature-{code}", tool.get_expire(), json.dumps(natures)) |
| | | |
| | | @classmethod |
| | | def get_nature(cls, code): |
| | |
| | | return 0, '' |
| | | |
| | | |
| | | # 是否涨得太高 |
| | | def is_up_too_high(record_datas): |
| | | datas = copy.deepcopy(record_datas) |
| | | datas.sort(key=lambda x: x["bob"]) |
| | | datas = datas[-10:] |
| | | limit_ups = [] |
| | | limit_up_count = 0 |
| | | for data in datas: |
| | | limit_up_price = float(gpcode_manager.get_limit_up_price_by_preprice(data["pre_close"])) |
| | | date = data['bob'].strftime("%Y-%m-%d") |
| | | if abs(limit_up_price - data["high"]) < 0.01: |
| | | limit_ups.append((date, True)) |
| | | limit_up_count += 1 |
| | | else: |
| | | limit_ups.append((date, False)) |
| | | |
| | | if limit_up_count < 3: |
| | | return False |
| | | # 连续5天有3天涨停 |
| | | for i in range(len(limit_ups)): |
| | | if i + 5 > len(limit_ups): |
| | | break |
| | | temp_datas = limit_ups[i:i + 5] |
| | | t_count = 0 |
| | | for t in temp_datas: |
| | | if t[1]: |
| | | t_count += 1 |
| | | if t_count >= 3: |
| | | return True |
| | | return False |
| | | |
| | | |
| | | # 是否有涨停 |
| | | def get_first_limit_up_count(datas): |
| | | datas = copy.deepcopy(datas) |
| | |
| | | """ |
| | | |
| | | # 处理首板代码信息 |
| | | import logging |
| | | |
| | | import constant |
| | | import inited_data |
| | |
| | | code_volumn_manager |
| | | from code_attribute.code_data_util import ZYLTGBUtil |
| | | from log_module.log import logger_first_code_record, logger_l2_codes_subscript |
| | | from third_data import kpl_api, block_info |
| | | from third_data.code_plate_key_manager import CodesHisReasonAndBlocksManager |
| | | from third_data.history_k_data_util import HistoryKDatasUtils |
| | | from third_data.kpl_data_manager import KPLLimitUpDataRecordManager |
| | | from ths import l2_code_operate |
| | | from trade import trade_data_manager |
| | | from trade import trade_data_manager, l2_trade_util |
| | | from utils import global_util, tool |
| | | |
| | | __CodesPlateKeysManager = CodesHisReasonAndBlocksManager() |
| | |
| | | volumes_data[:90])) |
| | | logger_first_code_record.info("{} 获取到首板60天最大量:{}", code, volumes) |
| | | code_volumn_manager.set_histry_volumn(code, volumes[0], volumes[1], volumes[2]) |
| | | if code_nature_analyse.is_up_too_high(volumes_data): |
| | | # 判断是否太高 |
| | | l2_trade_util.forbidden_trade(code, "股价长得太高") |
| | | |
| | | # 判断K线形态 |
| | | # is_has_k_format, msg = code_nature_analyse.is_has_k_format( |
| | | # gpcode_manager.get_limit_up_price(code), volumes_data) |
| | |
| | | l2_listen_pos_health_manager.init_all(client_infos) |
| | | |
| | | |
| | | if __name__ == "__main__": |
| | | if __name__ == "__main__1": |
| | | |
| | | # 交易成功无法读取时备用 |
| | | while True: |
| | |
| | | pass |
| | | time.sleep(1.5) |
| | | |
| | | if __name__ == "__main__1": |
| | | if __name__ == "__main__": |
| | | codes = gpcode_manager.FirstGPCodesManager().get_first_gp_codes() |
| | | for code in codes: |
| | | try: |
| | | global_data_loader.load_zyltgb() |
| | | limit_up_price = float(gpcode_manager.get_limit_up_price(code)) |
| | | volumes_data = inited_data.get_volumns_by_code(code, 150) |
| | | volumes_data = volumes_data[1:] |
| | | volumes = inited_data.parse_max_volume(volumes_data[:60], |
| | | code_nature_analyse.is_new_top(limit_up_price, |
| | | 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线形态 |
| | | k_format = code_nature_analyse.get_k_format( |
| | | limit_up_price, volumes_data) |
| | | print(k_format) |
| | | |
| | | code_nature_analyse.set_record_datas(code, |
| | | gpcode_manager.get_limit_up_price(code), |
| | | volumes_data) |
| | | except: |
| | | pass |
| | | volumes_data = inited_data.get_volumns_by_code(code, 150) |
| | | print(code, code_nature_analyse.is_up_too_high(volumes_data)) |
| | | # try: |
| | | # global_data_loader.load_zyltgb() |
| | | # limit_up_price = float(gpcode_manager.get_limit_up_price(code)) |
| | | # volumes_data = inited_data.get_volumns_by_code(code, 150) |
| | | # volumes_data = volumes_data[1:] |
| | | # volumes = inited_data.parse_max_volume(volumes_data[:60], |
| | | # code_nature_analyse.is_new_top(limit_up_price, |
| | | # 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线形态 |
| | | # k_format = code_nature_analyse.get_k_format( |
| | | # limit_up_price, volumes_data) |
| | | # print(k_format) |
| | | # |
| | | # 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, |
| | |
| | | |
| | | class BlackListCodeManager: |
| | | __instance = None |
| | | __db = 2 |
| | | __redis_manager = redis_manager.RedisManager(2) |
| | | |
| | | def __new__(cls, *args, **kwargs): |
| | |
| | | |
| | | def add_code(self, code): |
| | | self.__forbidden_trade_codes_cache.add(code) |
| | | RedisUtils.sadd(self.__get_redis(), "forbidden-trade-codes", code) |
| | | RedisUtils.expire(self.__get_redis(), "forbidden-trade-codes", tool.get_expire()) |
| | | RedisUtils.sadd_async(self.__db, "forbidden-trade-codes", code) |
| | | RedisUtils.expire_async(self.__db, "forbidden-trade-codes", tool.get_expire()) |
| | | |
| | | def sync(self): |
| | | data = RedisUtils.smembers(self.__get_redis(), |