Message Boards Message Boards

0
|
280 Views
|
0 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Holt-Winters method should work well for forecasting trading volume and stock price

Posted 1 month ago

I am trying to forecast the trading volume along with stock price by using Holt-Winters Exponential Smoothing method, a robust forecasting technique when the data exhibits seasonal patterns along with a long-term trend, making it suitable for predicting stock performance or trading volume that is influenced by cyclic factors. I came up with this code:

(* Define the time series data for volume and price *)
volumeData = TimeSeries[{4.04, 5.05, 6.06, 6.85, 7.81, 9.29, 11.70, 14.60, 18.00, 21.40, 26.30, 30.60, 36.70}, 
    {DateObject[{2024, 9}], DateObject[{2024, 10}], DateObject[{2024, 11}], DateObject[{2024, 12}], 
     DateObject[{2025, 1}], DateObject[{2025, 2}], DateObject[{2025, 3}], DateObject[{2025, 4}], 
     DateObject[{2025, 5}], DateObject[{2025, 6}], DateObject[{2025, 7}], DateObject[{2025, 8}], 
     DateObject[{2025, 9}]}];
priceData = TimeSeries[{0.44, 0.80, 1.10, 1.50, 1.80, 2.00, 2.50, 3.20, 3.80, 4.20, 4.50, 4.80, 5.00}, 
    {DateObject[{2024, 9}], DateObject[{2024, 10}], DateObject[{2024, 11}], DateObject[{2024, 12}], 
     DateObject[{2025, 1}], DateObject[{2025, 2}], DateObject[{2025, 3}], DateObject[{2025, 4}], 
     DateObject[{2025, 5}], DateObject[{2025, 6}], DateObject[{2025, 7}], DateObject[{2025, 8}], 
     DateObject[{2025, 9}]}];

(* Apply Holt-Winters exponential smoothing *)
holtWintersVolume = TimeSeriesModelFit[volumeData, {"HoltWinters", {"Additive"}}];
holtWintersPrice = TimeSeriesModelFit[priceData, {"HoltWinters", {"Additive"}}];

(* Generate forecast for the next 12 months *)
volumeForecast = TimeSeriesForecast[holtWintersVolume, 12];
priceForecast = TimeSeriesForecast[holtWintersPrice, 12];

(* Plot both original and smoothed data *)
volumePlot = DateListPlot[{volumeData, volumeForecast}, PlotLegends -> {"Original Volume", "Forecasted Volume"}, 
    PlotLabel -> "Holt-Winters Volume Forecast", ImageSize -> Medium];
pricePlot = DateListPlot[{priceData, priceForecast}, PlotLegends -> {"Original Price", "Forecasted Price"}, 
    PlotLabel -> "Holt-Winters Price Forecast", ImageSize -> Medium];

{volumePlot, pricePlot}

However, Wolfram can't seem to recognize that I am passing the values from TimeSeries to variables volumeData and priceData. if i retain TimeSeries only, it manages to read at least and move one step forward. What seems to be the issue? It always say no Wolfram Language Translation found.

POSTED BY: Maria Rosario
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract