| | |
| | | import json |
| | | |
| | | import constant |
| | | from log_module.log import logger_common |
| | | # 引入掘金API |
| | | # import utils.juejin_api |
| | | # import kpl_api |
| | | from log_module import async_log_util |
| | | from log_module.log import logger_common, logger_k_bars |
| | | from strategy import data_cache |
| | | |
| | | # 引入基础算法模块 |
| | |
| | | # 最高位据昨日较远 且 昨收价距历史最高价差距较小(小于5%,涨幅5%是左右是最容易把低吸骗进去的日内涨幅) 且 整体涨跌幅度较大 【当前二度突破近前高风险】 |
| | | # 【双成药业 2024-11-08 这样的二次近前高,实际数值为1.4646...,为安全起见还是设置为1.5】 |
| | | if (2 < historical_high_price_index < 15 and len(it_K_line) >= 90) and ( |
| | | historical_high_price / round(it_K_line[0]['close'], 2) < 1.5) and ( |
| | | historical_high_price > historical_low_price * 1.8): |
| | | historical_high_price / round(it_K_line[0]['close'], 2) < 1.2) and ( |
| | | historical_high_price > historical_low_price * 2): |
| | | it_K_line[0]['risk_position'] = 'recent_second_break_near_high_position_risk' |
| | | # 昨日就是最高位 且 整体涨跌幅度较大 【当前高位风险】 |
| | | if (historical_high_price_index < 2 and len(it_K_line) >= 90) and ( |
| | |
| | | current_count = 0 |
| | | start = None |
| | | # 确保不会出现除以零的报错 |
| | | if current_yesterday_volume == 0: |
| | | current_yesterday_volume = 1 |
| | | if current_yesterday_volume != 0: |
| | | if round(current_today_volume / current_yesterday_volume, 2) > 1.1: |
| | | # print(f"i=={i} {it_K_line[i]['bob']} {round(current_today_volume/current_yesterday_volume,2)} 【放量】") |
| | | if current_today_growth > 0: |
| | |
| | | else: |
| | | it_K_line[i]['today_volume_shape'] = 'decreases_balance' |
| | | # print(f"i=={i} {it_K_line[i]['bob']} 【缩量平收】") |
| | | else: |
| | | # print(f"i=={i} {it_K_line[i]['bob']} {round(current_today_volume/current_yesterday_volume,2)} 【平量】") |
| | | if current_today_growth > 0: |
| | | it_K_line[i]['today_volume_shape'] = 'remained_up' |
| | | # print(f"i=={i} {it_K_line[i]['bob']} 【平量上涨】") |
| | | elif current_today_growth < 0: |
| | | it_K_line[i]['today_volume_shape'] = 'remained_down' |
| | | # print(f"i=={i} {it_K_line[i]['bob']} 【平量下跌】") |
| | | else: |
| | | it_K_line[i]['today_volume_shape'] = 'remained_balance' |
| | | # print(f"i=={i} {it_K_line[i]['bob']} 【平量平收】") |
| | | # print(f"i=={i} {it_K_line[i]['bob']} {round(current_today_volume/current_yesterday_volume,2)} 【平量】") |
| | | if current_today_growth > 0: |
| | | it_K_line[i]['today_volume_shape'] = 'remained_up' |
| | | # print(f"i=={i} {it_K_line[i]['bob']} 【平量上涨】") |
| | | elif current_today_growth < 0: |
| | | it_K_line[i]['today_volume_shape'] = 'remained_down' |
| | | # print(f"i=={i} {it_K_line[i]['bob']} 【平量下跌】") |
| | | else: |
| | | it_K_line[i]['today_volume_shape'] = 'remained_balance' |
| | | # print(f"i=={i} {it_K_line[i]['bob']} 【平量平收】") |
| | | else: |
| | | logger.info(f"{symbol} 的 昨日成交量 为 0,报错!!") |
| | | |
| | | if current_open - previous_close > 0: |
| | | # print(f"i=={i} {it_K_line[i]['bob']} 成交总量:{today_volume},,,成交总金额:{today_amount}") |
| | |
| | | # 将转换后的JSON字符串写入文件 |
| | | with open(constant.K_BARS_PATH, 'w', encoding='utf-8') as f: |
| | | f.write(json_data) |
| | | async_log_util.info(logger_k_bars, json_data) |
| | | except Exception as error: |
| | | print(f"An error occurred while converting the data to JSON: {error}") |
| | | logger.info(f"标的个股历史k线写完了!{tool.get_now_time_str()}") |
| | |
| | | # # if now_time > data_cache.AFTER_CLOSING_TIME: |
| | | # data_cache.execution = True |
| | | # # 整理当日涨停信息并写入本地管理好本地数据 |
| | | # kpl_api.get_arrange_limit_up_info() |
| | | # plate_strength_analysis.get_arrange_limit_up_info() |
| | | # logger.info(f"整理当日涨停信息 已经运行完成") |
| | | # # # 获取所有个股的板块概念并写入文件【耗时较长应该放在 核心主线程 和 仓位管理 后面】 |
| | | # kpl_api.get_all_stocks_plate_dict(data_cache.min_stocks) |
| | | # plate_strength_analysis.get_all_stocks_plate_dict(data_cache.min_stocks) |
| | | # # logger.info(f"获取所有个股的板块概念 已经运行完成") |
| | | |
| | | # 构造一个循环检测K线子带你中所有个股代码下的日期是不是和某日一致的,如果不一致则返回False |