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

在主引擎中相关方法都没有设置的时候,为什么可以将OmsEngine子类的方法直接设置为主引擎的方法?
def add_function(self) -> None:
"""Add query function to main engine."""
self.main_engine.get_tick = self.get_tick
self.main_engine.get_order = self.get_order
self.main_engine.get_trade = self.get_trade
self.main_engine.get_position = self.get_position
self.main_engine.get_account = self.get_account
self.main_engine.get_contract = self.get_contract
self.main_engine.get_quote = self.get_quote

    self.main_engine.get_all_ticks = self.get_all_ticks
    self.main_engine.get_all_orders = self.get_all_orders
    self.main_engine.get_all_trades = self.get_all_trades
    self.main_engine.get_all_positions = self.get_all_positions
    self.main_engine.get_all_accounts = self.get_all_accounts
    self.main_engine.get_all_contracts = self.get_all_contracts
    self.main_engine.get_all_quotes = self.get_all_quotes
    self.main_engine.get_all_active_orders = self.get_all_active_orders
    self.main_engine.get_all_active_quotes = self.get_all_active_quotes
Member
avatar
加入于:
帖子: 3357
声望: 226

动态添加类方法直接将函数赋值给类就可以了

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

沪公网安备 31011502017034号

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