예제 #1
0
    def add_symbols(self, symbols: Union[str, Iterable[str]]):
        """
        Method to add symbol. Supports addition of one symbol as a string as well as list of symbols.
        If no event handler was set, DefaultHandler will be initialized.

        Parameters
        ----------
        symbols: str, Iterable
            Symbols to add. Previously added and remained symbols are ignored on C-API level

        Returns
        -------
        self: Subscription
        """
        self._attach_default_listener()
        dxp.dxf_add_symbols(sc=self.__sub, symbols=cu.to_iterable(symbols))
        return self
예제 #2
0
    def remove_symbols(self,
                       symbols: Optional[Union[str, Iterable[str]]] = None):
        """
        Method removes symbols from subscription. If no symbols provided removes all symbols

        Parameters
        ----------
        symbols: str, Iterable
            One ticker or list of tickers to remove from subscription

        Returns
        -------
        self: Subscription
        """
        if symbols:
            dxp.dxf_remove_symbols(self.__sub, symbols=cu.to_iterable(symbols))
        else:
            dxp.dxf_clear_symbols(self.__sub)
        return self
예제 #3
0
def test_to_iterable_of_strings_with_iterable():
    symbols = ('AAPL', 'MSFT')
    actual_symbols = cu.to_iterable(symbols)
    assert actual_symbols == symbols
예제 #4
0
def test_to_iterable_of_strings_with_incorrect_type():
    cu.to_iterable(123)
예제 #5
0
def test_to_iterable_of_strings_with_string():
    symbol = 'AAPL'
    actual_symbol = cu.to_iterable(symbol)
    assert actual_symbol == [symbol]