def simulate_mean_sortino_ratio(portfolio, test_data, parameters = default_parameters): test_bounds = generate_bounds(0.01, len(test_data)) test_data_sets = [simulate_test_data(test_data, test_bounds, factor=1.5) for _ in range(0,100)] return np.mean([pstats.sortino_base(simulate_portfolio(portfolio, td), parameters.target_rate) for td in test_data_sets])
def generate_ratios_experiment_20151027( portfolios, parameters = default_parameters): test_data = excess_returns[120:] + parameters.risk_free_rate test_bounds = generate_bounds(0.05, len(test_data)) msv_results = simulate_portfolio(portfolios['msv'], test_data) pu_results = [(s, simulate_portfolio(u, test_data)) for (s,u) in portfolios['pu']] naive_results = simulate_portfolio(portfolios['naive'], test_data) return {'Sharpe': {'msv': pstats.sharpe_base(msv_results), 'pu': [[s, pstats.sharpe_base(v)] for (s, v) in pu_results], 'naive': pstats.sharpe_base(naive_results)}, 'Sortino': {'msv': pstats.sortino_base(msv_results, parameters.target_rate), 'pu': [[s, pstats.sortino_base(v, parameters.target_rate)] for (s, v) in pu_results], 'naive': pstats.sortino_base(naive_results, parameters.target_rate)}}