VeighNa量化社区
你的开源社区量化交易平台
Member
avatar
加入于:
帖子: 2
声望: 0

在价差策略模组的UI模块下面,有一个SpreadDataMonitor Class。其中定义event_type为EVENT_SPREAD_DATA。但是在其中的register_event()函数中却注册监听了EVENT_SPREAD_POS。请问这是一个typo么?还是什么特别用途? 代码如下:
class SpreadDataMonitor(BaseMonitor):
"""
Monitor for spread data.
"""

event_type = EVENT_SPREAD_DATA
data_key = "name"
sorting = False

headers = {
    "name": {"display": "名称", "cell": BaseCell, "update": False},
    "bid_volume": {"display": "买量", "cell": BidCell, "update": True},
    "bid_price": {"display": "买价", "cell": BidCell, "update": True},
    "ask_price": {"display": "卖价", "cell": AskCell, "update": True},
    "ask_volume": {"display": "卖量", "cell": AskCell, "update": True},
    "net_pos": {"display": "净仓", "cell": PnlCell, "update": True},
    "datetime": {"display": "时间", "cell": TimeCell, "update": True},
    "price_formula": {"display": "定价", "cell": BaseCell, "update": False},
    "trading_formula": {"display": "交易", "cell": BaseCell, "update": False},
}

def register_event(self):
    """
    Register event handler into event engine.
    """
    super().register_event()
    self.event_engine.register(EVENT_SPREAD_POS, self.signal.emit)
Member
avatar
加入于:
帖子: 311
声望: 17

register_event()函数,已经注册了对价差盘口(行情)变化的监听。

下面补充的一行self.event_engine.register是为了额外加上对价差持仓(交易)变化的监听。

所以这里是正确的。

Member
avatar
加入于:
帖子: 2
声望: 0

xpeng wrote:

在价差策略模组的UI模块下面,有一个SpreadDataMonitor Class。其中定义event_type为EVENT_SPREAD_DATA。但是在其中的register_event()函数中却注册监听了EVENT_SPREAD_POS。请问这是一个typo么?还是什么特别用途? 代码如下:
class SpreadDataMonitor(BaseMonitor):
"""
Monitor for spread data.
"""

event_type = EVENT_SPREAD_DATA
data_key = "name"
sorting = False

headers = {
    "name": {"display": "名称", "cell": BaseCell, "update": False},
    "bid_volume": {"display": "买量", "cell": BidCell, "update": True},
    "bid_price": {"display": "买价", "cell": BidCell, "update": True},
    "ask_price": {"display": "卖价", "cell": AskCell, "update": True},
    "ask_volume": {"display": "卖量", "cell": AskCell, "update": True},
    "net_pos": {"display": "净仓", "cell": PnlCell, "update": True},
    "datetime": {"display": "时间", "cell": TimeCell, "update": True},
    "price_formula": {"display": "定价", "cell": BaseCell, "update": False},
    "trading_formula": {"display": "交易", "cell": BaseCell, "update": False},
}

def register_event(self):
    """
    Register event handler into event engine.
    """
    super().register_event()
    self.event_engine.register(EVENT_SPREAD_POS, self.signal.emit)

MTF wrote:

register_event()函数,已经注册了对价差盘口(行情)变化的监听。

下面补充的一行self.event_engine.register是为了额外加上对价差持仓(交易)变化的监听。

所以这里是正确的。
对,我也反应过来了,data 和 pos都得监听,UI上才能显示正确

© 2015-2022 上海韦纳软件科技有限公司
备案服务号:沪ICP备18006526号-3

沪公网安备 31011502017034号

【用户协议】
【隐私政策】
【免责条款】