Maybe this has already been solved and I am fairly new to this, however, it would be nice if the built-in factor Returns() had a log-normal version (log_return = ln(close/close). I'm struggling with recieving 'window safe" errors when defining my pipeline and haven't found a way around it yet. It just does not like my custom factor for the log-return. Perhaps it is just a datatype issue but I saw some documentation that said only the Return(), Zscore(), and some other built-in factors were the only window safe factors available. I included my custom factor below to illustrate. I want to use that LogReturn() custom factor as an input to other custom factors but the custom factors choke on this whereas they work just fine with Returns(); but that is pct_change and that is not what I want.
I'm not even sure why we use the pct_change version of the returns since to my limited understanding they don't really work for quant purposes since they don't multiply (cumproduct) across different time series accurately like the log-returns do; they are different quantities. I want to do some future price expected value and confidence interval forecasting based on the drift rate and standard deviation of the log-returns so any inaccuracies in the returns have a significant compounding effect.
I appreciate any help you can give. Thanks!
# Default inputs
inputs = [USEquityPricing.close]
window_length = 2
# Compute log return
def compute(self, today, assets, out, close):
logreturns = pd.Series(np.log(close[-1] / close), name = 'logreturns')
out[:] = logreturns #np.log(close[-1] / close)