generated from cvxgrp/simulator
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
16 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |