def subscribe(id_or_symbols):
    """
    订阅合约行情。该操作会导致合约池内合约的增加，从而影响handle_bar中处理bar数据的数量。

    需要注意，用户在初次编写策略时候需要首先订阅合约行情，否则handle_bar不会被触发。

    :param id_or_symbols: 标的物
    :type id_or_symbols: :class:`~Instrument` object | `str` | List[:class:`~Instrument`] | List[`str`]
    """
    current_universe = Environment.get_instance().get_universe()
    if isinstance(id_or_symbols, six.string_types):
        order_book_id = instruments(id_or_symbols).order_book_id
        current_universe.add(order_book_id)
    elif isinstance(id_or_symbols, Instrument):
        current_universe.add(id_or_symbols.order_book_id)
    elif isinstance(id_or_symbols, Iterable):
        for item in id_or_symbols:
            current_universe.add(assure_order_book_id(item))
    else:
        raise RQInvalidArgument(_(u"unsupported order_book_id type"))
    verify_that("id_or_symbols")._are_valid_instruments("subscribe", id_or_symbols)
    Environment.get_instance().update_universe(current_universe)
def subscribe ( id_or_symbols ) : current_universe = Environment . get_instance ( ) . get_universe ( ) if isinstance ( id_or_symbols , six . string_types ) : order_book_id = instruments ( id_or_symbols ) . order_book_id current_universe . add ( order_book_id ) elif isinstance ( id_or_symbols , Instrument ) : current_universe . add ( id_or_symbols . order_book_id ) elif isinstance ( id_or_symbols , Iterable ) : for item in id_or_symbols : current_universe . add ( assure_order_book_id ( item ) ) else : raise RQInvalidArgument ( _ ( u"unsupported order_book_id type" ) ) verify_that ( "id_or_symbols" ) . _are_valid_instruments ( "subscribe" , id_or_symbols ) Environment . get_instance ( ) . update_universe ( current_universe )
订阅合约行情。该操作会导致合约池内合约的增加，从而影响handle_bar中处理bar数据的数量。

    需要注意，用户在初次编写策略时候需要首先订阅合约行情，否则handle_bar不会被触发。

    :param id_or_symbols: 标的物
    :type id_or_symbols: :class:`~Instrument` object | `str` | List[:class:`~Instrument`] | List[`str`]