Giter Site home page Giter Site logo

mjmaher987 / stock-prediction-using-ml Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 0.0 14.37 MB

Predicting Stock and Currency Prices Using Machine Learning and Artificial Intelligence Tools

License: MIT License

Jupyter Notebook 99.89% Python 0.11%
ichimoku-cloud lstm-neural-networks machine-learning nbits rnn stock-price-prediction transformers nheats

stock-prediction-using-ml's Introduction

Machine Learning Methods in Algorithmic Trading

image

This is the code and documentation for the paper "Machine Learning Methods in Algorithmic Trading: An Experimental Evaluation of Supervised Learning Techniques for Stock Price". You can find the preprint version of the document here.

Authors

  • Mohammad Javad Maheronnaghsh
  • Mohammad Mahdi Gheidi
  • Abolfazl Younesi
  • MohammadAmin Fazli

Introduction

This paper explores using machine learning techniques like RNN, LSTM, NBeats, NHits and Transformer models for stock price prediction and algorithmic trading. The models are trained and evaluated on historical pricing data. A trading bot is also implemented to utilize the predictions.

  • The key goals of the paper are:
    • Evaluate and compare different ML models for financial time series forecasting
    • Identify the most accurate models for stock price prediction
    • Implement a trading bot to leverage predictions for automated trading

Models

The following supervised learning models are implemented:

  • Recurrent Neural Network (RNN)
  • Long Short-Term Memory (LSTM)
  • NBeats
  • NHits
  • Transformer The models are implemented in TensorFlow and Keras.

Data

The dataset used is daily closing prices for the EUR/USD currency pair obtained from yfinance API.

The data is split 80/20 into train and test sets. It is preprocessed by reshaping into input/output samples and normalizing to [0,1].

Usage

The model training and evaluation scripts are located in the src folder:

  • train.py - Trains a model
  • evaluate.py - Evaluates a trained model on the test set
  • trading_bot.py - Trading bot implementation Example usage:
# Train LSTM model
python train.py --model lstm

# Evaluate NBeats model 
python evaluate.py --model nbeats

# Train LSTM model 
python train.py --model lstm 

# Evaluate NBeats model
python evaluate.py --model nbeats

Results

The NBeats and NHits models achieve the lowest errors, indicating good performance even with limited data. Transformer requires more data to reach full potential.

References

Citation

@article{maheronnaghsh2023machine,
  title={Machine Learning Methods in Algorithmic Trading: An Experimental Evaluation of Supervised Learning Techniques for Stock Price},
  author={Maheronnaghsh, Mohammad Javad and others},
  journal={preprint},
  year={2023}
}

Milestones

I. Milestone 1: Data Collection and Preprocessing (Week 1)

  • Collect historical stock and currency price data from reliable financial sources.
  • Preprocess the data to handle missing values, outliers, and ensure consistent scaling across features.

II. Milestone 2: Data Partitioning and Model Definition (Week 2)

  • Divide the preprocessed data into training, validation, and test sets.
  • Define the 6 models to be used: Transformers, LSTM, Simple RNN, Ichimoku, NHits, and NBeats.

III. Milestone 3: Model Training and Validation (Week 3)

  • Train each model using the training data and appropriate optimization algorithms (e.g., Adam, RMSprop) with suitable learning rates.
  • Utilize the validation set to fine-tune hyperparameters for optimal model performance.

IV. Milestone 4: Model Evaluation and Comparative Analysis (Week 4)

  • Evaluate the predictive accuracy of each model using evaluation metrics such as MSE, RMSE, and MAE.
  • Conduct a comprehensive comparative analysis to identify the most accurate and reliable model.

V. Milestone 5: Discussion of Results and Conclusion (Week 5)

  • Present the findings of the comparative analysis, highlighting the strengths and weaknesses of each model.
  • Discuss the models' suitability for stock and currency price prediction in different market conditions.
  • Address potential limitations and challenges encountered during the research.
  • Summarize key findings and emphasize the model that demonstrated superior performance.
  • Draw conclusions, discuss implications, and suggest future research directions.

stock-prediction-using-ml's People

Contributors

mjmaher987 avatar

Stargazers

Fabien avatar  avatar  avatar

Watchers

 avatar  avatar

stock-prediction-using-ml's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.