Пример #1
0
    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')
        rolling_annual_return_df[[
            'TeamCo Client Composite', 'HFRI Fund Weighted Composite Index',
            'HFRI Fund of Funds Composite Index'
        ]].plot(title='36 Months Rolling Annual Return')
        plt.legend(prop={'size': 12})
        pdf.savefig()
Пример #2
0
                                                       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, min_periods)
    ### Draw Down
    dd_df = 100 * m.draw_down(df_data, columns_name)

    ### Generate graph and save them to the pdf file
    p.graph_gen('Rolling Ratio Figure and Radar Chart Result.pdf', index_name, rolling_annual_return_df, cum_return_df, \
                rolling_alpha_df,rolling_beta_df, rolling_corr_df, rolling_sharpe_ratio_df, \
                rolling_sortino_ratio_df,rolling_omega_ratio_df, dd_df, Beta_df, Beta_df_p, \
                Beta_df_np, Corr_df, Corr_df_p, Corr_df_np)

    ### Output all static dataframe into excel file
    dfs = [Annulized_Return_df,Calendar_Return_df,Sharpe_df,Sortino_df,\
           Standard_deviation_df,Downside_Deviation_df,Beta_df,Beta_df_p,\
           Beta_df_np,Omega_df,Corr_df,Corr_df_p,Corr_df_np,Summary_table_df]
    put.multiple_dfs(dfs, 'Financial Ratio', 'Financial Ratio Result.xlsx', 1)
Пример #3
0
                                                       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()
    df_data_Q1['Russell 3000'] = df_data_other[Q1].mean(axis=1)
Пример #4
0
  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()
  df_data_Q1['Russell 3000'] = df_data_other[Q1].mean(axis=1)
  df_data_Q2 = df_data.copy()