Simulate return-weighted rebalancing strategy
OptiverSoftware Engineer · Technical ScreenLast updated
Simulate return-weighted rebalancing strategy evaluates metric design, causal reasoning, experiment setup, diagnostics, SQL/statistical checks, and recommendations in a realistic interview setting. A strong answer states assumptions, handles edge cases, explains trade-offs, and shows how to validate the result clearly.
You are given an N×T matrix prices where prices[i][t] is the end‑of‑day price of asset i on day t (t = 0…T− 1). Start with total capital C in cash on day 0. For each day t ≥ 1, compute simple returns r_i(t) = prices[i][t]/prices[i][t−1] − 1. If all r_i(t) ≤ 0, hold 100% cash for the next day. Otherwise, set next‑day portfolio weights proportional to the positive returns: w_i(t) = r_i(t) / Σ_{j: r_j(t) > 0} r_j(t) for r_i(t) > 0, and w_i(t) = 0 otherwise. Rebalance at the close of day t using these weights; fractional shares and zero transaction costs are allowed. Let V_t be portfolio value at the close of day t. The daily log return for period t→t+1 is ln(V_{t+1}/V_t). Compute and return [mean_log_return, stddev_log_return] over all T−1 daily log returns.
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.