Skip to content

mypham14/predicting-stock-market

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

S&P 500 Stock Prediction Project

Overview

This project involves building a stock prediction model using historical data from the S&P 500 index. The model utilizes machine learning techniques to predict whether the stock market will rise or fall the next day. The project aims to provide insights into stock market trends and improve prediction accuracy using various features.

Data Sources

  • Yahoo Finance: Historical data for the S&P 500 index is retrieved using the yfinance library.

Project Structure

  1. Data Collection:

    • The project uses the yfinance library to fetch historical data for the S&P 500 index.
    • Data is stored in a CSV file named sp500.csv for analysis.
  2. Data Processing:

    • The dataset is processed to include features such as moving averages and trends over different time horizons.
    • The target variable is created to indicate whether the market will rise the next day.
  3. Model Building:

    • A Random Forest Classifier is used to predict the target variable.
    • The model is trained on historical data and tested on recent data to evaluate performance.
  4. Backtesting:

    • The model is backtested using historical data to assess prediction accuracy over time.
    • Precision scores are calculated to measure the model's performance.

Data Description

S&P 500 Data

  • Open: Opening price of the index.
  • High: Highest price of the index during the day.
  • Low: Lowest price of the index during the day.
  • Close: Closing price of the index.
  • Volume: Trading volume.
  • Tomorrow: Closing price of the index the next day.
  • Target: Binary indicator of whether the market will rise the next day.
  • Close_Ratio_*: Ratio of the closing price to the moving average over different horizons.
  • Trend_*: Sum of the target variable over different horizons.

Usage

To run the project, execute the Jupyter Notebook provided. The notebook will load the dataset, process the data, train the model, and provide predictions for the stock market.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Yahoo Finance for providing the stock market data.
  • Scikit-learn for machine learning tools and libraries.
  • Pandas for data manipulation and analysis.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published