
# 市场数据监听控制事件
EventMarketActiveSwitch = "market_active_switch" # 市场数据状态变更
MarketDataUpdate = "market_data_update" # 市价更新
MarketOrderCreated = "market_order_created" # 市价单创建
MarketOrderTraded = "market_order_traded" # 市价单成交
# Pring Log
EventPrintLog = "print_log" # 打印日志

# 订阅与发布事件示例
# event_bus.subscribe('my_event', handle_event)
# event_bus.publish('my_event', {'key': 'value'})

class EventBus:
    def __init__(self):
        self.listeners = {} # 管理各种event的订阅情况

    def subscribe(self, event_type, listener):
        if event_type not in self.listeners:
            self.listeners[event_type] = []
        self.listeners[event_type].append(listener)

    def publish(self, event_type, data):
        if event_type in self.listeners:
            for listener in self.listeners[event_type]:
                listener(data)

# 创建事件总线实例
event_bus = EventBus()