Skip to content

Commit

Permalink
explained return predictions model
Browse files Browse the repository at this point in the history
  • Loading branch information
kasperjo committed Oct 24, 2023
1 parent bd4a0d0 commit a355ead
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions experiments/utils.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit a355ead

Please sign in to comment.