| | |
| | | # 引入瞬时分时行情模块 |
| | | # 引入账户管理模块【进行资金和仓位管理】 |
| | | from strategy import kpl_api, data_cache, check_timer, all_K_line, instant_time_market, account_management, \ |
| | | order_methods, local_data_management, kpl_data_manager, market_sentiment_analysis |
| | | order_methods, local_data_management, kpl_data_manager, market_sentiment_analysis, plate_strength_analysis |
| | | from huaxin_client import l2_market_client, l2_client |
| | | from log_module import async_log_util |
| | | from trade import huaxin_trade_data_update, huaxin_trade_api |
| | | from utils import hx_qc_value_util, huaxin_util |
| | | from utils import hx_qc_value_util, huaxin_util, juejin_api, tool |
| | | |
| | | # 引入行情订阅模块 |
| | | # import subscribe_market |
| | |
| | | # 实时运行定时器线程【定时器函数目前 只管理 15:00 后运行一次 整理当日涨停信息 和 获取所有个股的板块概念】 |
| | | threading.Thread(target=lambda: check_timer.check_time(), daemon=True).start() |
| | | # 获取实时大盘行情情绪综合强度 [分数] 线程 |
| | | threading.Thread(target=lambda: market_sentiment_analysis.get_real_time_market_strong(), daemon=True).start() |
| | | threading.Thread(target=lambda: market_sentiment_analysis.set_plan_position_quantity(), daemon=True).start() |
| | | # 实时检测是否拉取K线线程 |
| | | threading.Thread(target=lambda: all_K_line.check_time_and_data_date(), daemon=True).start() |
| | | # print(f"all_stocks_all_K_line_property_dict== {type(data_cache.all_stocks_all_K_line_property_dict)}") |
| | |
| | | |
| | | # 开启开盘啦 涨停列表 和 全盘个股概念板块 接口线程 |
| | | # 涨停概念线程 |
| | | # threading.Thread(target=kpl_api.kpl_limit_up_process, daemon=True).start() #该行代码为只运行单一线程不回调数据的方式 |
| | | threading.Thread(target=kpl_api.kpl_limit_up_process, args=(kpl_limit_up_process,), daemon=True).start() |
| | | # threading.Thread(target=plate_strength_analysis.kpl_limit_up_process, daemon=True).start() #该行代码为只运行单一线程不回调数据的方式 |
| | | threading.Thread(target=plate_strength_analysis.kpl_limit_up_process, args=(kpl_limit_up_process,), daemon=True).start() |
| | | |
| | | # # 开盘啦的板块强度下的个股强度回调函数 |
| | | def get_market_sift_plate_its_stock_power_process(market_sift_plate_stock_dict): |
| | |
| | | data_cache.market_sift_plate_stock_dict = market_sift_plate_stock_dict |
| | | |
| | | # 板块强度下个股强度线程 |
| | | threading.Thread(target=kpl_api.get_market_sift_plate_its_stock_power_process, |
| | | threading.Thread(target=plate_strength_analysis.get_market_sift_plate_its_stock_power_process, |
| | | args=(get_market_sift_plate_its_stock_power_process,), daemon=True).start() |
| | | |
| | | # 初始化get_current_data方法函数,下单买逻辑才会运行中。。。【核心主线程,随时考虑其启动顺序】>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> |
| | |
| | | |
| | | try: |
| | | # 计算开盘啦昨日拉取的概念数据中为空的股票数量 |
| | | kpl_api.get_have_no_plate_num() |
| | | plate_strength_analysis.get_have_no_plate_num() |
| | | except Exception as e: |
| | | logger_system.exception(e) |
| | | |
| | | # 获取历史涨停信息数据并整理 |
| | | try: |
| | | kpl_api.get_handling_limit_up_info() |
| | | plate_strength_analysis.get_handling_limit_up_info() |
| | | except Exception as e: |
| | | logger_system.exception(e) |
| | | |
| | |
| | | except Exception as e: |
| | | logger_system.exception(e) |
| | | |
| | | # # 获取所有个股的板块概念并写入文件【耗时较长应该放在 核心主线程 和 仓位管理 后面】 |
| | | # kpl_api.get_all_stocks_plate_dict(data_cache.min_stocks) |
| | | |
| | | |
| | | # 持仓代码的L2数据回调 |
| | | class MyPositionsL2DataCallback(L2DataCallBack): |
| | | __last_price_dict = {} |
| | | __pre_close_price_dict = {} # 昨日收盘价 |
| | | |
| | | def OnL2Transaction(self, code, datas): |
| | | """ |
| | | 昨日持仓L2逐笔成交回调 |
| | | :param code: |
| | | :param datas: |
| | | :return: |
| | | """ |
| | | if datas: |
| | | # 获取最近的成交价 |
| | | price, time_str = datas[-1][1], huaxin_util.convert_time(datas[-1][3]) |
| | | # TODO 涨停价变为非涨停价才处理 |
| | | self.__last_price_dict[code] = price |
| | | try: |
| | | # 获取最近的成交价 |
| | | if code not in self.__pre_close_price_dict: |
| | | # 获取收盘价格 |
| | | results = juejin_api.JueJinApi.history_n(tool.get_symbol(code), "1d", 1, 1, "close") |
| | | if results: |
| | | self.__pre_close_price_dict[code] = results[0]["close"] |
| | | if self.__last_price_dict.get(code) == price: |
| | | return |
| | | limit_up_price = tool.get_limit_up_price(code, self.__pre_close_price_dict[code]) |
| | | if code in self.__last_price_dict: |
| | | if abs(limit_up_price - self.__last_price_dict[code]) < 0.0001 < abs(limit_up_price - price): |
| | | # TODO 处理炸板逻辑 |
| | | |
| | | # 炸板 |
| | | logger_debug.info(f"炸板:{code}-({price},{time_str})") |
| | | finally: |
| | | self.__last_price_dict[code] = price |
| | | |
| | | def OnMarketData(self, code, datas): |
| | | # logger_debug.info(f"收到L2Market数据:{datas}") |
| | |
| | | code = d["securityID"] |
| | | buy1 = d["buy"][0] |
| | | |
| | | # 实时L2买1成交量 |
| | | def OnRealTimeBuy1Info(self, code, buy1_info): |
| | | # buy1_info: [买1时间,买1价格, 原始买1量, 实时买1量] |
| | | async_log_util.info(logger_debug, f"OnRealTimeBuy1Info:{code}-{buy1_info}") |