admin
2024-01-08 1110af9cc42cbf6a3ebbb953f18585cb37ba5b8c
bug修复/日志添加
9个文件已修改
212 ■■■■ 已修改文件
constant.py 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
data_server.py 42 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
log.py 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
middle_api_server.py 55 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
middle_server.py 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
socket_manager.py 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
third_data/kpl_api.py 22 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
third_data/kpl_data_manager.py 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
utils/hosting_api_util.py 50 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
constant.py
@@ -1,6 +1,6 @@
import platform
TEST = True
TEST = False
IS_A = False
##B类##
@@ -85,6 +85,15 @@
        "passwd": "Yeshi2016@"
    }
if TEST:
    MYSQL_CONFIG = {
        "host": "gz-cdb-r13d0yi9.sql.tencentcdb.com",
        "port": 62929,
        "database": "gp",
        "charset": "utf8",
        "user": "root",
        "passwd": "Yeshi2016@"
    }
# 获取根路径
def get_path_prefix():
data_server.py
@@ -1,24 +1,22 @@
import http
import json
import random
import socketserver
import time
from http.server import BaseHTTPRequestHandler
import dask
from code_attribute import gpcode_manager
from log import logger_request_debug
from log_module import log_analyse, log_export
from output import limit_up_data_filter, output_util, code_info_output
from output import limit_up_data_filter, output_util
from output.limit_up_data_filter import IgnoreCodeManager
from third_data import kpl_util, kpl_data_manager, kpl_api
from third_data.code_plate_key_manager import KPLPlateForbiddenManager
from third_data.kpl_data_manager import KPLLimitUpDataRecordManager, KPLDataManager, KPLCodeLimitUpReasonManager
from third_data.kpl_util import KPLPlatManager, KPLDataType
from trade import trade_manager
from trade.l2_trade_util import BlackListCodeManager
from utils import tool, global_util, kp_client_msg_manager, hosting_api_util
from utils.history_k_data_util import HistoryKDatasUtils
from utils import tool, global_util, hosting_api_util
import urllib.parse as urlparse
from urllib.parse import parse_qs
@@ -45,6 +43,17 @@
        if not total_datas:
            KPLLimitUpDataRecordManager.load_total_datas()
            total_datas = KPLLimitUpDataRecordManager.total_datas
        current_datas_results = hosting_api_util.common_request({"ctype":"get_kpl_limit_up_datas"})
        if type(current_datas_results) == str:
            current_datas_results = json.loads(current_datas_results)
        current_datas = current_datas_results.get("data")  #KPLLimitUpDataRecordManager.latest_origin_datas
        current_block_codes = {}
        for c in current_datas:
            if c[5] not in current_block_codes:
                current_block_codes[c[5]] = set()
            current_block_codes[c[5]].add(c[0])
        # 通过涨停时间排序
        total_datas = list(total_datas)
@@ -64,12 +73,15 @@
                limit_up_reason_want_count_dict[d[2]] = 0
            if d[3] in want_codes:
                limit_up_reason_want_count_dict[d[2]] += 1
        # (板块名称,涨停代码数量,想买单数量,涨停时间)
        # (板块名称,涨停代码数量,炸板数量,想买单数量,涨停时间)
        limit_up_reason_statistic_info = [
            (k, len(limit_up_reason_dict[k]), limit_up_reason_want_count_dict.get(k), limit_up_reason_dict[k][0][5]) for
            (k, len(limit_up_reason_dict[k]),
             len(limit_up_reason_dict[k]) - (len(current_block_codes[k]) if k in current_block_codes else 0),
             limit_up_reason_want_count_dict.get(k), limit_up_reason_dict[k][0][5]) for
            k in
            limit_up_reason_dict]
        limit_up_reason_statistic_info.sort(key=lambda x: int(x[1]))
        limit_up_reason_statistic_info.sort(
            key=lambda x: len(current_block_codes.get(x[0])) if x[0] in current_block_codes else 0)
        limit_up_reason_statistic_info.reverse()
        codes_set = set([d[3] for d in total_datas])
