| | |
| | | # 计算监听的总条数 |
| | | total_num = 0 |
| | | max_num = 0 |
| | | thresh_hold_rate, must_buy = LCancelRateManager.get_cancel_rate(code, |
| | | total_data[buy_exec_index]["val"]["time"]) |
| | | # 这是下单位置之后的索引: key为字符串 |
| | | after_place_order_index_dict = self.__get_cancel_l_down_after_place_order_index_dict(code) |
| | | if after_place_order_index_dict is None: |
| | | after_place_order_index_dict = {} |
| | | for wi in watch_indexes: |
| | | if str(wi) in after_place_order_index_dict: |
| | | # 如果加红就需要计算分母 |
| | | if must_buy: |
| | | total_num += total_data[wi]["val"]["num"] * ( |
| | | 10 - after_place_order_index_dict[str(wi)]) // 10 |
| | | continue |
| | | total_num += total_data[wi]["val"]["num"] * total_data[wi]["re"] |
| | | if total_data[wi]["val"]["num"] > max_num: |
| | |
| | | # return True, total_data[-1] |
| | | |
| | | rate = round(canceled_num / total_num, 3) |
| | | thresh_hold_rate, must_buy = LCancelRateManager.get_cancel_rate(code, |
| | | total_data[buy_exec_index]["val"]["time"]) |
| | | |
| | | # 除开最大单的影响权重 |
| | | if not must_buy: |
| | | temp_thresh_hold_rate = round((total_num - max_num) * 0.9 / total_num, 2) |
| | |
| | | return |
| | | if pMarketDataField.SecurityName.find("ST") >= 0: |
| | | return |
| | | close_price = round(pMarketDataField.UpperLimitPrice / out_tool.get_limit_up_rate(pMarketDataField.SecurityID), 2) |
| | | close_price = round(pMarketDataField.UpperLimitPrice / out_tool.get_limit_up_rate(pMarketDataField.SecurityID), |
| | | 2) |
| | | rate = round((pMarketDataField.LastPrice - close_price) * 100 / close_price, 2) |
| | | if out_tool.get_limit_up_rate(pMarketDataField.SecurityID) > 1.1001: |
| | | # 涨停板20%以上的打折 |
| | | rate = rate/2 |
| | | rate = rate / 2 |
| | | |
| | | # print(pMarketDataField.SecurityID, pMarketDataField.SecurityName, rate, pMarketDataField.Volume) |
| | | |
| | |
| | | threshold_rate = constant.L1_MIN_RATE_PRE if int(tool.get_now_time_str().replace(":", "")) < int( |
| | | "094000") else constant.L1_MIN_RATE |
| | | for d in list_: |
| | | |
| | | if d[2] >= threshold_rate: |
| | | # 涨幅小于5%的需要删除 |
| | | flist.append(d) |
| | | |
| | | if d[0] in __position_codes: |
| | | plist.append(d) |
| | | flist.sort(key=lambda x: x[2], reverse=True) |
| | | datas = flist[:1000] |
| | | # 将持仓股加入进去 |
| | | datas.extend(plist) |
| | | print("代码数量:", len(datas)) |
| | | logger_l2_codes_subscript.info("开始#华鑫L1上传代码:数量-{}", len(datas)) |
| | | __upload_codes_info(queue_l1_w_strategy_r, datas) |
| | | if len(datas) > 0: |
| | | logger_l2_codes_subscript.info("开始#华鑫L1上传代码:数量-{}", len(datas)) |
| | | __upload_codes_info(queue_l1_w_strategy_r, datas) |
| | | except Exception as e: |
| | | logging.exception(e) |
| | | finally: |
| | |
| | | # 分析L2数据传输时间 |
| | | def analyze_l2_data_transformation(path_): |
| | | with open(path_, 'r', encoding="utf-8") as f: |
| | | while True: |
| | | line = f.readline() |
| | | lines = f.readlines() |
| | | for line in lines: |
| | | if not line: |
| | | break |
| | | try: |
| | |
| | | date = tool.get_now_date_str() |
| | | try: |
| | | with open("{}/logs/gp/l2/l2_data.{}.log".format(constant.get_path_prefix(), date), mode='r') as f: |
| | | while True: |
| | | data = f.readline() |
| | | lines = f.readlines() |
| | | for data in lines: |
| | | if not data: |
| | | break |
| | | index = data.find(' - ') + 2 |
| | |
| | | try: |
| | | with open(path_, mode='r', |
| | | encoding="utf-8") as f: |
| | | while True: |
| | | line = f.readline() |
| | | lines = f.readlines() |
| | | for line in lines: |
| | | if not line: |
| | | break |
| | | if line.find("code:{}".format(code)) < 0: |
| | |
| | | with open("{}/logs/gp/l2/l2_trade.{}.log".format(constant.get_path_prefix(), date), mode='r', |
| | | encoding="utf-8") as f: |
| | | latest_single = [None, None] |
| | | while True: |
| | | line = f.readline() |
| | | lines = f.readlines() |
| | | for line in lines: |
| | | if not line: |
| | | break |
| | | if line.find("code={}".format(code)) < 0: |
| | |
| | | pos_list = [] |
| | | with open("{}/logs/gp/l2/l2_real_place_order_position.{}.log".format(constant.get_path_prefix(), date), mode='r', |
| | | encoding="utf-8") as f: |
| | | while True: |
| | | line = f.readline() |
| | | lines = f.readlines() |
| | | for line in lines: |
| | | if not line: |
| | | break |
| | | if line.find("{}-".format(code)) < 0: |
| | |
| | | msg_list = [] |
| | | if os.path.exists(path_str): |
| | | with open(path_str, mode='r', encoding="utf-8") as f: |
| | | while True: |
| | | line = f.readline() |
| | | lines = f.readlines() |
| | | for line in lines: |
| | | if not line: |
| | | break |
| | | msg_list.append(line) |
| | |
| | | datas = data["data"] |
| | | cls.__save_l1_current_price(datas) |
| | | # 9:30之前采用非线程 |
| | | if int(tool.get_now_time_str().replace(":","")) < int("093000"): |
| | | if int(tool.get_now_time_str().replace(":", "")) < int("093000"): |
| | | HuaXinL1TargetCodesManager.set_level_1_codes_datas(datas, request_id=request_id) |
| | | else: |
| | | cls.__process_l1_data_thread_pool.submit( |
| | |
| | | except Exception as e: |
| | | logger_debug.exception(e) |
| | | fdata["trade_channel_access"] = 0 |
| | | |
| | | |
| | | # 获取CPU与内存适用情况 |
| | | memory_info = psutil.virtual_memory() |