| | |
| | | p9 = is_special(record_datas) |
| | | p10 = is_latest_10d_max_volume_at_latest_2d(record_datas) |
| | | p11 = __is_yesterday_open_limit_up(record_datas) |
| | | # 30天内是否有涨停 |
| | | p12 = __has_limit_up(record_datas, 30) |
| | | |
| | | return p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11 |
| | | return p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12 |
| | | |
| | | |
| | | # 是否具有K线形态 |
| | | def is_has_k_format(limit_up_price, record_datas): |
| | | is_too_high, is_new_top, is_lowest, is_near_new_top, is_n, is_v, has_format, volume_info, is_special, has_max_volume, open_limit_up = get_k_format( |
| | | is_too_high, is_new_top, is_lowest, is_near_new_top, is_n, is_v, has_format, volume_info, is_special, has_max_volume, open_limit_up, is_limit_up_in_30days = get_k_format( |
| | | float(limit_up_price), record_datas) |
| | | if not has_format: |
| | | return False, "不满足K线形态" |
| | |
| | | min_price = d["low"] |
| | | if max_price < d["high"]: |
| | | max_price = d["high"] |
| | | if max_price > float(limit_up_price): |
| | | return False |
| | | # if max_price > float(limit_up_price): |
| | | # return False |
| | | rate = (float(limit_up_price) - min_price) / min_price |
| | | # print(rate) |
| | | if rate >= 0.28: |
| | |
| | | |
| | | def is_new_top(limit_up_price, datas): |
| | | return __is_new_top(float(limit_up_price), datas)[0] |
| | | |
| | | |
| | | def is_near_top(limit_up_price, datas): |
| | | return __is_near_new_top(float(limit_up_price), datas)[0] |
| | | |
| | | |
| | | # 接近新高 |
| | |
| | | return abs(limit_up_price - data["high"]) < 0.001 |
| | | |
| | | |
| | | # 多少天内是否有涨停/曾涨停 |
| | | def __has_limit_up(datas, day_count): |
| | | datas = copy.deepcopy(datas) |
| | | datas.sort(key=lambda x: x["bob"]) |
| | | datas = datas[0 - day_count:] |
| | | if len(datas) >= 1: |
| | | for i in range(0, len(datas)): |
| | | item = datas[i] |
| | | if __is_limit_up(item): |
| | | return True |
| | | return False |
| | | |
| | | |
| | | # 首板涨停溢价率 |
| | | def get_limit_up_premium_rate(datas): |
| | | datas = copy.deepcopy(datas) |
| | |
| | | volumes = init_data_util.parse_max_volume(volumes_data[:90], |
| | | code_nature_analyse.is_new_top( |
| | | limit_up_price, |
| | | volumes_data[:90]) or code_nature_analyse.is_near_top( |
| | | limit_up_price, |
| | | 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_in_120d(volumes_data): |
| | | # 判断是否太高 |
| | | # l2_trade_util.forbidden_trade(code, "120天内股价长得太高") |
| | | HighIncreaseCodeManager().add_code(code) |
| | | # HighIncreaseCodeManager().add_code(code) |
| | | pass |
| | | |
| | | if code_nature_analyse.is_price_too_high_in_days(volumes_data, limit_up_price): |
| | | # 判断是否太高 |
| | | l2_trade_util.forbidden_trade(code, "6天内股价长得太高") |
| | | HighIncreaseCodeManager().add_code(code) |
| | | # HighIncreaseCodeManager().add_code(code) |
| | | |
| | | if code_nature_analyse.is_have_latest_max_volume(volumes_data, 2): |
| | | # 最近2天是否是最高量 |
| | |
| | | if total_left_count > 5: |
| | | break |
| | | # 成交进度变化 |
| | | if len(current_limit_up_block_codes_dict[block]) == 1 and volume_rate < 0.6 and total_left_count <= 5: |
| | | return True, "独苗下单30分钟无后排且成交位离我们很近且量小于60%" |
| | | # if len(current_limit_up_block_codes_dict[block]) == 1 and volume_rate < 0.6 and total_left_count <= 5: |
| | | # return True, "独苗下单30分钟无后排且成交位离我们很近且量小于60%" |
| | | # if time_sub > 10 * 60: |
| | | # if len(current_limit_up_block_codes_dict[block]) == 1 and volume_rate < 0.7: |
| | | # return True, f"独苗下单10分钟无后排且量({volume_rate})小于70%" |
| | |
| | | limit_up_price = gpcode_manager.get_limit_up_price(code) |
| | | |
| | | if float(limit_up_price) >= constant.MAX_CODE_PRICE: |
| | | HighIncreaseCodeManager().add_code(code) |
| | | # HighIncreaseCodeManager().add_code(code) |
| | | return False, True, f"股价大于{constant.MAX_CODE_PRICE}块" |
| | | |
| | | # place_order_count = cls.__PlaceOrderCountManager.get_place_order_count(code) |
| | |
| | | # return False, True, f"炸板后最低价跌至5%以下" |
| | | |
| | | # 回封的票,下13:15买入需要判断板块是否为独苗 |
| | | if open_limit_up_lowest_price and int(total_data[-1]["val"]["time"].replace(":", "")) > 131500: |
| | | # 获取当前票的涨停原因 |
| | | if code in LimitUpCodesPlateKeyManager.today_total_limit_up_reason_dict: |
| | | limit_up_reason = kpl_data_manager.KPLLimitUpDataRecordManager.get_current_block(code) |
| | | if limit_up_reason and limit_up_reason not in constant.KPL_INVALID_BLOCKS: |
| | | # 判断是否是独苗 |
| | | codes = kpl_data_manager.KPLLimitUpDataRecordManager.get_current_codes_by_block(limit_up_reason) |
| | | if codes: |
| | | codes = copy.deepcopy(codes) |
| | | codes.discard(code) |
| | | if not codes: |
| | | return False, True, f"13:15以后炸板之后下单,({limit_up_reason}) 为独苗" |
| | | # if open_limit_up_lowest_price and int(total_data[-1]["val"]["time"].replace(":", "")) > 131500: |
| | | # # 获取当前票的涨停原因 |
| | | # if code in LimitUpCodesPlateKeyManager.today_total_limit_up_reason_dict: |
| | | # limit_up_reason = kpl_data_manager.KPLLimitUpDataRecordManager.get_current_block(code) |
| | | # if limit_up_reason and limit_up_reason not in constant.KPL_INVALID_BLOCKS: |
| | | # # 判断是否是独苗 |
| | | # codes = kpl_data_manager.KPLLimitUpDataRecordManager.get_current_codes_by_block(limit_up_reason) |
| | | # if codes: |
| | | # codes = copy.deepcopy(codes) |
| | | # codes.discard(code) |
| | | # if not codes: |
| | | # return False, True, f"13:15以后炸板之后下单,({limit_up_reason}) 为独苗" |
| | | # 暂时注释想买单功能 |
| | | # if not cls.__WantBuyCodesManager.is_in_cache(code): |
| | | # if cls.__TradeTargetCodeModeManager.get_mode_cache() == TradeTargetCodeModeManager.MODE_ONLY_BUY_WANT_CODES: |
| | | # return False, True, f"只买想买单中的代码" |
| | | |
| | | if HighIncreaseCodeManager().is_in(code): |
| | | return False, True, f"涨幅过高,5天内3次涨停" |
| | | return cls.can_buy_first(code, limit_up_price) |
| | | # else: |
| | | # return True, False, "在想买名单中" |
| | |
| | | can_buy_result = CodePlateKeyBuyManager.can_buy(code) |
| | | if can_buy_result is None: |
| | | async_log_util.warning(logger_debug, "没有获取到板块缓存,将获取板块") |
| | | yesterday_current_limit_up_records = kpl_data_manager.get_yesterday_current_limit_up_records() |
| | | latest_current_limit_up_records = kpl_data_manager.get_latest_current_limit_up_records() |
| | | CodePlateKeyBuyManager.update_can_buy_blocks(code, |
| | | kpl_data_manager.KPLLimitUpDataRecordManager.latest_origin_datas, |
| | | kpl_data_manager.KPLLimitUpDataRecordManager.total_datas, |
| | | yesterday_current_limit_up_records, |
| | | latest_current_limit_up_records, |
| | | block_info.get_before_blocks_dict(), |
| | | kpl_data_manager.KPLLimitUpDataRecordManager.get_current_reason_codes_dict()) |
| | | can_buy_result = CodePlateKeyBuyManager.can_buy(code) |
| | |
| | | def can_buy_first(cls, code, limit_up_price): |
| | | now_timestamp = int(tool.get_now_time_str().replace(":", "")) |
| | | # 判断板块 |
| | | # (可以买的板块列表, 是否是独苗, 消息简介,可买的强势主线) |
| | | can_buy_result = cls.__get_can_buy_block(code) |
| | | l2_log.debug(code, "获取到的板块信息:{}", can_buy_result) |
| | | if can_buy_result is None: |
| | | return False, True, "尚未获取到板块信息" |
| | | if not can_buy_result[0] and can_buy_result[1]: |
| | | zyltgb = global_util.zyltgb_map.get(code) |
| | | # 独苗 |
| | | if now_timestamp > int("100000"): |
| | | return False, True, f"独苗不下单({can_buy_result[4]}) 10点后不下单" |
| | | elif zyltgb < 10 * 100000000 or zyltgb > 20 * 100000000: |
| | | return False, True, f"独苗不下单({can_buy_result[4]})自由流通市值({zyltgb})不满足条件" |
| | | |
| | | # -------量的约束-------- |
| | | k_format = code_nature_analyse.CodeNatureRecordManager().get_k_format_cache(code) |
| | | if k_format and (k_format[1][0] or k_format[3][0]) and len(k_format) >= 12 and k_format[11]: |
| | | # 破前高/接近前高且30天内有涨停 |
| | | if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < 0.6: |
| | | return False, True, f"股价创新高或者逼近前高且30天内有涨停,当日量比({cls.volume_rate_info[code][0]})小于0.6" |
| | | |
| | | # 前一天炸板之后,今日10:00之前才能下单 |
| | | if k_format and len(k_format) >= 11 and k_format[10]: |
| | | if now_timestamp > int("100000"): |
| | | return False, True, f"上个交易日炸板,当日量10点以后不下单" |
| | | return False, True, f"上个交易日炸板,当日10点以后不下单" |
| | | |
| | | msg_list = [] |
| | | if can_buy_result[3] and now_timestamp <= int("094000"): |
| | | # 强势主线与强势10分钟不看量 |
| | | pass |
| | | msg_list.append("强势10分钟") |
| | | zyltgb = global_util.zyltgb_map.get(code) |
| | | # 独苗 |
| | | if not can_buy_result[0] and can_buy_result[1]: |
| | | msg_list.append("独苗") |
| | | if zyltgb < 10 * 100000000 or zyltgb > 20 * 100000000: |
| | | return False, True, f"强势10分钟,独苗不下单({can_buy_result[4]})自由流通市值({zyltgb})不满足条件" |
| | | if k_format and (k_format[1][0] or k_format[3][0]): |
| | | msg_list.append("股价创新高或者逼近前高") |
| | | # 股价创新高或者逼近前高 |
| | | if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < 0.6: |
| | | return False, True, f"强势10分钟,独苗,股价创新高或者逼近前高,当日量比({cls.volume_rate_info[code][0]})小于0.6" |
| | | else: |
| | | if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < 0.3: |
| | | return False, True, f"强势10分钟,独苗,当日量比({cls.volume_rate_info[code][0]})小于0.3" |
| | | else: |
| | | msg_list.append("非独苗") |
| | | if zyltgb < 10 * 100000000 or zyltgb > 20 * 100000000: |
| | | msg_list.append("不满足自由流通") |
| | | if k_format and (k_format[1][0] or k_format[3][0]): |
| | | # 股价创新高或者逼近前高 |
| | | if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < 0.6: |
| | | return False, True, f"强势10分钟,后排,不满足自由市值,股价创新高或者逼近前高,当日量比({cls.volume_rate_info[code][0]})小于0.6" |
| | | else: |
| | | if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < 0.3: |
| | | return False, True, f"强势10分钟,后排,不满足自由市值,当日量比({cls.volume_rate_info[code][0]})小于0.3" |
| | | else: |
| | | msg_list.append("满足自由流通") |
| | | # 后排,满足自由流通市值需要下单 |
| | | return True, False, can_buy_result[2] |
| | | return True, False, can_buy_result[2] |
| | | else: |
| | | zyltgb = global_util.zyltgb_map.get(code) |
| | | # 非强势10分钟只买主线 |
| | | if not can_buy_result[0] and can_buy_result[1]: |
| | | return False, True, f"非强势10分钟,独苗不下单" |
| | | if can_buy_result[3]: |
| | | # 强势主线 |
| | | if zyltgb < 10 * 100000000 or zyltgb > 20 * 100000000: |
| | | if k_format and (k_format[1][0] or k_format[3][0]): |
| | | # 股价创新高或者逼近前高 |
| | | if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < 0.6: |
| | | return False, True, f"非强势10分钟,强势主线后排,不满足自由市值,股价创新高或者逼近前高,当日量比({cls.volume_rate_info[code][0]})小于0.6" |
| | | else: |
| | | if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < 0.3: |
| | | return False, True, f"非强势10分钟,强势主线后排,不满足自由市值,当日量比({cls.volume_rate_info[code][0]})小于0.3" |
| | | else: |
| | | if k_format and (k_format[1][0] or k_format[3][0]): |
| | | if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < 0.3: |
| | | return False, True, f"非强势10分钟,强势主线后排,满足自由市值,股价创新高或者逼近前高, 当日量比({cls.volume_rate_info[code][0]})小于0.3" |
| | | else: |
| | | # 非强势主线 |
| | | if zyltgb < 10 * 100000000 or zyltgb > 20 * 100000000: |
| | | if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < 0.6: |
| | | return False, True, f"非强势10分钟,非强势主线后排,不满足自由市值, 当日量比({cls.volume_rate_info[code][0]})小于0.6" |
| | | else: |
| | | if k_format and (k_format[1][0] or k_format[3][0]): |
| | | # 股价创新高或者逼近前高 |
| | | if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < 0.6: |
| | | return False, True, f"非强势10分钟,强势主线后排,不满足自由市值,股价创新高或者逼近前高,当日量比({cls.volume_rate_info[code][0]})小于0.6" |
| | | else: |
| | | if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < 0.3: |
| | | return False, True, f"股价创新高或者逼近前高,当日量比({cls.volume_rate_info[code][0]})小于0.3" |
| | | # 如果是早上的强势后排就不需要判断量 |
| | | if can_buy_result[0] and not can_buy_result[1] and now_timestamp <= int("094000"): |
| | | return True, False, f"9:40:00之前非独苗:{can_buy_result[0]}" |
| | | else: |
| | | if code in cls.volume_rate_info: |
| | | if float(limit_up_price) < 3.0 and cls.volume_rate_info[code][0] < 0.6: |
| | | return False, True, f"涨停价小于3块,当日量比({cls.volume_rate_info[code][0]})小于0.6" |
| | | |
| | | if HighIncreaseCodeManager().is_in(code) and cls.volume_rate_info[code][0] < 0.6: |
| | | return False, True, f"股价涨得过高,当日量比({cls.volume_rate_info[code][0]})小于0.6" |
| | | |
| | | if now_timestamp <= int("100000"): |
| | | if cls.volume_rate_info[code][0] < 0.1: |
| | | return False, True, f"当日量比({cls.volume_rate_info[code][0]})小于0.1" |
| | | else: |
| | | if cls.volume_rate_info[code][0] < 0.2: |
| | | return False, True, f"当日量比({cls.volume_rate_info[code][0]})小于0.2" |
| | | |
| | | if code_nature_analyse.LatestMaxVolumeManager().is_latest_max_volume(code): |
| | | # 最近几天有最大量,判断量比是否大于60% |
| | | if cls.volume_rate_info[code][0] < 0.6: |
| | | # HighIncreaseCodeManager().add_code(code) |
| | | return False, True, f"近日出现最大量,当日量比({cls.volume_rate_info[code][0]})小于0.6" |
| | | |
| | | # 独苗不再下单 |
| | | # if can_buy_result[1]: |
| | | # # 独苗 |
| | | # # ------自由流通市值约束------ |
| | | # zyltgb = global_util.zyltgb_map.get(code) |
| | | # if zyltgb: |
| | | # if zyltgb < 10 * 100000000: |
| | | # return False, True, f"独苗,自由流通小于10亿({zyltgb})" |
| | | # if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < 0.6: |
| | | # return False, True, f"独苗:量比({cls.volume_rate_info[code][0]})未达到60%" |
| | | # |
| | | # # 判断是否近2天是否为10天内最大量 |
| | | # if k_format and len(k_format) >= 10 and k_format[9]: |
| | | # # 是独苗 |
| | | # if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < 0.3: |
| | | # return False, True, f"近2天有10日内最高量,量比({cls.volume_rate_info[code][0]})未达到30%" |
| | | # if now_timestamp < int("100000") or int("130000") <= now_timestamp < int("133000"): |
| | | # # 独苗必须9:30-10:00和13:00-13:30时间段内买 |
| | | # return True, False, f"独苗:{can_buy_result[2]}" |
| | | # else: |
| | | # return False, True, f"独苗:当前时间不能买" |
| | | # else: |
| | | if can_buy_result[0]: |
| | | return False, True, f"非强势10分钟,强势主线后排,不满足自由市值,当日量比({cls.volume_rate_info[code][0]})小于0.3" |
| | | return True, False, can_buy_result[2] |
| | | |
| | | if can_buy_result[1]: |
| | | return True, False, "买独苗" |
| | | |
| | | return False, True, can_buy_result[2] |
| | | |
| | | @classmethod |
| | | def __cancel_buy(cls, code): |
| | |
| | | buy_progress_index) |
| | | # ---------------------------------判断板块是否跟上来了------------------------------- |
| | | try: |
| | | order_begin_pos = l2_data_manager.TradePointManager().get_buy_compute_start_data_cache(code) |
| | | volume_rate = 0 |
| | | volume_info = L2TradeDataProcessor.volume_rate_info.get(code) |
| | | if volume_info: |
| | | volume_rate = volume_info[0] |
| | | need_cancel, msg = UCancelBigNumComputer().need_cancel(code, buy_progress_index, order_begin_pos, |
| | | kpl_data_manager.KPLLimitUpDataRecordManager.get_current_reason_codes_dict(), |
| | | volume_rate) |
| | | if need_cancel: |
| | | L2TradeDataProcessor.cancel_buy(code, msg) |
| | | pass |
| | | # order_begin_pos = l2_data_manager.TradePointManager().get_buy_compute_start_data_cache(code) |
| | | # volume_rate = 0 |
| | | # volume_info = L2TradeDataProcessor.volume_rate_info.get(code) |
| | | # if volume_info: |
| | | # volume_rate = volume_info[0] |
| | | # need_cancel, msg = UCancelBigNumComputer().need_cancel(code, buy_progress_index, order_begin_pos, |
| | | # kpl_data_manager.KPLLimitUpDataRecordManager.get_current_reason_codes_dict(), |
| | | # volume_rate) |
| | | # if need_cancel: |
| | | # L2TradeDataProcessor.cancel_buy(code, msg) |
| | | except Exception as e: |
| | | logger_debug.exception(e) |
| | | else: |
| | |
| | | |
| | | # @unittest.skip("跳过此单元测试") |
| | | def test_block(self): |
| | | # code = "600713" |
| | | code = "603825" |
| | | # KPLCodeJXBlockManager().load_jx_blocks(code, 23.52,23.62, |
| | | # kpl_data_manager.KPLLimitUpDataRecordManager.get_current_reasons()) |
| | | # |
| | | # block_info.init_code(code) |
| | | # kpl_data_manager.KPLLimitUpDataRecordManager.load_total_datas() |
| | | # yesterday_current_limit_up_records = kpl_data_manager.get_yesterday_current_limit_up_records() |
| | | block_info.init_code(code) |
| | | kpl_data_manager.KPLLimitUpDataRecordManager.load_total_datas() |
| | | latest_current_limit_up_records = kpl_data_manager.get_latest_current_limit_up_records() |
| | | kpl_data_manager.KPLLimitUpDataRecordManager.save_record(tool.get_now_date_str(), |
| | | kpl_data_manager.KPLDataManager.get_data( |
| | | kpl_util.KPLDataType.LIMIT_UP)) |
| | | |
| | | # CodePlateKeyBuyManager.update_can_buy_blocks(code, |
| | | # kpl_data_manager.KPLLimitUpDataRecordManager.latest_origin_datas, |
| | | # kpl_data_manager.KPLLimitUpDataRecordManager.total_datas, |
| | | # yesterday_current_limit_up_records, |
| | | # block_info.get_before_blocks_dict(), |
| | | # kpl_data_manager.KPLLimitUpDataRecordManager.get_current_reason_codes_dict()) |
| | | CodePlateKeyBuyManager.update_can_buy_blocks(code, |
| | | kpl_data_manager.KPLLimitUpDataRecordManager.latest_origin_datas, |
| | | kpl_data_manager.KPLLimitUpDataRecordManager.total_datas, |
| | | latest_current_limit_up_records, |
| | | block_info.get_before_blocks_dict(), |
| | | kpl_data_manager.KPLLimitUpDataRecordManager.get_current_reason_codes_dict()) |
| | | # l2.l2_data_manager_new.L2TradeDataProcessor.can_buy_first(code, None) |
| | | |
| | | @unittest.skip("跳过此单元测试") |
| | |
| | | # high_level_general_code_blocks 高位泛化板块 |
| | | @classmethod |
| | | def update_can_buy_blocks(cls, code, current_limit_up_datas, limit_up_record_datas, |
| | | yesterday_current_limit_up_records, |
| | | latest_current_limit_up_records, |
| | | before_blocks_dict, current_limit_up_block_codes_dict): |
| | | yesterday_current_limit_up_codes = set() |
| | | yesterday_current_limit_up_records_dict = {} |
| | | yesterday_current_limit_up_records = latest_current_limit_up_records[0][1] |
| | | if yesterday_current_limit_up_records: |
| | | for r in yesterday_current_limit_up_records: |
| | | yesterday_current_limit_up_codes.add(r[0]) |
| | |
| | | if r[4].replace("连板", "").isdigit(): |
| | | count = int(r[4].replace("连板", "")) |
| | | if count >= 3: |
| | | latest_datas = latest_current_limit_up_records[:count-1] |
| | | # 是高位板 |
| | | # 当日精选 |
| | | blocks = set(r[6].split("、")) |
| | | if r[0] in yesterday_current_limit_up_records_dict: |
| | | # 昨日涨停原因 |
| | | blocks.add(yesterday_current_limit_up_records_dict.get(r[0])[5]) |
| | | for d in latest_datas: |
| | | for dd in d[1]: |
| | | if dd[0] == r[0]: |
| | | blocks.add(dd[5]) |
| | | break |
| | | f_blocks = [] |
| | | for b in blocks: |
| | | if b: |
| | |
| | | mysqldb = mysql_data.Mysqldb() |
| | | return mysqldb.select_all(f"select * from kpl_limit_up_record where _code='{code}' and _day='{day}'") |
| | | |
| | | |
| | | @staticmethod |
| | | def list_by_block(block_name, day): |
| | | mysqldb = mysql_data.Mysqldb() |
| | |
| | | cls.__file_content_cache[key] = fdata |
| | | return fdata |
| | | |
| | | |
| | | |
| | | @classmethod |
| | | # 获取最近几天的数据,根据日期倒序返回 |
| | | def get_latest_from_file(cls, type, count): |
| | |
| | | datas = __limit_up_list_records_dict[day] |
| | | else: |
| | | logger_debug.info("从文件中获取前几天的实时涨停数据") |
| | | datas = KPLDataManager().get_latest_from_file(KPLDataType.LIMIT_UP, 10) |
| | | datas = KPLDataManager().get_latest_from_file(KPLDataType.LIMIT_UP, count + 2) |
| | | if datas: |
| | | # 保存数据 |
| | | __limit_up_list_records_dict[day] = datas |
| | |
| | | def get_yesterday_current_limit_up_records(): |
| | | yesterday_limit_up_data_records = get_current_limit_up_data_records(1)[0][1] |
| | | return yesterday_limit_up_data_records |
| | | |
| | | |
| | | # 获取最近几天涨停原因 |
| | | __latest_current_limit_up_records = {} |
| | | |
| | | |
| | | def get_latest_current_limit_up_records(): |
| | | day = tool.get_now_date_str() |
| | | if day not in __latest_current_limit_up_records: |
| | | fdatas = get_current_limit_up_data_records(15) |
| | | __latest_current_limit_up_records[day] = fdatas |
| | | return __latest_current_limit_up_records.get(day) |
| | | |
| | | |
| | | # 运行拉取任务 |
| | |
| | | |
| | | |
| | | if __name__ == "__main__": |
| | | run_pull_task() |
| | | print(get_latest_current_limit_up_records()) |
| | | print(get_latest_current_limit_up_records()) |
| | | input() |
| | |
| | | cls.__KPLCodeJXBlockManager.load_jx_blocks(code, buy_1_price, limit_up_price, |
| | | kpl_data_manager.KPLLimitUpDataRecordManager.get_current_reasons()) |
| | | # 更新板块信息 |
| | | yesterday_current_limit_up_records = kpl_data_manager.get_yesterday_current_limit_up_records() |
| | | latest_current_limit_up_records = kpl_data_manager.get_latest_current_limit_up_records() |
| | | CodePlateKeyBuyManager.update_can_buy_blocks(code, |
| | | kpl_data_manager.KPLLimitUpDataRecordManager.latest_origin_datas, |
| | | kpl_data_manager.KPLLimitUpDataRecordManager.total_datas, |
| | | yesterday_current_limit_up_records, |
| | | latest_current_limit_up_records, |
| | | block_info.get_before_blocks_dict(), |
| | | kpl_data_manager.KPLLimitUpDataRecordManager.get_current_reason_codes_dict()) |
| | | |
| | |
| | | |
| | | |
| | | # 解析最大量 |
| | | def parse_max_volume(datas, is_new_top=False): |
| | | def parse_max_volume(datas, is_new_or_near_top=False): |
| | | max_volume = 0 |
| | | |
| | | max_volume_date = None |
| | | if is_new_top: |
| | | # 判断30天内是否有涨停 |
| | | if is_new_or_near_top: |
| | | # 30天内是否有涨停 |
| | | latest_limit_up_index = None |
| | | for i in range(30): |
| | | if i >= len(datas): |
| | | break |
| | | item = datas[i] |
| | | limit_up_price = float(gpcode_manager.get_limit_up_price_by_preprice(item["pre_close"])) |
| | | if abs(limit_up_price - item["high"]) < 0.001: |
| | | latest_limit_up_index = i |
| | | break |
| | | if latest_limit_up_index is not None: |
| | | # 突破前高或者接近前高,30个交易日内有涨停 |
| | | if latest_limit_up_index > 0 and datas[latest_limit_up_index - 1]["volume"] > datas[latest_limit_up_index]["volume"]: |
| | | return datas[latest_limit_up_index - 1]["volume"], datas[latest_limit_up_index - 1]["volume"], \ |
| | | datas[latest_limit_up_index - 1]['bob'].strftime("%Y-%m-%d") |
| | | else: |
| | | return datas[latest_limit_up_index]["volume"], datas[latest_limit_up_index]["volume"], \ |
| | | datas[latest_limit_up_index]['bob'].strftime("%Y-%m-%d") |
| | | |
| | | if is_new_or_near_top: |
| | | # 如果是突破前高就取最大量 |
| | | for item in datas: |
| | | if max_volume < item["volume"]: |
| | |
| | | max_volume_date = item["bob"] |
| | | return max_volume, max_volume, max_volume_date.strftime("%Y-%m-%d") |
| | | else: |
| | | |
| | | date = None |
| | | target_volume = None |
| | | for i in range(len(datas)): |