| | |
| | | if time_str.startswith("9"): |
| | | time_str = f"0{time_str}" |
| | | time_ = f"{time_str[0:2]}:{time_str[2:4]}:{time_str[4:6]}" |
| | | price = item["Price"] |
| | | price = item[1] |
| | | if price <= 0: |
| | | # 深证的买撤无价格数据,需要去查找价格数据,暂时设置为涨停价 |
| | | price = limit_up_price |
| | | |
| | | limitPrice = 1 if abs(limit_up_price - price) < 0.001 else 0 |
| | | operateType = 0 |
| | | if item[''] == 'D': |
| | | if item[9] == 'D': |
| | | if item[3] == '1': |
| | | # 买撤 |
| | | operateType = 1 |
| | |
| | | |
| | | def get_format_l2_datas(code, origin_datas, limit_up_price, start_index): |
| | | # 先转变数据格式 |
| | | datas = [__convert_order(x, limit_up_price) for x in origin_datas] |
| | | fdatas = __format_l2_data(datas, code, limit_up_price) |
| | | datas = [__convert_order(x, float(limit_up_price)) for x in origin_datas] |
| | | fdatas = __format_l2_data(datas, code, float(limit_up_price)) |
| | | for i in range(0, len(fdatas)): |
| | | fdatas[i]["index"] = start_index + i |
| | | fdatas[i]["index"]= start_index + i |
| | |
| | | rotation="00:00", compression="zip", enqueue=True) |
| | | |
| | | def get_path(self, dir_name, log_name): |
| | | return "/home/logs_/huaxin/{}/{}".format(dir_name, log_name) + ".{time:YYYY-MM-DD}.log" |
| | | return "/home/logs/huaxin/{}/{}".format(dir_name, log_name) + ".{time:YYYY-MM-DD}.log" |
| | | |
| | | def get_logger(self, log_name): |
| | | return logger.bind(name=log_name) |
| | |
| | | __start_time = round(time.time() * 1000) |
| | | l2_data_manager_new.L2TradeDataProcessor().process_add_datas(code, datas, 0, __start_time) |
| | | except Exception as e: |
| | | logging.exception(e) |
| | | logger_l2_error.exception(e) |
| | | finally: |
| | | l2_data_log.l2_time(code, round(time.time() * 1000) - origin_start_time, |
| | |
| | | |
| | | |
| | | if __name__ == "__main__": |
| | | code = "002251" |
| | | datas =[['002251', 0.0, 138300, '1', '2', 112555120, 2011, 18281251, 18233797, 'D']] |
| | | origin_start_time = 0 |
| | | try: |
| | | # 转换数据格式 |
| | | _start_index = 0 |
| | | if local_today_datas.get(code) is not None and len( |
| | | local_today_datas[code]) > 0: |
| | | _start_index = local_today_datas[code][-1]["index"] + 1 |
| | | datas = l2_huaxin_util.get_format_l2_datas(code, datas, |
| | | gpcode_manager.get_limit_up_price(code), _start_index) |
| | | __start_time = round(time.time() * 1000) |
| | | # l2_data_manager_new.L2TradeDataProcessor().process_add_datas(code, datas, 0, __start_time) |
| | | except Exception as e: |
| | | logging.exception(e) |
| | | logger_l2_error.exception(e) |
| | | finally: |
| | | l2_data_log.l2_time(code, round(time.time() * 1000) - origin_start_time, |
| | | "l2数据处理总耗时", |
| | | True) |
| | | # l2.l2_data_util.save_l2_data(code, None, datas) |
| | | |
| | | run() |
| | | # ClientSocketManager.add_client(ClientSocketManager.CLIENT_TYPE_TRADE, "1", None) |
| | | # ClientSocketManager.add_client(ClientSocketManager.CLIENT_TYPE_TRADE, "2", None) |
| | | # ClientSocketManager.add_client(ClientSocketManager.CLIENT_TYPE_TRADE, "3", None) |