"""
|
推送消息管理器
|
"""
|
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)
|