From a355ead2942078c2ffd580f266e5d9c76a94eef3 Mon Sep 17 00:00:00 2001 From: Kasper Johansson Date: Tue, 24 Oct 2023 08:44:58 -0700 Subject: [PATCH] explained return predictions model --- experiments/utils.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/experiments/utils.py b/experiments/utils.py index a62ab64..cf435cb 100644 --- a/experiments/utils.py +++ b/experiments/utils.py @@ -1,8 +1,22 @@ import numpy as np -def synthetic_returns(prices, sigma_r=0.02236, sigma_eps=0.14142): +def synthetic_returns(prices, var_r=0.0005, var_eps=0.02): + """ + param prices: a DataFrame of prices + param var_r: the Gaussian variance of the returns + param var_eps: the Gaussian variance of the noise term + + returns: a DataFrame of "synthetic return predictions" computed as + alpha*(returns+noise), where alpha=var_r / (var_r + var_eps); this is the + coefficient that minimize the variance of the prediction error under the + above model. + + var_r = 0.0005 and var_eps = 0.02 correspond to an information ratio + sqrt(alpha) of about 0.15. + """ returns = prices.pct_change() - alpha = sigma_r**2 / (sigma_r**2 + sigma_eps**2) + alpha = var_r / (var_r + var_eps) + sigma_eps = np.sqrt(var_eps) return alpha * (returns + np.random.normal(size=returns.shape) * sigma_eps)