| | |
| | | # blocking是否阻塞进程 |
| | | def trade_order(direction, code, volume, price, price_type=2, blocking=True): |
| | | print("客户端", ClientSocketManager.socket_client_dict) |
| | | request_id, client = __request(ClientSocketManager.CLIENT_TYPE_TRADE, |
| | | request_id, client = __request( |
| | | ClientSocketManager.CLIENT_TYPE_TRADE if direction == 1 else ClientSocketManager.CLIENT_TYPE_TRADE_SELL, |
| | | {"type": API_TYPE_TRADE, "trade_type": 1, |
| | | "direction": direction, |
| | | "code": code, |
| | |
| | | |
| | | # 保存正在运行的数据 |
| | | def sell_rule(operate, data={}, blocking=True): |
| | | request_id, client = __request(ClientSocketManager.CLIENT_TYPE_COMMON, |
| | | request_id, client = __request(ClientSocketManager.CLIENT_TYPE_TRADE_SELL, |
| | | {"type": API_TYPE_SELL_RULE, "operate": operate, "data": data, |
| | | "sinfo": f"cb_{API_TYPE_SELL_RULE}_{round(time.time() * 1000)}"}) |
| | | return __read_response(client, request_id, blocking, timeout=10) |
| | |
| | | |
| | | # 获取代码持仓信息 |
| | | def get_code_position_info(code, blocking=True): |
| | | request_id, client = __request(ClientSocketManager.CLIENT_TYPE_TRADE, |
| | | request_id, client = __request(ClientSocketManager.CLIENT_TYPE_TRADE_SELL, |
| | | {"type": API_TYPE_GET_CODE_POSITION_INFO, "code": code, |
| | | "sinfo": f"cb_{API_TYPE_GET_CODE_POSITION_INFO}_{round(time.time() * 1000)}"}) |
| | | return __read_response(client, request_id, blocking) |