@@ -260,6 +272,9 @@
    def do_GET(self):
        path = self.path
        url = urlparse.urlparse(path)
        thread_id = random.randint(0, 1000000)
        logger_request_debug.info(f"GET 请求开始({thread_id}):{url.path}")
        try:
        if url.path == "/kpl/get_limit_up_list":
            response_data = self.__get_limit_up_list()
            self.send_response(200)
@@ -271,17 +286,26 @@
            ps_dict = dict([(k, v[0]) for k, v in parse_qs(url.query).items()])
            result = hosting_api_util.get_from_data_server(url.path, ps_dict)
            self.__send_response(result)
        finally:
            logger_request_debug.info(f"GET 请求结束({thread_id}):{url.path}")
    def do_POST(self):
        thread_id = random.randint(0, 1000000)
        path = self.path
        url = urlparse.urlparse(path)
        logger_request_debug.info(f"POST 请求开始({thread_id}):{url.path}")
        try:
        if url.path == "/upload_kpl_data":
            # 接受开盘啦数据
            params = self.__parse_request()
            result_str = self.__process_kpl_data(params)
            self.__send_response(result_str)
        finally:
            logger_request_debug.info(f"POST 请求结束({thread_id}):{url.path}")
    def __process_kpl_data(self, data):
        data = json.loads(json.dumps(data).replace("概念", ""))
        type_ = data["type"]
        print("开盘啦type:", type_)
        if type_ == KPLDataType.BIDDING.value:
log.py
@@ -47,6 +47,10 @@
                   filter=lambda record: record["extra"].get("name") == "profile",
                   rotation="00:00", compression="zip", enqueue=True)
        logger.add(self.get_path("request", "request_debug"),
                   filter=lambda record: record["extra"].get("name") == "request_debug",
                   rotation="00:00", compression="zip", enqueue=True)
    def get_path(self, dir_name, log_name):
        path_str = "{}/logs/gp/{}/{}".format(constant.get_path_prefix(), dir_name, log_name) + ".{time:YYYY-MM-DD}.log"
        # print(path_str)
@@ -73,3 +77,5 @@
logger_redis_debug = __mylogger.get_logger("redis_debug")
logger_profile = __mylogger.get_logger("profile")
logger_request_debug = __mylogger.get_logger("request_debug")
middle_api_server.py
@@ -1,6 +1,7 @@
import hashlib
import json
import logging
import random
import socket
import socketserver
import threading
@@ -11,6 +12,7 @@
import trade_manager
from db import mysql_data, redis_manager
from db.redis_manager import RedisUtils
from log import logger_request_debug
from utils import socket_util, hosting_api_util, huaxin_trade_record_manager, huaxin_util, tool, global_data_cache_util
from utils.history_k_data_util import HistoryKDatasUtils, JueJinApi
from utils.huaxin_trade_record_manager import PositionManager
@@ -63,6 +65,9 @@
                    # print("收到数据------", f"{data_str[:20]}......{data_str[-20:]}")
                    data_json = json.loads(data_str)
                    type_ = data_json['type']
                    thread_id = random.randint(0, 1000000)
                    try:
                        logger_request_debug.info(f"middle_api_server 请求开始({thread_id}):{type_}")
                    if type(type_) == int:
                        # 处理数字型TYPE
                        return_str = self.process_num_type(sk, type_, data_str)
