Skip to content

Developed an enhanced stock price forecasting solution using YFinance with LSTM and RNN, for improved prediction accuracy.

License

Notifications You must be signed in to change notification settings

AjNavneet/Stock-Price-Prediction-YFinance-LSTM-RNN

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Stock Price Prediction Using Yfinance, LSTM, and RNN

Business Context

Accurate stock price prediction plays a pivotal role in financial markets, influencing investment decisions, risk management, and portfolio optimization. This project leverages recurrent neural networks (RNNs) and long short-term memory (LSTM) networks for stock price prediction, showcasing the application of deep learning techniques in financial forecasting.


Practical Application

Stock price prediction benefits a wide range of stakeholders, including:

  • Investors: Make informed investment decisions and identify opportunities.
  • Traders: Adapt strategies to anticipated price movements.
  • Financial Analysts: Analyze market trends to provide actionable insights.

By accurately forecasting stock prices, stakeholders can manage risks and optimize portfolios more effectively.


Challenges and Limitations

Stock price prediction is inherently challenging due to:

  • Market Volatility: Unpredictable price fluctuations driven by external events.
  • Data Noise: Irregularities and inconsistencies in financial data.
  • External Factors: Global events, policy changes, and other variables impacting market behavior.

This project acknowledges these challenges and aims to highlight how RNNs and LSTMs address temporal dependencies in financial data.


Objective

The project aims to achieve the following outcomes:

  • Improved forecasting accuracy of stock prices.
  • Effective use of RNN and LSTM networks.
  • Insights into how deep learning models capture temporal dependencies in time series data.

Data Description

The dataset consists of historical stock prices for Apple Inc. (AAPL), sourced using the Yahoo Finance API. Key features include:

  • Open: Opening price of the stock.
  • Close: Closing price of the stock.
  • High: Highest price for the trading day.
  • Low: Lowest price for the trading day.
  • Volume: Number of shares traded.

Tech Stack


Approach

1. Neural Network Basics

  • Understand the concepts of RNNs and LSTMs for handling sequential data.

2. Load Stock Data

  • Retrieve historical stock price data using Yahoo Finance API.

3. Data Preprocessing

  • Scale and normalize stock price data.
  • Create sliding windows for time series analysis.

4. RNN Model Development

  • Build and train recurrent neural networks for stock price prediction.

5. LSTM Model Development

  • Extend the analysis by implementing LSTM networks to capture long-term dependencies.

6. Incorporate Technical Indicators

  • Use additional features, such as technical analysis indicators, for improved predictions.

7. Model Evaluation

  • Assess the performance of the RNN and LSTM models using appropriate metrics.
  • Generate sequences for forecasting.

Modular Code Structure

.
├── lib/                                   # Reference folder with original IPython notebooks.
├── ml_pipeline/                           # Folder with modular Python scripts.
│   ├── data_preparation.py                # Functions for data preprocessing.
│   ├── model_training.py                  # Functions for training RNN and LSTM models.
│   ├── evaluation.py                      # Functions for evaluating model performance.
│   ├── engine.py                          # Main script to execute the pipeline.
├── output/                                # Stores saved models and evaluation results.
├── requirements.txt                       # Lists all required libraries and their versions.
└── README.md                              # Project documentation.

Getting Started

1. Clone the Repository

git clone <repository_url>
cd <repository_folder>

2. Install Dependencies

Install the required Python libraries using:

pip install -r requirements.txt

3. Run the Project

Execute the pipeline by running the engine.py script:

python ml_pipeline/engine.py

4. Explore Results

  • Review model outputs and predictions in the output/ folder.
  • Analyze the evaluation metrics for model performance.

Results

  • Forecasting Accuracy:
    • RNN and LSTM models effectively captured temporal patterns in stock prices.
  • Technical Indicator Integration:
    • Enhanced predictions by incorporating additional features.
  • Deep Learning Insights:
    • Demonstrated how RNNs and LSTMs model sequential dependencies in financial data.

Contributing

Contributions are welcome! To contribute:

  1. Fork the repository.
  2. Create a feature branch:
git checkout -b feature-name
  1. Commit your changes:
git commit -m "Add feature"
  1. Push your branch:
git push origin feature-name
  1. Open a pull request.

License

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


Contact

For any questions or suggestions, please reach out to:


Acknowledgments

Special thanks to:


About

Developed an enhanced stock price forecasting solution using YFinance with LSTM and RNN, for improved prediction accuracy.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published