| | |
| | | async_log_util.info(logger_l2_codes_subscript, f"{request_id}从网络加载K线数据:{code}") |
| | | if not volumes_data: |
| | | continue |
| | | volumes = init_data_util.parse_max_volume(code, volumes_data[:90], |
| | | code_nature_analyse.is_new_top(code, |
| | | limit_up_price, |
| | | volumes_data[ |
| | | :90]) or code_nature_analyse.is_near_top( |
| | | code, |
| | | limit_up_price, |
| | | volumes_data[:90])) |
| | | volumes = init_data_util.parse_max_volume_new(code, volumes_data[:60]) |
| | | max_volume_in_5_days = init_data_util.parse_max_volume_in_days(volumes_data, 5) |
| | | |
| | | async_log_util.info(logger_first_code_record, f"{code} 获取到首板60天最大量:{volumes}") |
| | |
| | | "%Y-%m-%d"), refer_index |
| | | |
| | | |
| | | def parse_max_volume_new(code, datas): |
| | | """ |
| | | 计算远高量 |
| | | @param code: |
| | | @param datas: |
| | | @return: [高量,高量,高量日期,高量索引] |
| | | """ |
| | | |
| | | def __is_limited_up(item): |
| | | limit_up_price = float(gpcode_manager.get_limit_up_price_by_preprice(code, item["pre_close"])) |
| | | if abs(limit_up_price - item["high"]) < 0.001: |
| | | return True |
| | | return False |
| | | |
| | | # 取最近60个交易日 |
| | | datas = datas[:60] |
| | | |
| | | # 判断是否涨停过 |
| | | target_index = None |
| | | for i in range(len(datas)): |
| | | data = datas[i] |
| | | if __is_limited_up(data): |
| | | next_data = None |
| | | if i > 0: |
| | | next_data = datas[i - 1] |
| | | # max(涨停这一天, 后一天)的量 |
| | | if next_data and next_data['volume'] > data['volume']: |
| | | target_index = i - 1 |
| | | else: |
| | | target_index = i |
| | | break |
| | | if target_index is None: |
| | | # 60天未涨停,获取60天内的最高量 |
| | | for i in range(len(datas)): |
| | | data = datas[i] |
| | | if target_index is None: |
| | | target_index = i |
| | | if data['volume'] > datas[target_index]['volume']: |
| | | target_index = i |
| | | return datas[target_index]['volume'], datas[target_index]['volume'], datas[target_index]['bob'].strftime( |
| | | "%Y-%m-%d"), target_index |
| | | |
| | | |
| | | def parse_max_volume_in_days(datas, max_day): |
| | | """ |
| | | 解析最近几天最大的量 |