Interpolating Missing Data with Noise like Brownian Motion

7 visualizaciones (últimos 30 días)
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!

Respuesta aceptada

Bruno Luong
Bruno Luong el 2 de Sept. de 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 comentarios
Bruno Luong
Bruno Luong el 8 de Sept. de 2022
Editada: Bruno Luong el 8 de Sept. de 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 el 8 de Sept. de 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!

Iniciar sesión para comentar.

Más respuestas (1)

Image Analyst
Image Analyst el 2 de Sept. de 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 comentarios
Image Analyst
Image Analyst el 2 de Sept. de 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 el 6 de Sept. de 2022
Thanks for the response and comments. I will try this method as well!

Iniciar sesión para comentar.

Categorías

Más información sobre Data Preprocessing en Help Center y File Exchange.

Productos


Versión

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by