<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Equal-weight Portfolio
Step1:  Volatility-weighted Portfolio (using just np.std as weighting metric)
Step2:  Volatility-weighted Portfolio (with constraint of no asset weight to be greater than 2x any other asset weight. Function def min_max_vol_bounds defines the the constraint)
Step3:  Quantized bucket Volatility-weighted Portfolio (using custom function bucket_std() as weighting metric)
<ASSISTANT_TASK:>
Python Code:
# USAGE: Equal-Weight Portfolio.
# 1) if 'exclude_non_overlapping=True' below, the portfolio will only contains 
#    days which are available across all of the algo return timeseries.
# 
#    if 'exclude_non_overlapping=False' then the portfolio returned will span from the
#    earliest startdate of any algo, thru the latest enddate of any algo.
#
# 2) Weight of each algo will always be 1/N where N is the total number of algos passed to the function
portfolio_rets_ts, data_df = pf.timeseries.portfolio_returns_metric_weighted([SPY, FXE, GLD],
                                                                             exclude_non_overlapping=True
                                                                            )
to_plot = ['SPY', 'GLD', 'FXE'] + ["port_ret"]
data_df[to_plot].apply(pf.timeseries.cum_returns).plot()
pf.timeseries.perf_stats(data_df['port_ret'])
Explanation: Equal-weight Portfolio
End of explanation
# USAGE: Portfolio based on volatility weighting.
# The higher the volatility the _less_ weight the algo gets in the portfolio
# The portfolio is rebalanced monthly. For quarterly reblancing, set portfolio_rebalance_rule='Q'
stocks_port, data_df = pf.timeseries.portfolio_returns_metric_weighted([SPY, FXE, GLD], 
                                                                       weight_function=np.std, 
                                                                       weight_function_window=126, 
                                                                       inverse_weight=True
                                                                      )
to_plot = ['SPY', 'GLD', 'FXE'] + ["port_ret"]
data_df[to_plot].apply(pf.timeseries.cum_returns).plot()
pf.timeseries.perf_stats(data_df['port_ret'])
Explanation: Volatility-weighted Portfolio (using just np.std as weighting metric)
End of explanation
stocks_port, data_df = pf.timeseries.portfolio_returns_metric_weighted([SPY, FXE, GLD], 
                                                                       weight_function=np.std,
                                                                       weight_func_transform=pf.timeseries.min_max_vol_bounds,
                                                                       weight_function_window=126, 
                                                                       inverse_weight=True)
to_plot = ['SPY', 'GLD', 'FXE'] + ["port_ret"]
data_df[to_plot].apply(pf.timeseries.cum_returns).plot()
pf.timeseries.perf_stats(data_df['port_ret'])
Explanation: Volatility-weighted Portfolio (with constraint of no asset weight to be greater than 2x any other asset weight. Function def min_max_vol_bounds defines the the constraint)
End of explanation
stocks_port, data_df = pf.timeseries.portfolio_returns_metric_weighted([SPY, FXE, GLD], 
                                                                       weight_function=np.std,
                                                                       weight_func_transform=pf.timeseries.bucket_std,
                                                                       weight_function_window=126, 
                                                                       inverse_weight=True)
to_plot = ['SPY', 'GLD', 'FXE'] + ["port_ret"]
data_df[to_plot].apply(pf.timeseries.cum_returns).plot()
pf.timeseries.perf_stats(data_df['port_ret'])
Explanation: Quantized bucket Volatility-weighted Portfolio (using custom function bucket_std() as weighting metric)
End of explanation
<END_TASK>