def __init__(self, connection, event_type: str, date_time: Union[str, datetime], exact_format: bool = True): """ Parameters ---------- connection: dxfeed.core.DXFeedPy.ConnectionClass Core class written in cython, that handle connection related details on the low level event_type: str One of possible event types: 'Trade', 'Quote', 'Summary', 'Profile', 'Order', 'TimeAndSale', 'Candle', 'TradeETH', 'SpreadOrder', 'Greeks', 'TheoPrice', 'Underlying', 'Series', 'Configuration' or '' date_time: str or datetime.datetime If present timed subscription will be created (conflated stream). For sting date format is following: %Y-%m-%d %H:%M:%S.%f. If None - stream subscription will be created (non-conflated). Default - None. exact_format: bool If False no warning will be thrown in case of incomplete date_time parameter. Default - True """ self.__event_type = event_type if date_time is None: self.__sub = dxp.dxf_create_subscription(cc=connection, event_type=event_type) else: date_time = cu.handle_datetime(date_time, fmt='%Y-%m-%d %H:%M:%S.%f', exact_format=exact_format) timestamp = int(date_time.timestamp() * 1000) self.__sub = dxp.dxf_create_subscription_timed( cc=connection, event_type=event_type, time=timestamp)
def test_subscription_fail_on_incorrect_type(connection): dxc.dxf_create_subscription_timed(cc=connection, event_type='TradeQuote', time=0)
def test_subscription_timed_on_correct_types(connection, sub_type): sub = dxc.dxf_create_subscription_timed(cc=connection, event_type=sub_type, time=0) act_sub_type = dxc.dxf_get_subscription_event_types(sc=sub) dxc.dxf_close_subscription(sub) assert act_sub_type == sub_type