The math description sounds clean on paper but actually implementing it correctly is another thing.
First, clarify the problem inputs and outputs, then outline the algorithm step-by-step: compute daily simple returns, determine weights based on positive returns, simulate portfolio value, and calculate log returns. Finally, discuss implementation details, edge cases, and complexity.
Pro tip: Emphasize the importance of handling edge cases like all returns being non-positive and ensuring numerical stability when computing log returns. Also, mention that you would validate the solution with a small example to catch off-by-one errors.
Confirm the input format (N assets, T days), starting capital, and that returns are computed from prices. Ask if the price matrix includes the initial day or only subsequent days.
For each asset and day (from day 1 to T-1), calculate the simple return as (price_t / price_{t-1}) - 1. Store these in a matrix of size N x (T-1).
For each day, consider only assets with positive returns. Allocate weights proportional to these positive returns, ensuring they sum to 1. If no positive returns, set all weights to 0 (hold cash).
Starting with initial capital, for each day compute the portfolio return as the weighted sum of asset returns. Update the portfolio value. Then compute the daily log return as ln(1 + portfolio_return).
Compute the mean and standard deviation of the daily log returns over the full period. Use appropriate formulas (e.g., sample standard deviation) and discuss any assumptions.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.