@@ -286,8 +291,29 @@
                        result = hosting_api_util.get_l2_listen_active_count()
                        return_str = json.dumps(result)
                    elif type_ == "trade_server_channels":
                        channels = socket_manager.ClientSocketManager.list_client()
                        return_str = json.dumps({"code": 0, "data": channels})
                            trade_channels = socket_manager.ClientSocketManager.list_client(
                                socket_manager.ClientSocketManager.CLIENT_TYPE_TRADE)
                            common_channels = socket_manager.ClientSocketManager.list_client(
                                socket_manager.ClientSocketManager.CLIENT_TYPE_COMMON)
                            data = {}
                            available_count = 0
                            active_count = 0
                            now_time_str = tool.get_now_time_str()
                            for t in trade_channels:
                                if not t[1]:
                                    available_count += 1
                                if tool.trade_time_sub(now_time_str, t[2]) < 60:
                                    active_count += 1
                            data["trade"] = (len(trade_channels), available_count, active_count)
                            available_count = 0
                            active_count = 0
                            for t in common_channels:
                                if not t[1]:
                                    available_count += 1
                                if tool.trade_time_sub(now_time_str, t[2]) < 60:
                                    active_count += 1
                            data["common"] = (len(common_channels), available_count, active_count)
                            return_str = json.dumps({"code": 0, "data": data})
                    elif type_ == "save_running_data":
                        result = hosting_api_util.save_running_data()
                        return_str = json.dumps(result)
@@ -309,7 +335,8 @@
                        params = data_json["data"]
                        result = hosting_api_util.common_request(params)
                        return_str = json.dumps(result)
                    finally:
                        logger_request_debug.info(f"middle_api_server 请求结束({thread_id}):{type}")
                break
                # sk.close()
            except Exception as e:
@@ -420,6 +447,28 @@
                else:
                    return_str = json.dumps({"code": 1, "msg": "不可以取消"})
            elif type == 421:
                # 加入暂不买
                data = json.loads(_str)
                codes = data["data"]["codes"]
                for code in codes:
                    hosting_api_util.add_code_list(code, hosting_api_util.CODE_LIST_MUST_BUY)
                return_str = json.dumps({"code": 0})
            elif type == 422:
                # 移除暂不买
                data = json.loads(_str)
                codes = data["data"]["codes"]
                for code in codes:
                    hosting_api_util.remove_code_list(code, hosting_api_util.CODE_LIST_MUST_BUY)
                return_str = json.dumps({"code": 0})
            elif type == 423:
                # 暂不买列表
                result = hosting_api_util.get_code_list(hosting_api_util.CODE_LIST_MUST_BUY)
                return_str = json.dumps(result)
            elif type == 430:
                # 查询代码属性
                data = json.loads(_str)
middle_server.py
@@ -1,6 +1,4 @@
import datetime
import hashlib
import io
import json
import logging
import queue
@@ -14,7 +12,7 @@
import socket_manager
from db import mysql_data
from db.redis_manager import RedisUtils, RedisManager
from log import logger_debug
from log import logger_debug, logger_request_debug
from utils import socket_util, kpl_api_util, hosting_api_util, kp_client_msg_manager, global_data_cache_util, tool
from utils.juejin_util import JueJinHttpApi
@@ -95,6 +93,9 @@
                            {"code": 100, "msg": f"JSON解析失败"}).encode(
                            encoding='utf-8')))
                        continue
                    thread_id = random.randint(0, 1000000)
                    logger_request_debug.info(f"middle_server 请求开始({thread_id}):{data_json.get('type')}")
                    try:
                    if data_json["type"] == 'register':
                        client_type = data_json["data"]["client_type"]
                        rid = data_json["rid"]
@@ -119,7 +120,6 @@
                            socket_manager.ClientSocketManager.del_client(rid)
                        except Exception as e:
                            logging.exception(e)
                    elif data_json["type"] == "response":
                        # 主动触发的响应
                        try:
@@ -260,7 +260,8 @@
                        result_str = json.dumps({"code": 0, "data": {}})
                        sk.sendall(socket_util.load_header(result_str.encode(encoding='utf-8')))
                        pass
                    finally:
                        logger_request_debug.info(f"middle_server 请求结束({thread_id}):{data_json.get('type')}")
                else:
                    # 断开连接
                    break
socket_manager.py
@@ -6,6 +6,7 @@
class ClientSocketManager:
    # 客户端类型
    CLIENT_TYPE_COMMON = "common"
    CLIENT_TYPE_TRADE = "trade"
    socket_client_dict = {}
