<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def factor_positions(factor_data, period, long_short=True, group_neutral=False, equal_weight=False, quantiles=None, groups=None):
 """ Simulate a portfolio using the factor in input and returns the assets positions as percentage of the total portfolio. Parameters factor_data : pd.DataFrame - MultiIndex A MultiIndex DataFrame indexed by date (level 0) and asset (level 1), containing the values for a single alpha factor, forward returns for each period, the factor quantile/bin that factor value belongs to, and (optionally) the group the asset belongs to. - See full explanation in utils.get_clean_factor_and_forward_returns period : string 'factor_data' column name corresponding to the 'period' returns to be used in the computation of porfolio returns long_short : bool, optional if True then simulates a dollar neutral long-short portfolio - see performance.create_pyfolio_input for more details group_neutral : bool, optional If True then simulates a group neutral portfolio - see performance.create_pyfolio_input for more details equal_weight : bool, optional Control the assets weights: - see performance.create_pyfolio_input for more details. quantiles: sequence[int], optional Use only specific quantiles in the computation. By default all quantiles are used groups: sequence[string], optional Use only specific groups in the computation. By default all groups are used Returns ------- assets positions : pd.DataFrame Assets positions series, datetime on index, assets on columns. Example: index 'AAPL' 'MSFT' cash 2004-01-09 10:30:00 13939.3800 -14012.9930 711.5585 2004-01-09 15:30:00 0.00 -16012.9930 411.5585 2004-01-12 10:30:00 14492.6300 -14624.8700 0.0 2004-01-12 15:30:00 14874.5400 -15841.2500 0.0 2004-01-13 10:30:00 -13853.2800 13653.6400 -43.6375 """

    fwd_ret_cols = utils.get_forward_returns_columns(factor_data.columns)

    if period not in fwd_ret_cols:
        raise ValueError("Period '%s' not found" % period)

    todrop = list(fwd_ret_cols)
    todrop.remove(period)
    portfolio_data = factor_data.drop(todrop, axis=1)

    if quantiles is not None:
        portfolio_data = portfolio_data[portfolio_data['factor_quantile'].isin(
            quantiles)]

    if groups is not None:
        portfolio_data = portfolio_data[portfolio_data['group'].isin(groups)]

    weights = \
        factor_weights(portfolio_data, long_short, group_neutral, equal_weight)

    return positions(weights, period)