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 close_subscription(self): """ Method to close subscription. All received data will remain in the object. """ dxp.dxf_close_subscription(sc=self.__sub)
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