@@ -14,7 +15,7 @@
    @classmethod
    def add_client(cls, _type, rid, sk):
        if _type == cls.CLIENT_TYPE_TRADE:
        if _type == cls.CLIENT_TYPE_COMMON or _type == cls.CLIENT_TYPE_TRADE:
            # 交易列表
            if _type not in cls.socket_client_dict:
                cls.socket_client_dict[_type] = []
@@ -26,7 +27,7 @@
    @classmethod
    def acquire_client(cls, _type):
        if _type == cls.CLIENT_TYPE_TRADE:
        if _type == cls.CLIENT_TYPE_COMMON or _type == cls.CLIENT_TYPE_TRADE:
            if _type in cls.socket_client_dict:
                # 根据排序活跃时间排序
                client_list = sorted(cls.socket_client_dict[_type], key=lambda x: cls.active_client_dict.get(x[0]) if x[
@@ -96,7 +97,9 @@
                cls.del_client(k)
    @classmethod
    def list_client(cls):
    def list_client(cls, type_=None):
        _type = type_
        if not _type:
        _type = cls.CLIENT_TYPE_TRADE
        client_list = sorted(cls.socket_client_dict[_type],
                             key=lambda x: cls.active_client_dict.get(x[0]) if x[0] in cls.active_client_dict else 0,
@@ -110,4 +113,3 @@
            fdata.append(
                (client[0], cls.socket_client_lock_dict[client[0]].locked(),active_time))
        return fdata
third_data/kpl_api.py
@@ -27,13 +27,29 @@
    return response.text
def daBanList(pidType):
    data = "Order=1&a=DaBanList&st=100&c=HomeDingPan&PhoneOSNew=1&DeviceID=a38adabd-99ef-3116-8bb9-6d893c846e23" \
           f"&VerSion=5.8.0.2&Index=0&Is_st=1&PidType={pidType}&apiv=w32&Type=4&FilterMotherboard=0&Filter=0&FilterTIB=0" \
def daBanList(pidType, page_size=50, index=0):
    data = f"Order=1&a=DaBanList&st={page_size}&c=HomeDingPan&PhoneOSNew=1&DeviceID=a38adabd-99ef-3116-8bb9-6d893c846e23" \
           f"&VerSion=5.8.0.2&Index={index}&Is_st=1&PidType={pidType}&apiv=w32&Type=4&FilterMotherboard=0&Filter=0&FilterTIB=0" \
           "&FilterGem=0 "
    result = __base_request("https://apphq.longhuvip.com/w1/api/index.php", data=data)
    return result
def getLimitUpInfo():
    list_ = []
    page_size = 50
    MAX_SIZE = 150
    for i in range(0, 10):
        result_str = daBanList(DABAN_TYPE_LIMIT_UP, page_size=page_size, index=len(list_))
        result = json.loads(result_str)
        temp_list = result["list"]
        list_ += temp_list
        if len(temp_list) < page_size:
            result['list'] = list_
            return json.dumps(result)
        elif len(list_) > MAX_SIZE:
            return json.dumps(result)
    return None
# 市场行情-行业
def getMarketIndustryRealRankingInfo(orderJingE_DESC=True):
third_data/kpl_data_manager.py
@@ -7,6 +7,7 @@
import constant
from db.redis_manager import RedisUtils
from log import logger_kpl_limit_up_reason_change
from utils import tool
# 开盘啦历史涨停数据管理
@@ -325,7 +326,7 @@
        while True:
            if tool.is_trade_time():
                try:
                    results = kpl_api.daBanList(kpl_api.DABAN_TYPE_LIMIT_UP)
                    results = kpl_api.getLimitUpInfo()
                    result = json.loads(results)
                    __upload_data("limit_up", result)
                except Exception as e:
@@ -367,7 +368,7 @@
            time.sleep(3)
    threading.Thread(target=get_limit_up, daemon=True).start()
    threading.Thread(target=get_bidding_money, daemon=True).start()
    # threading.Thread(target=get_bidding_money, daemon=True).start()
    threading.Thread(target=get_market_industry, daemon=True).start()
    threading.Thread(target=get_market_jingxuan, daemon=True).start()
utils/hosting_api_util.py
@@ -23,7 +23,7 @@
CODE_LIST_BLACK = "black"
CODE_LIST_WANT = "want"
CODE_LIST_PAUSE_BUY = "pause_buy"
CODE_LIST_MUST_BUY = "must_buy"
# 类型
API_TYPE_TRADE = "trade"  # 交易
API_TYPE_TRADE_STATE = "trade_state"  # 交易状态
@@ -156,7 +156,7 @@
# 设置交易状态
def set_trade_state(state, blocking=True):
    request_id, client = __request(ClientSocketManager.CLIENT_TYPE_TRADE,
    request_id, client = __request(ClientSocketManager.CLIENT_TYPE_COMMON,
                                   {"type": API_TYPE_TRADE_STATE, "operate": OPERRATE_SET,
                                    "state": state,
                                    "sinfo": f"cb_{API_TYPE_TRADE_STATE}_{round(time.time() * 1000)}"})
@@ -165,7 +165,7 @@
# 获取交易状态
def get_trade_state(blocking=True):
    request_id, client = __request(ClientSocketManager.CLIENT_TYPE_TRADE,
    request_id, client = __request(ClientSocketManager.CLIENT_TYPE_COMMON,
                                   {"type": API_TYPE_TRADE_STATE, "operate": OPERRATE_GET,
                                    "sinfo": f"cb_{API_TYPE_TRADE_STATE}_{round(time.time() * 1000)}"})
    return __read_response(client, request_id, blocking)
@@ -173,7 +173,7 @@
# 设置交易模式
def set_trade_mode(mode, blocking=True):
    request_id, client = __request(ClientSocketManager.CLIENT_TYPE_TRADE,
    request_id, client = __request(ClientSocketManager.CLIENT_TYPE_COMMON,
                                   {"type": API_TYPE_TRADE_MODE, "operate": OPERRATE_SET, "mode": mode,
                                    "sinfo": f"cb_{API_TYPE_TRADE_MODE}_{round(time.time() * 1000)}"})
    return __read_response(client, request_id, blocking)
@@ -181,7 +181,7 @@
# 获取交易模式
def get_trade_mode(blocking=True):
    request_id, client = __request(ClientSocketManager.CLIENT_TYPE_TRADE,
    request_id, client = __request(ClientSocketManager.CLIENT_TYPE_COMMON,
                                   {"type": API_TYPE_TRADE_MODE, "operate": OPERRATE_GET,
                                    "sinfo": f"cb_{API_TYPE_TRADE_MODE}_{round(time.time() * 1000)}"})
    return __read_response(client, request_id, blocking)
@@ -189,7 +189,7 @@
# -----代码名单操作----
def add_code_list(code, code_list_type, blocking=True):
    request_id, client = __request(ClientSocketManager.CLIENT_TYPE_TRADE,
    request_id, client = __request(ClientSocketManager.CLIENT_TYPE_COMMON,
                                   {"type": API_TYPE_CODE_LIST, "code_list_type": code_list_type, "code": code,
                                    "operate": OPERRATE_SET,
                                    "sinfo": f"cb_{API_TYPE_CODE_LIST}_{round(time.time() * 1000)}"})
@@ -197,7 +197,7 @@
def remove_code_list(code, code_list_type, blocking=True):
    request_id, client = __request(ClientSocketManager.CLIENT_TYPE_TRADE,
    request_id, client = __request(ClientSocketManager.CLIENT_TYPE_COMMON,
                                   {"type": API_TYPE_CODE_LIST, "code_list_type": code_list_type, "code": code,
                                    "operate": OPERRATE_DELETE,
                                    "sinfo": f"cb_{API_TYPE_CODE_LIST}_{round(time.time() * 1000)}"})
@@ -205,7 +205,7 @@
def get_code_list(code_list_type, blocking=True):
    request_id, client = __request(ClientSocketManager.CLIENT_TYPE_TRADE,
    request_id, client = __request(ClientSocketManager.CLIENT_TYPE_COMMON,
                                   {"type": API_TYPE_CODE_LIST, "code_list_type": code_list_type,
                                    "operate": OPERRATE_GET,
                                    "sinfo": f"cb_{API_TYPE_CODE_LIST}_{round(time.time() * 1000)}"})
@@ -214,7 +214,7 @@
# -----导出L2数据----
def export_l2_data(code, blocking=True):
    request_id, client = __request(ClientSocketManager.CLIENT_TYPE_TRADE,
    request_id, client = __request(ClientSocketManager.CLIENT_TYPE_COMMON,
                                   {"type": API_TYPE_EXPORT_L2, "code": code,
                                    "sinfo": f"cb_{API_TYPE_EXPORT_L2}_{round(time.time() * 1000)}"})
    return __read_response(client, request_id, blocking)
@@ -222,7 +222,7 @@
# -----每日初始化----
def everyday_init(blocking=True):
    request_id, client = __request(ClientSocketManager.CLIENT_TYPE_TRADE,
    request_id, client = __request(ClientSocketManager.CLIENT_TYPE_COMMON,
                                   {"type": API_TYPE_INIT,
                                    "sinfo": f"cb_{API_TYPE_INIT}_{round(time.time() * 1000)}"})
    return __read_response(client, request_id, blocking)
@@ -230,7 +230,7 @@
#  刷新交易数据
def refresh_trade_data(type, blocking=True):
    request_id, client = __request(ClientSocketManager.CLIENT_TYPE_TRADE,
    request_id, client = __request(ClientSocketManager.CLIENT_TYPE_COMMON,
                                   {"type": API_TYPE_REFRESH_TRADE_DATA, "ctype": type,
                                    "sinfo": f"cb_{API_TYPE_REFRESH_TRADE_DATA}_{round(time.time() * 1000)}"})
    return __read_response(client, request_id, blocking)
@@ -238,7 +238,7 @@
#  获取代码属性
def get_code_attribute(code, blocking=True):
    request_id, client = __request(ClientSocketManager.CLIENT_TYPE_TRADE,
    request_id, client = __request(ClientSocketManager.CLIENT_TYPE_COMMON,
                                   {"type": API_TYPE_CODE_ATRRIBUTE, "code": code,
                                    "sinfo": f"cb_{API_TYPE_CODE_ATRRIBUTE}_{round(time.time() * 1000)}"})
    return __read_response(client, request_id, blocking)
@@ -246,7 +246,7 @@
#  获取代码交易状态
def get_code_trade_state(code, blocking=True):
    request_id, client = __request(ClientSocketManager.CLIENT_TYPE_TRADE,
    request_id, client = __request(ClientSocketManager.CLIENT_TYPE_COMMON,
                                   {"type": API_TYPE_CODE_TRADE_STATE, "code": code,
                                    "sinfo": f"{API_TYPE_CODE_TRADE_STATE}_{round(time.time() * 1000)}"})
    return __read_response(client, request_id, blocking)
@@ -254,7 +254,7 @@
# 获取环境信息
def get_env_info(blocking=True):
    request_id, client = __request(ClientSocketManager.CLIENT_TYPE_TRADE,
    request_id, client = __request(ClientSocketManager.CLIENT_TYPE_COMMON,
                                   {"type": API_TYPE_GET_ENV,
                                    "sinfo": f"cb_{API_TYPE_GET_ENV}_{round(time.time() * 1000)}"})
    return __read_response(client, request_id, blocking)
@@ -262,7 +262,7 @@
# 获取环境信息
def sync_l1_subscript_codes(blocking=True):
    request_id, client = __request(ClientSocketManager.CLIENT_TYPE_TRADE,
    request_id, client = __request(ClientSocketManager.CLIENT_TYPE_COMMON,
                                   {"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)
@@ -270,7 +270,7 @@
# 获取系统日志
def get_system_logs(start_index, count, blocking=True):
    request_id, client = __request(ClientSocketManager.CLIENT_TYPE_TRADE,
    request_id, client = __request(ClientSocketManager.CLIENT_TYPE_COMMON,
                                   {"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)
@@ -278,7 +278,7 @@
# 拉取data_server的内容
def get_from_data_server(path, params, blocking=True):
    request_id, client = __request(ClientSocketManager.CLIENT_TYPE_TRADE,
    request_id, client = __request(ClientSocketManager.CLIENT_TYPE_COMMON,
                                   {"type": API_TYPE_GET_FROM_DATA_SERVER, "path": path, "params": params,
                                    "sinfo": f"cb_{API_TYPE_GET_FROM_DATA_SERVER}_{round(time.time() * 1000)}"})
    return __read_response(client, request_id, blocking, timeout=30)
@@ -286,7 +286,7 @@
# 获取代码的交易信息
def get_code_trade_info(code, blocking=True):
    request_id, client = __request(ClientSocketManager.CLIENT_TYPE_TRADE,
    request_id, client = __request(ClientSocketManager.CLIENT_TYPE_COMMON,
                                   {"type": API_TYPE_CODE_TRADE_INFO, "code": code,
                                    "sinfo": f"cb_{API_TYPE_CODE_TRADE_INFO}_{round(time.time() * 1000)}"})
    return __read_response(client, request_id, blocking, timeout=30)
@@ -294,7 +294,7 @@
# L2有效监听数量
def get_l2_listen_active_count(blocking=True):
    request_id, client = __request(ClientSocketManager.CLIENT_TYPE_TRADE,
    request_id, client = __request(ClientSocketManager.CLIENT_TYPE_COMMON,
                                   {"type": API_TYPE_CODE_L2_LISTEN_ACTIVE_COUNT,
                                    "sinfo": f"cb_{API_TYPE_CODE_L2_LISTEN_ACTIVE_COUNT}_{round(time.time() * 1000)}"})
    return __read_response(client, request_id, blocking, timeout=30)
@@ -302,7 +302,7 @@
# 保存正在运行的数据
def save_running_data(blocking=True):
    request_id, client = __request(ClientSocketManager.CLIENT_TYPE_TRADE,
    request_id, client = __request(ClientSocketManager.CLIENT_TYPE_COMMON,
                                   {"type": API_TYPE_SAVE_RUNNING_DATA,
                                    "sinfo": f"cb_{API_TYPE_SAVE_RUNNING_DATA}_{round(time.time() * 1000)}"})
    return __read_response(client, request_id, blocking, timeout=30)
@@ -310,10 +310,10 @@
# 保存正在运行的数据
def sell_rule(operate, data={}, blocking=True):
    request_id, client = __request(ClientSocketManager.CLIENT_TYPE_TRADE,
    request_id, client = __request(ClientSocketManager.CLIENT_TYPE_COMMON,
                                   {"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=30)
    return __read_response(client, request_id, blocking, timeout=10)
# 获取代码持仓信息
@@ -321,7 +321,7 @@
    request_id, client = __request(ClientSocketManager.CLIENT_TYPE_TRADE,
                                   {"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, timeout=30)
    return __read_response(client, request_id, blocking)
def common_request(params={}, blocking=True):
@@ -330,8 +330,8 @@
    if params:
        for k in params:
            data[k] = params[k]
    request_id, client = __request(ClientSocketManager.CLIENT_TYPE_TRADE, data)
    return __read_response(client, request_id, blocking, timeout=30)
    request_id, client = __request(ClientSocketManager.CLIENT_TYPE_COMMON, data)
    return __read_response(client, request_id, blocking, timeout=10)
if __name__ == "__main__":