Repository: quantopian/zipline
File: zipline/assets/synthetic.py (Python)

Code before:
        If not provided, symbols are generated from the sequence 'A', 'B', ...

    Returns
    -------
    info : pd.DataFrame
        DataFrame representing newly-created assets.
    """
    num_assets = len(sids)
    if symbols is None:
        symbols = list(ascii_uppercase[:num_assets])

    if names is None:
        names = map(lambda x: str(x) + " INC.", symbols)

    return pd.DataFrame(
        {
            'symbol': list(symbols),
            'start_date': pd.to_datetime([start_date] * num_assets),
            'end_date': pd.to_datetime([end_date] * num_assets),
            'asset_name': list(names),
            'exchange': 'TEST',
            'exchange_full': 'TEST FULL',
        },
        index=sids,
        columns=(
            'start_date',
            'end_date',
            'symbol',
            'exchange',
            'exchange_full',
            'asset_name',
        ),
    )


def make_jagged_equity_info(num_assets,
                            start_date,
                            first_end,
                            frequency,
                            periods_between_ends,
                            auto_close_delta):
    """
    Create a DataFrame representing assets that all begin at the same start
    date, but have cascading end dates.

    Parameters
    ----------
    num_assets : int
        How many assets to create.
    start_date : pd.Timestamp
        The start date for all the assets.

Review comment (bug):
This branch has failing python3 tests in the case where `symbols` is passed as a generator (actually the result of a call to `map`, which in python2 returns a `list`). The map is already consumed by the call to `list(symbols)`, so `names` is an empty list, which is a different length from the length of the list of symbols.

Code after:
        If not provided, symbols are generated from the sequence 'A', 'B', ...
    names : list, optional
        Names to use for the assets.
        If not provided, names are generated by adding " INC." to each of the
        symbols (which might also be auto-generated).

    Returns
    -------
    info : pd.DataFrame
        DataFrame representing newly-created assets.
    """
    num_assets = len(sids)
    if symbols is None:
        symbols = list(ascii_uppercase[:num_assets])
    else:
        symbols = list(symbols)

    if names is None:
        names = [str(s) + " INC." for s in symbols]

    return pd.DataFrame(
        {
            'symbol': symbols,
            'start_date': pd.to_datetime([start_date] * num_assets),
            'end_date': pd.to_datetime([end_date] * num_assets),
            'asset_name': list(names),
            'exchange': 'TEST',
            'exchange_full': 'TEST FULL',
        },
        index=sids,
        columns=(
            'start_date',
            'end_date',
            'symbol',
            'exchange',
            'exchange_full',
            'asset_name',
        ),
    )


def make_jagged_equity_info(num_assets,
                            start_date,
                            first_end,
                            frequency,
                            periods_between_ends,
                            auto_close_delta):
    """
    Create a DataFrame representing assets that all begin at the same start
    date, but have cascading end dates.