예제 #1
0
                                              window_length, min_periods)
    ### Rolling sortino ratio
    rolling_sortino_ratio_df = m.rolling_sortino_ratio(df_data, columns_name,
                                                       window_length,
                                                       min_periods, MAR,
                                                       threshold)
    ### Rolling omega ratio
    rolling_omega_ratio_df = m.rolling_omega_ratio(df_data, columns_name,
                                                   window_length, min_periods,
                                                   MAR)
    ### Rolling sharp ratio
    rolling_sharpe_ratio_df = m.rolling_sharpe_ratio(df_data, columns_name,
                                                     window_length,
                                                     min_periods, benchmark)
    ### Rolling alpha
    rolling_alpha_df = m.rolling_alpha(df_data, columns_name, window_length,
                                       min_periods)
    ### Rolling correlation
    rolling_corr_df = m.rolling_corr(df_data, columns_name, market_index,
                                     window_length_corr, min_periods_corr)

    ### Calculate the correlation with other fund's mean return
    # Modify the market data, replace it with mean of other fund's return
    df_data_corr = df_data.copy()
    df_data_corr['Russell 3000'] = df_data_other.mean(
        axis=1)  # replace with population mean
    final_cum_return = cum_return_df_other.iloc[-1, :-1]

    quantile = pd.qcut(final_cum_return.T, 4, labels=['Q1', 'Q2', 'Q3', 'Q4'])
    Q1 = quantile[quantile.values == 'Q1'].index
    Q2 = quantile[quantile.values == 'Q2'].index
    Q3 = quantile[quantile.values == 'Q3'].index
예제 #2
0
                                                   columns_name=columns_name,
                                                   window_length=36,
                                                   min_periods=36,
                                                   start_gap=6,
                                                   MAR=0)
    ### Rolling sharp ratio
    rolling_sharpe_ratio_df = m.rolling_sharpe_ratio(df_data,
                                                     columns_name=columns_name,
                                                     window_length=36,
                                                     min_periods=36,
                                                     start_gap=6,
                                                     benchmark=0.02)
    ### Rolling alpha
    rolling_alpha_df = m.rolling_alpha(df_data,
                                       columns_name=columns_name,
                                       window_length=36,
                                       min_periods=36,
                                       start_gap=6)
    ### Rolling correlation
    rolling_corr_df = m.rolling_corr(df_data,
                                     columns_name=columns_name,
                                     target_benchmark='Russell 3000',
                                     window_length=36,
                                     min_periods=36,
                                     start_gap=6)
    ### Draw Down
    dd_df = 100 * m.draw_down(df_data, columns_name, start_gap)

    ### Graph for result
    with PdfPages('Rolling Ratio Figure.pdf') as pdf:
        plt.style.use('fivethirtyeight')
예제 #3
0
    ### Rolling beta
    rolling_beta_df = m.rolling_beta(df_data, columns_name, window_length, min_periods)
    ### Rolling annulized return
    rolling_annual_return_df = m.rolling_annulized_return(df_data, columns_name, window_length, min_periods)
    ### Cummulative return
    cum_return_df = m.cumulative_return(df_data, columns_name, window_length, min_periods)
    cum_return_df_other = m.cumulative_return(df_data_other, columns_name_other, window_length, min_periods)
    ### Rolling sortino ratio
    rolling_sortino_ratio_df = m.rolling_sortino_ratio(df_data, columns_name, window_length, min_periods, MAR, threshold)
    ### Rolling omega ratio
    rolling_omega_ratio_df = m.rolling_omega_ratio(df_data, columns_name, window_length, min_periods, MAR)
    ### Rolling sharp ratio
    rolling_sharpe_ratio_df = m.rolling_sharpe_ratio(df_data, columns_name, window_length, min_periods, benchmark)
    ### Rolling alpha
    rolling_alpha_df = m.rolling_alpha(df_data, columns_name, window_length, min_periods)
    ### Rolling correlation
    rolling_corr_df = m.rolling_corr(df_data, columns_name, market_index, window_length_corr, min_periods_corr)
   
    ### Calculate the correlation with other fund's mean return
    # Modify the market data, replace it with mean of other fund's return
    df_data_corr = df_data.copy()
    df_data_corr['Russell 3000'] = df_data_other.mean(axis=1) # replace with population mean    
    final_cum_return = cum_return_df_other.iloc[-1,:-1]
    
    quantile = pd.qcut(final_cum_return.T,4, labels=['Q1','Q2','Q3','Q4'])
    Q1 = quantile[quantile.values == 'Q1'].index
    Q2 = quantile[quantile.values == 'Q2'].index
    Q3 = quantile[quantile.values == 'Q3'].index
    Q4 = quantile[quantile.values == 'Q4'].index 
    df_data_Q1 = df_data.copy()