| | |
| | | @param pre_close: |
| | | @return: |
| | | """ |
| | | return abs(close - cls.calculate_upper_limit_price(code, |
| | | pre_close)) < 0.01 |
| | | return round(abs(close - cls.calculate_upper_limit_price(code, |
| | | pre_close)), 4) < 0.01 |
| | | |
| | | @classmethod |
| | | def is_limit_up(cls, code, close, pre_close): |
| | | return cls.__is_limit_up(code, close, pre_close) |
| | | |
| | | @classmethod |
| | | def get_third_limit_up_days(cls, k_data, days): |
| | |
| | | return count |
| | | |
| | | @classmethod |
| | | def is_too_high_and_not_relase_volume(cls, k_data): |
| | | def is_too_high_and_not_release_volume(cls, k_data): |
| | | """ |
| | | 长得太高且没放量:30个交易日内,出现过最低价(最高价之前的交易日)到最高价之间的涨幅≥35%的票,且今日距离最高价那日无涨停/无炸板且>=3板且必须有2连板 |
| | | @param k_data: K线数据列表(近150个交易日,不包含当前交易日,时间倒序) |
| | |
| | | # 从最高价日期向前最多看15个交易日 |
| | | before_datas = before_datas[:15] |
| | | min_close_price_data = min(before_datas, key=lambda x: x["close"]) |
| | | if (max_high_price_data['high'] - min_close_price_data['close']) / min_close_price_data['close'] < 0.35: |
| | | rate = (max_high_price_data['high'] - min_close_price_data['close']) / min_close_price_data['close'] |
| | | rate = round(rate, 4) |
| | | if rate < 0.35: |
| | | # 涨幅小于35% |
| | | return False |
| | | before_k_datas = [d for d in k_data if min_close_price_data['bob'] <= d['bob'] <= max_high_price_data['bob']] |
| | | before_k_datas.sort(key=lambda x: x['bob']) |
| | | |
| | | # [最低价-最高价]日期内有3个板且有两连扳 |
| | | |
| | | continue_2_limit_up_date = None |
| | |
| | | |
| | | k_data = [d for d in k_data if d['bob'] > max_high_price_data['bob']] |
| | | # 判断是否涨停过 |
| | | if len([d for d in k_data if cls.__is_limit_up(code, d["high"], d["pre_close"])]) > 0 or len(after_datas) >= 10: |
| | | threshold_day_count = min(int(20*rate + 3), 30) |
| | | if len([d for d in k_data if cls.__is_limit_up(code, d["high"], d["pre_close"])]) > 0 or len(after_datas) >= threshold_day_count: |
| | | # 最高价之后有过涨停或者是最高价后10个交易日 |
| | | return False |
| | | return True, f"高价日期:{max_high_price_data['bob'][:10]},低价日期:{min_close_price_data['bob'][:10]},两连扳日期:{continue_2_limit_up_date}" |
| | | |
| | | @classmethod |
| | | def is_latest_limit_up_with_no_release_volume(cls, k_data, days_count=7): |
| | | """ |
| | | 最近7个交易日内有炸板/首板涨停次日无溢价,且炸板/涨停那日距今日的最高价无法超过炸板那日的最高价 |
| | | @param days_count: |
| | | @param k_data: K线数据列表(近150个交易日,不包含当前交易日,时间倒序) |
| | | @return: 四跌停及以上天数 |
| | | """ |
| | | k_data = k_data[:days_count] |
| | | code = k_data[0]["sec_id"] |
| | | # 找到最近的涨停/炸板 |
| | | latest_limited_up_data = None |
| | | for item in k_data: |
| | | if cls.__is_limit_up(code, item['high'], item['pre_close']): |
| | | latest_limited_up_data = item |
| | | break |
| | | if not latest_limited_up_data: |
| | | # 最近没有涨停/炸板 |
| | | return False |
| | | after_datas = [x for x in k_data if x['bob'] > latest_limited_up_data['bob']] |
| | | if not after_datas: |
| | | # 炸板之后没有数据 |
| | | return False |
| | | after_max_price_data = max(after_datas, key=lambda x: x["high"]) |
| | | if after_max_price_data['high'] > latest_limited_up_data['high']: |
| | | # 有最高价覆盖炸板/涨停那日最高价 |
| | | return False |
| | | return True, f"炸板/涨停日期:{latest_limited_up_data['bob'][:10]}" |
| | | |
| | | |
| | | class K60SLineAnalyzer: |
| | |
| | | block_days[reason].add(date) |
| | | return set([b for b in block_days if len(block_days[b]) == len(days_list)]) |
| | | return set() |
| | | |
| | | |
| | | if __name__ == "__main__": |
| | | item = {'sec_id': '000037', 'open': 9.11, 'high': 9.91, 'low': 9.07, 'close': 9.25, 'volume': 34540400, |
| | | 'pre_close': 9.02, |
| | | 'bob': '2025-06-13 00:00:00', 'amount': 326110864} |
| | | print(KTickLineAnalyzer.is_limit_up(item['sec_id'], item['high'], item['pre_close'])) |