def test_symbol_addition(connection): symbols = ['AAPL', 'GOOG'] sub = dxc.dxf_create_subscription(cc=connection, event_type='Trade') dxc.dxf_add_symbols(sc=sub, symbols=symbols) actual_symbols = dxc.dxf_get_symbols(sc=sub) dxc.dxf_close_subscription(sub) assert set(symbols) == set(actual_symbols)
def test_wrong_symbol_types_ignored(connection): symbols = ['AAPL', 'GOOG'] sub = dxc.dxf_create_subscription(cc=connection, event_type='Trade') dxc.dxf_add_symbols(sc=sub, symbols=symbols + [1, 5.0, [], True, {}, ()]) actual_symbols = dxc.dxf_get_symbols(sc=sub) dxc.dxf_close_subscription(sub) assert set(symbols) == set(actual_symbols)
def test_symbol_deletion(connection): symbols = ['AAPL', 'GOOG'] sub = dxc.dxf_create_subscription(cc=connection, event_type='Trade') dxc.dxf_add_symbols(sc=sub, symbols=symbols) dxc.dxf_remove_symbols(sc=sub, symbols=['AAPL']) actual_symbols = dxc.dxf_get_symbols(sc=sub) dxc.dxf_close_subscription(sub) assert ['GOOG'] == actual_symbols
def test_double_event_handler_attachment(connection): handler1 = DefaultHandler() handler2 = DefaultHandler() sub = dxc.dxf_create_subscription(cc=connection, event_type='Trade') sub.set_event_handler(handler1) dxc.dxf_attach_listener(sub) symbols = ['AAPL', 'MSFT'] dxc.dxf_add_symbols(sub, symbols) sub.set_event_handler(handler2) assert sub.get_event_handler() is handler2 assert set(dxc.dxf_get_symbols(sub)) == set(symbols)
def symbols(self): return dxp.dxf_get_symbols(self.__sub)