-
-
Notifications
You must be signed in to change notification settings - Fork 284
Open
Description
In the Financial Data Analysis with Spyder workshop, the portfolio return is calculated using:
rets_1 = np.log(close_data_1/close_data_1.shift(1)).dropna()
weights_1 = [0.2, 0.2, 0.2, 0.2, 0.2]
def portfolio_return(returns, weights):
return np.dot(returns.mean(), weights) * 252problems
This approach is problematic for two reasons:
-
Arithmetic scaling of returns: Multiplying the mean daily return by 252 assumes linearity and ignores compounding, which misrepresents actual portfolio performance.
-
Log scale mismatch: If returns are log returns (as is common in financial analysis), the formula incorrectly averages them arithmetically. This leads to inaccurate results, as shown in this example:
Invest $50 in Stock A (100% gain) and $50 in Stock B (0% gain)
True portfolio return: 50%
Log returns: log(2) and log(1)
Arithmetic mean of log returns: log(2)/2 ≈ 0.3466
Exponentiated result: exp(0.3466) - 1 ≈ 41.42% → incorrect
suggested fix
- Use the terminal value (raw, not logged) for returns to avoid scaling the log returns with linear weights.
Metadata
Metadata
Assignees
Labels
No labels