Administrator
2024-01-10 a3a15c958b4a3e04f6dd90ea52904ff1a48f75a9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
"""
推送消息管理器
"""
import concurrent.futures
 
from utils import middle_api_protocol
 
TYPE_ORDER_ALMOST_DEAL = "order_almost_deal"  # 订单即将成交
 
TYPE_DELEGATE_QUEUE_CHANGE = "delegate_queue_change"  # 委托队列变化
 
thread_pool = concurrent.futures.ThreadPoolExecutor(max_workers=5)
 
 
# 推送订单快成交信息
def push_order_almost_deal(code, code_name):
    __push_msg(TYPE_ORDER_ALMOST_DEAL, data={"code": code, "code_name": code_name})
 
 
# 推送委托队列变化消息
def push_delegate_queue_update():
    __push_msg(TYPE_DELEGATE_QUEUE_CHANGE)
 
 
# 添加消息
def __push_msg(msg_type, data=None):
    def push():
        fdata = {"type": msg_type}
        if data:
            fdata["data"] = data
        middle_api_protocol.request(middle_api_protocol.load_push_msg(fdata))
    thread_pool.submit(push)