
# 市场数据监听控制事件
MarketDataUpdate = "market_data_update"
ActionEnableMarketData = "enable_market_data"
ActionDisableMarketData = "disable_market_data"
MarketDataEnabled = "market_data_enabled"
MarketDataDisabled = "market_data_disabled"
MarketOrderCreated = "market_order_created"
MarketOrderTraded = "market_order_traded"
# Pring Log
EventPrintLog = "print_log"

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.subscribe('my_event', handle_event)

# # 发布事件
# event_bus.publish('my_event', {'key': 'value'})

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