Problem: Momentum-weighted daily log-return statistics
You have N assets with end-of-day prices over T trading days. Let prices[i][t] be the closing price of asset i on day t (i = 0..N−1, t = 0..T−1). You start with total capital C in cash at the close of day 0. Fractional shares and zero transaction costs are allowed.
At each day t ≥ 1:
-
Compute simple returns r_i(t) = prices[i][t] / prices[i][t−1] − 1.
-
Set next-day portfolio weights for period t→t+1 as follows:
-
If all r_i(t) ≤ 0, hold 100% cash for the next day (i.e., all asset weights are 0).
-
Otherwise, assign weights only to assets with positive returns, proportional to those returns:
w_i(t) = r_i(t) / Σ_{j: r_j(t) > 0} r_j(t) if r_i(t) > 0; else w_i(t) = 0.
-
Rebalance at the close of day t using these weights.
Let V_t denote portfolio value at the close of day t. The daily log return for period t→t+1 is ln(V_{t+1}/V_t). Note:
-
For t = 0, there are no prior-day returns; treat period 0→1 as 100% cash (log return 0).
Task: Compute and return [mean_log_return, stddev_log_return] over all T−1 daily log returns L_t = ln(V_{t+1}/V_t), for t = 0..T−2.
Assume prices are positive. If T < 2, return [0.0, 0.0].