| | |
| | | API_TYPE_CODE_ATRRIBUTE = "code_attribute" # 代码属性 |
| | | API_TYPE_CODE_TRADE_STATE = "code_trade_state" # 代码交易状态 |
| | | API_TYPE_GET_ENV = "get_env" # 获取环境信息 |
| | | API_TYPE_SYNC_L1_TARGET_CODES = "sync_l1_subscript_codes" # 同步L1需要订阅的代码 |
| | | API_TYPE_SYSTEM_LOG = "system_log" # 系统日志 |
| | | |
| | | # 超时时间2s |
| | | TIMEOUT = 5.0 |
| | | |
| | |
| | | def export_l2_data(code, blocking=True): |
| | | request_id, client = __request(ClientSocketManager.CLIENT_TYPE_TRADE, |
| | | {"type": API_TYPE_EXPORT_L2, "code": code, |
| | | "sinfo": f"cb_{API_TYPE_CODE_LIST}_{round(time.time() * 1000)}"}) |
| | | "sinfo": f"cb_{API_TYPE_EXPORT_L2}_{round(time.time() * 1000)}"}) |
| | | return __read_response(client, request_id, blocking) |
| | | |
| | | |
| | |
| | | def everyday_init(blocking=True): |
| | | request_id, client = __request(ClientSocketManager.CLIENT_TYPE_TRADE, |
| | | {"type": API_TYPE_INIT, |
| | | "sinfo": f"cb_{API_TYPE_CODE_LIST}_{round(time.time() * 1000)}"}) |
| | | "sinfo": f"cb_{API_TYPE_INIT}_{round(time.time() * 1000)}"}) |
| | | return __read_response(client, request_id, blocking) |
| | | |
| | | |
| | |
| | | def refresh_trade_data(type, blocking=True): |
| | | request_id, client = __request(ClientSocketManager.CLIENT_TYPE_TRADE, |
| | | {"type": API_TYPE_REFRESH_TRADE_DATA, "ctype": type, |
| | | "sinfo": f"update_trade_data_{round(time.time() * 1000)}"}) |
| | | "sinfo": f"cb_{API_TYPE_REFRESH_TRADE_DATA}_{round(time.time() * 1000)}"}) |
| | | return __read_response(client, request_id, blocking) |
| | | |
| | | |
| | |
| | | def get_code_attribute(code, blocking=True): |
| | | request_id, client = __request(ClientSocketManager.CLIENT_TYPE_TRADE, |
| | | {"type": API_TYPE_CODE_ATRRIBUTE, "code": code, |
| | | "sinfo": f"update_trade_data_{round(time.time() * 1000)}"}) |
| | | "sinfo": f"cb_{API_TYPE_CODE_ATRRIBUTE}_{round(time.time() * 1000)}"}) |
| | | return __read_response(client, request_id, blocking) |
| | | |
| | | |
| | |
| | | def get_code_trade_state(code, blocking=True): |
| | | request_id, client = __request(ClientSocketManager.CLIENT_TYPE_TRADE, |
| | | {"type": API_TYPE_CODE_TRADE_STATE, "code": code, |
| | | "sinfo": f"update_trade_data_{round(time.time() * 1000)}"}) |
| | | "sinfo": f"{API_TYPE_CODE_TRADE_STATE}_{round(time.time() * 1000)}"}) |
| | | return __read_response(client, request_id, blocking) |
| | | |
| | | |
| | |
| | | def get_env_info(blocking=True): |
| | | request_id, client = __request(ClientSocketManager.CLIENT_TYPE_TRADE, |
| | | {"type": API_TYPE_GET_ENV, |
| | | "sinfo": f"update_trade_data_{round(time.time() * 1000)}"}) |
| | | "sinfo": f"cb_{API_TYPE_GET_ENV}_{round(time.time() * 1000)}"}) |
| | | return __read_response(client, request_id, blocking) |
| | | |
| | | |
| | | # 获取环境信息 |
| | | def sync_l1_subscript_codes(blocking=True): |
| | | request_id, client = __request(ClientSocketManager.CLIENT_TYPE_TRADE, |
| | | {"type": API_TYPE_SYNC_L1_TARGET_CODES, |
| | | "sinfo": f"cb_{API_TYPE_SYNC_L1_TARGET_CODES}_{round(time.time() * 1000)}"}) |
| | | return __read_response(client, request_id, blocking) |
| | | |
| | | |
| | | # 获取系统日志 |
| | | def get_system_logs(start_index, count, blocking=True): |
| | | request_id, client = __request(ClientSocketManager.CLIENT_TYPE_TRADE, |
| | | {"type": API_TYPE_SYSTEM_LOG, "start_index": start_index, "count": count, |
| | | "sinfo": f"cb_{API_TYPE_SYSTEM_LOG}_{round(time.time() * 1000)}"}) |
| | | return __read_response(client, request_id, blocking) |
| | | |
| | | |