def random_tickers(
    length, n_tickers, endswith=None, letters=None, slicer=itertools.islice
):
    """Generate a length-n_tickers list of unique random ticker symbols.

    Parameters
    ----------
    length : int
        The length of each ticker string.
    n_tickers : int
        Number of tickers to generate.
    endswith : str, default None
        Specify the ending element(s) of each ticker (for example, 'X').
    letters : sequence, default None
        Sequence of possible letters to choose from.  If None, defaults to
        `string.ascii_uppercase`.

    Returns
    -------
    list of str

    Examples
    --------
    >>> from pyfinance import utils
    >>> utils.random_tickers(length=5, n_tickers=4, endswith='X')
    ['UZTFX', 'ROYAX', 'ZBVIX', 'IUWYX']

    >>> utils.random_tickers(3, 8)
    ['SBW', 'GDF', 'FOG', 'PWO', 'QDH', 'MJJ', 'YZD', 'QST']
    """

    # The trick here is that we need uniqueness.  That defeats the
    #     purpose of using NumPy because we need to generate 1x1.
    #     (Although the alternative is just to generate a "large
    #     enough" duplicated sequence and prune from it.)

    if letters is None:
        letters = string.ascii_uppercase
    if endswith:
        # Only generate substrings up to `endswith`
        length = length - len(endswith)
    join = "".join

    def yield_ticker(rand=random.choices):
        if endswith:
            while True:
                yield join(rand(letters, k=length)) + endswith
        else:
            while True:
                yield join(rand(letters, k=length))

    tickers = itertools.islice(unique_everseen(yield_ticker()), n_tickers)
    return list(tickers)
Generate a length-n_tickers list of unique random ticker symbols.

    Parameters
    ----------
    length : int
        The length of each ticker string.
    n_tickers : int
        Number of tickers to generate.
    endswith : str, default None
        Specify the ending element(s) of each ticker (for example, 'X').
    letters : sequence, default None
        Sequence of possible letters to choose from.  If None, defaults to
        `string.ascii_uppercase`.

    Returns
    -------
    list of str

    Examples
    --------
    >>> from pyfinance import utils
    >>> utils.random_tickers(length=5, n_tickers=4, endswith='X')
    ['UZTFX', 'ROYAX', 'ZBVIX', 'IUWYX']

    >>> utils.random_tickers(3, 8)
    ['SBW', 'GDF', 'FOG', 'PWO', 'QDH', 'MJJ', 'YZD', 'QST']