| | |
| | | str_list.sort() |
| | | str_list.append("%Yeshi2014@#.") |
| | | root_data["sign"] = crypt.md5_encrypt("&".join(str_list)) |
| | | print("请求前对象", root_data) |
| | | # print("请求前对象", root_data) |
| | | # 添加请求头 |
| | | client[1].sendall(socket_util.load_header(json.dumps(root_data).encode(encoding='utf-8'))) |
| | | result = client[1].recv(1024) |
| | | print("请求发送成功", result.decode(encoding='utf-8')) |
| | | # print("请求发送成功", result.decode(encoding='utf-8')) |
| | | except BrokenPipeError as e: |
| | | ClientSocketManager.del_client(client[0]) |
| | | raise e |
| | |
| | | # price:价格(如果是卖时不传价格就按照5挡价卖) |
| | | # blocking是否阻塞进程 |
| | | def order(direction, code, volume, price, price_type=2, blocking=True): |
| | | print("客户端", ClientSocketManager.socket_client_dict) |
| | | # print("客户端", ClientSocketManager.socket_client_dict) |
| | | request_id, client = __request(ClientSocketManager.CLIENT_TYPE_TRADE, |
| | | {"type": ClientSocketManager.CLIENT_TYPE_TRADE, "trade_type": 1, |
| | | "direction": direction, |
| | | "code": code, |
| | | "volume": volume, |
| | | "price_type": price_type, |
| | | "price": price, "sinfo": f"b_{code}_{round(time.time() * 1000)}"}) |
| | | "price": price, "sinfo": f"ba_{code}_{round(time.time() * 1000)}"}) |
| | | |
| | | return __read_response(client, request_id, blocking) |
| | | |