| | |
| | | from log_module.log import logger_system, logger_debug, logger_request_api |
| | | from strategy import strategy_manager |
| | | from strategy.env_info import RealTimeEnvInfo |
| | | from trade import trade_record_log_util |
| | | |
| | | from utils import tool |
| | | from log_module import async_log_util |
| | |
| | | url = urlparse.urlparse(path) |
| | | async_log_util.info(logger_request_api, f"开始请求{tool.get_thread_id()}-{url}") |
| | | response_data = "" |
| | | if url.path == "/get_kpl_data": |
| | | response_data = json.dumps({"code": 0, "data": {}}) |
| | | async_log_util.info(logger_request_api, f"结束请求{tool.get_thread_id()}-{url}") |
| | | if url.path == "/get_place_order_records": |
| | | # 获取下单记录 |
| | | datas = trade_record_log_util.get_trade_records(trade_record_log_util.TYPE_PLACE_ORDER) |
| | | response_data = json.dumps({"code": 0, "data": datas}) |
| | | # async_log_util.info(logger_request_api, f"结束请求{tool.get_thread_id()}-{url}") |
| | | self.send_response(200) |
| | | # 发给请求客户端的响应数据 |
| | | self.send_header('Content-type', 'application/json') |
| | |
| | | url = urlparse.urlparse(path) |
| | | result_str = "" |
| | | try: |
| | | params = self.__parse_request() |
| | | if type(params) == str: |
| | | params = json.loads(params) |
| | | if url.path == "/upload_big_order_datas": |
| | | # 接收成交大单数据 |
| | | params = self.__parse_request() |
| | | strategy_manager.low_suction_strtegy.add_big_orders(params) |
| | | # logger_debug.info("upload_big_order_datas:{}", f"{params}") |
| | | big_order_datas = params |
| | | strategy_manager.low_suction_strtegy.add_big_orders(big_order_datas) |
| | | RealTimeEnvInfo().big_order_update_time = tool.get_now_time_str() |
| | | print("获取到大单", os.getpid()) |
| | | result_str = json.dumps({"code": 0}) |
| | | elif url.path == "/upload_block_in_datas": |
| | | # 接收板块流入数据 |
| | | params = self.__parse_request() |
| | | strategy_manager.low_suction_strtegy.add_block_in(params) |
| | | # logger_debug.info("upload_block_in_datas:{}", f"{params}") |
| | | RealTimeEnvInfo().block_in = (tool.get_now_time_str(), len(params)) |
| | | block_in_datas = params |
| | | strategy_manager.low_suction_strtegy.add_block_in(block_in_datas) |
| | | RealTimeEnvInfo().block_in = (tool.get_now_time_str(), len(block_in_datas)) |
| | | result_str = json.dumps({"code": 0}) |
| | | elif url.path == "/upload_limit_up_list": |
| | | params = self.__parse_request() |
| | | strategy_manager.low_suction_strtegy.add_limit_up_list(params) |
| | | # logger_debug.info("upload_limit_up_list:{}", f"{params}") |
| | | RealTimeEnvInfo().kpl_current_limit_up = (tool.get_now_time_str(), len(params)) |
| | | limit_up_list = params |
| | | strategy_manager.low_suction_strtegy.add_limit_up_list(limit_up_list) |
| | | RealTimeEnvInfo().kpl_current_limit_up = (tool.get_now_time_str(), len(limit_up_list)) |
| | | result_str = json.dumps({"code": 0}) |
| | | else: |
| | | pass |
| | |
| | | self.wfile.write(data.encode()) |
| | | |
| | | def __parse_request(self): |
| | | params = {} |
| | | datas = self.rfile.read(int(self.headers['content-length'])) |
| | | _str = str(datas, encoding="gbk") |
| | | params = json.loads(_str) |
| | | return params |
| | | return json.loads(_str) |
| | | |
| | | |
| | | class ThreadedHTTPServer(socketserver.ThreadingMixIn, http.server.HTTPServer): |