def add_position(p, name, pos):
    """Add a position to a portfolio.

    Parameters
    ----------
    p : alphapy.Portfolio
        Portfolio that will hold the position.
    name : int
        Unique identifier for the position, e.g., a stock symbol.
    pos : alphapy.Position
        New position to add to the portfolio.

    Returns
    -------
    p : alphapy.Portfolio
        Portfolio with the new position.

    """
    if name not in p.positions:
        p.positions[name] = pos
    return p
