| | |
| | | SERVER_PORT = 10008 |
| | | |
| | | |
| | | def request(data_json): |
| | | def request(data_json, host=SERVER_HOST, port=SERVER_PORT): |
| | | if type(data_json) == set: |
| | | data_json = list(data_json) |
| | | data_bytes = socket_util.load_header(json.dumps(data_json).encode('utf-8')) |
| | | sk = socket_util.create_socket(SERVER_HOST, SERVER_PORT) |
| | | sk = socket_util.create_socket(host, port) |
| | | try: |
| | | sk.sendall(data_bytes) |
| | | result_str, header_str = socket_util.recv_data(sk) |
| | |
| | | def load_push_msg(data): |
| | | fdata = {"type": "push_msg", "data": {"ctype": "push_msg", "data": data}} |
| | | return fdata |
| | | |
| | | |
| | | # ------------------------------仿真交易------------------------------------ |
| | | def load_simulation_trade(type, data): |
| | | fdata = {"type": "simulation_trade", "data": {"ctype": type, "data": data}} |
| | | return fdata |