R Stock Forecaster

R Stock Forecaster is an R based cgi program for forecasting stock values using neural networks. I used SSSR for cgi-bin programming in R, fImport for importing stock data from Yahoo Finance and neuralnet for neural network training and forecasting. First, R program collects close data for a given stock from Yahoo, then calculates return values for the given price data and then uses up to 10 lags as independent variables and today's return values as dependent. Dependent (response) variables are binary, can only take two vectors of binary data. They are [1,0] if next day return increases and [0,1] if next day return does not change or decreases. Neural network is trained for three times and best result is printed.


You have to learn the stock code, for example GOOG is the stock code of Google, in order to forecast. You can get the stock codes using Search - Yahoo! Finance link. The stock code of Dell is DELL, code of IBM is IBM, code of Apple is AAPL, code of Oracle is ORCL. Now, you can type a stock code and click the Try forecasting button to try forecasting next day! Notes:
  • This process can take time.
  • Neural network may reach a local optima so running the query for more times can be a good solution.
  • No warranty!

    Stock Code

If you like this solution or you have got any questions, you can send e-mail using mhsatman [at] yahoo.com.

Back to home



View My Stats