I have a dataset in QuestDB with daily returns for a stock, starting at $100. I want to calculate the cumulative product of the returns to simulate the stock’s price path (random walk). The daily returns are stored in a table called daily_returns
.
Here’s a sample of the relevant columns:
Date | Daily Return (%) |
---|---|
2024-09-05 | 2.00 |
2024-09-06 | -1.00 |
2024-09-07 | 1.50 |
2024-09-08 | -3.00 |
2024-09-09 | 2.50 |
2024-09-10 | 1.00 |
2024-09-11 | -2.00 |
2024-09-12 | 1.50 |
I’m trying to calculate the cumulative product of (1 + return)
for each day, starting from $100. This would be the expected output
Date | Daily Return (%) | Stock Price |
---|---|---|
2024-09-05 | 2.00 | 102.00 |
2024-09-06 | -1.00 | 100.98 |
2024-09-07 | 1.50 | 102.49 |
2024-09-08 | -3.00 | 99.42 |
2024-09-09 | 2.50 | 101.91 |
2024-09-10 | 1.00 | 102.93 |
2024-09-11 | -2.00 | 100.87 |
2024-09-12 | 1.50 | 102.38 |