| | |
| | | import ths_util |
| | | import tool |
| | | from output import code_info_output |
| | | from third_data import hot_block_data_process, block_info |
| | | from third_data import hot_block_data_process, block_info, kpl_api, kpl_util |
| | | from third_data.code_plate_key_manager import TargetCodePlateKeyManager |
| | | from third_data.kpl_data_manager import KPLCodeLimitUpReasonManager, KPLLimitUpDataRecordManager |
| | | from ths import l2_listen_pos_health_manager |
| | | from trade import trade_gui, trade_data_manager, trade_manager, l2_trade_util, deal_big_money_manager, \ |
| | | first_code_score_manager, current_price_process_manager |
| | |
| | | first_tick_datas = [] |
| | | latest_oringin_data = {} |
| | | last_l2_listen_health_time = {} |
| | | __KPLCodeLimitUpReasonManager = KPLCodeLimitUpReasonManager() |
| | | __TargetCodePlateKeyManager = TargetCodePlateKeyManager() |
| | | |
| | | def setup(self): |
| | | super().setup() # 可以不调用父类的setup()方法,父类的setup方法什么都没做 |
| | |
| | | if gpcode_manager.get_limit_up_price(code) is None: |
| | | juejin.re_set_price_pres([code], True) |
| | | |
| | | # 板块关键字准备 |
| | | for code in codes: |
| | | if self.__TargetCodePlateKeyManager.get_history_limit_up_reason(code) is None: |
| | | self.__TargetCodePlateKeyManager.set_history_limit_up_reason(code, |
| | | KPLLimitUpDataRecordManager.get_latest_blocks_set( |
| | | code)) |
| | | if self.__TargetCodePlateKeyManager.get_blocks(code) is None: |
| | | try: |
| | | results = kpl_api.getStockIDPlate(code) |
| | | bs = [r[1] for r in results] |
| | | self.__TargetCodePlateKeyManager.set_blocks(code, bs) |
| | | except Exception as e: |
| | | logging.exception(e) |
| | | pass |
| | | |
| | | # 获取60天最大记录 |
| | | for code in codes: |
| | | need_get_volumn = False |
| | |
| | | # 加入首板涨停 |
| | | gpcode_manager.FirstCodeManager.add_limited_up_record([code]) |
| | | pricePre = gpcode_manager.get_price_pre(code) |
| | | if pricePre is None: |
| | | juejin.re_set_price_pres([code]) |
| | | |
| | | rate = round((float(price) - pricePre) * 100 / pricePre, 1) |
| | | prices.append( |
| | | {"code": code, "time": limit_up_time, "rate": rate, |
| | |
| | | __start_time = time.time() |
| | | final_data = {'code': code, 'data': code_info_output.get_output_html(code)} |
| | | return_str = json.dumps({"code": 0, "data": final_data}) |
| | | print("代码信息获取时间",code,round((time.time()-__start_time)*1000)) |
| | | print("代码信息获取时间", code, round((time.time() - __start_time) * 1000)) |
| | | pass |
| | | # 获取最近2个交易日涨停代码 |
| | | elif type == 72: |
| | |
| | | results = juejin.JueJinManager.get_gp_codes_names([code]) |
| | | if results: |
| | | gpcode_manager.CodesNameManager.add_first_code_name(code, results[code]) |
| | | if "plates" in data["data"]: |
| | | for i in range(len(data["data"]["plates"])): |
| | | self.__KPLCodeLimitUpReasonManager.save_reason(codes[i], data["data"]["plates"][i]) |
| | | |
| | | return_str = json.dumps({"code": 0}) |
| | | elif type == 402: |
| | | data = json.loads(_str) |
| | | codes = data["data"]["codes"] |
| | |
| | | gpcode_manager.WantBuyCodesManager.remove_code(code) |
| | | return_str = json.dumps({"code": 0}) |
| | | elif type == 403: |
| | | plate = None |
| | | include_codes = set() |
| | | if _str: |
| | | data = json.loads(_str) |
| | | plate = data.get("plate") |
| | | if plate: |
| | | code_map = self.__KPLCodeLimitUpReasonManager.list_all() |
| | | for k in code_map: |
| | | if code_map[k] == plate: |
| | | include_codes.add(k) |
| | | |
| | | codes = gpcode_manager.WantBuyCodesManager.list_code() |
| | | datas = [] |
| | | for code in codes: |
| | | if plate and plate != '其他' and code not in include_codes: |
| | | continue |
| | | name = gpcode_manager.get_code_name(code) |
| | | datas.append(f"{name}:{code}") |
| | | |
| | | return_str = json.dumps({"code": 0, "data": datas}) |
| | | elif type == 501: |
| | | data = json.loads(_str) |
| | |
| | | elif type == 502: |
| | | can_buy = trade_manager.TradeStateManager.is_can_buy() |
| | | return_str = json.dumps({"code": 0, "data": {"can_buy": can_buy}}) |
| | | elif type == 601: |
| | | pass |
| | | # 加自选 |
| | | elif type == 602: |
| | | pass |
| | | # 移除自选 |
| | | |
| | | sk.send(return_str.encode()) |
| | | |