Interpolating Missing Data with Noise like Brownian Motion

7 views (last 30 days)
Hello folks,
I have a few questions regarding interpolating financial price data set.
I have a set of price points, but their frequency is not high, so I would like to interporlate between these between.
For instance, consider 24 by 2 double price data points where it spans over 24 hours.
Between each hour, I would like to interporlate 15, 30, 45, so total three interporlated points, that way I now have 72 points per day.
However, I would like to insert some noise that follows possibly a geometric brownian motion or random walk to give a flavor of randomness in the data and they are not all linear connected.
What might be the best way to do this?
I have the basic codes so far of importing the data and converting to 24 by 2 double format:
file= "pricedata.xlsx";
Tab =readtable(file);
T=table2array(Tab);
Any suggestions?
Thanks in advance!

Accepted Answer

Bruno Luong
Bruno Luong on 2 Sep 2022
"What might be the best way to do this?'"
Interpolation THEN
adding noise.
There is no reason to mix the noise generation with interpolation step.
  9 Comments
Bruno Luong
Bruno Luong on 8 Sep 2022
Edited: Bruno Luong on 8 Sep 2022
Because I read this:
"For instance, consider 24 by 2 double price data points where it spans over 24 hours.
...
that way I now have 72 points per day."
You start with 24 data per day and want to end up with 72. 72/24 is 3. But I might miss understanding what you wrote.
Tatte Berklee
Tatte Berklee on 8 Sep 2022
Excellent. No, you are correct. I wanted this, but your sample code had 3600, so now it is clear to me you put 3600 for demonstration. Thanks!

Sign in to comment.

More Answers (1)

Image Analyst
Image Analyst on 2 Sep 2022
Try this:
rows = 24;
prices = round(100*rand(rows, 2), 2) % [Beginning of day, end of day]
% Scan down getting prices.
% Allocate 72 points per day, including the start and end.
interpPrices = zeros(rows, 72);
for row = 1 : rows
% Add up to +/- 2 unit of noise.
noise = 2 * rand(1, 72);
interpPrices(row, :) = round(linspace(prices(row, 1), prices(row, 2), 72) + noise, 2);
end
  3 Comments
Image Analyst
Image Analyst on 2 Sep 2022
Yes. prices is the opening and closing prices for the day. You said you already have this. Then you said you wanted to go between those two values with 70 interpolated values that had a bit of noise added to them, for a total of 72 prices per day. Each row of interpPrices is a day, and there are 72 prices at various times thoughout that day.
Tatte Berklee
Tatte Berklee on 6 Sep 2022
Thanks for the response and comments. I will try this method as well!

Sign in to comment.

Categories

Find more on Data Preprocessing in Help Center and File Exchange

Products


Release

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!