Giter Club home page Giter Club logo

georgemuriithi / investment-portfolio-optim Goto Github PK

View Code? Open in Web Editor NEW
31.0 2.0 3.0 2.29 MB

An investment portfolio of stocks is created using Long Short-Term Memory (LSTM) stock price prediction and optimized weights. The performance of this portfolio is better compared to an equally weighted portfolio and a market capitalization-weighted portfolio.

License: GNU General Public License v3.0

Jupyter Notebook 100.00%
stock-price-prediction investment-portfolio python pytorch deep-learning lstm time-series-forecasting

investment-portfolio-optim's Introduction

Investment Portfolio Optimization

License

An investment portfolio of stocks is created using Long Short-Term Memory (LSTM) stock price prediction and optimized weights. The performance of this portfolio is better compared to an equally weighted portfolio and a market capitalization-weighted portfolio.

Disclaimer: The LSTM model cannot be used to predict stock prices in real life, and this project cannot help an investor make investment decisions in the stock market. This is because the stock market is highly unpredictable. In this project, the validation phase is used to test the model's performance. The purpose of the project is to implement Univariate Time-Series Prediction using LSTM.

Problem Description

The task is to create an investment portfolio of stocks that maximizes overall return.

Data

Top 30 U.S. companies by market capitalization are used. The start time is 2009-12-31 and the end time is 2021-12-31. AbbVie (ABBV), Meta (FB) and Tesla, Inc. (TSLA) are excluded because they were listed in the stock market after 2009-12-31.

The csv files and model states can be accessed from the data folder.

Open In Colab

An investment portfolio of several stocks is created by making stock price predictions using an LSTM Univariate Time-Series Prediction model. Daily returns are then are computed from the predicted stock prices and used to get weights that maximize overall return. This is done using SLSQP (Sequential Least SQuares Programming) optimization.

To create the features of the LSTM model, a time step of 100 days is used. This means that if we consider today's Adj Close price as the response, the features will be the Adj Close prices of the past 100 days.

LSTM model parameters:

  • input_size=1
  • hidden_size=1
  • num_layers=1
  • batch_first=True
  • num_classes=1
  • learning_rate=0.001
  • optimizer=Adam
  • loss_function=MSELoss()
  • num_epochs=10000

GPU is leveraged.

investment-portfolio-optim's People

Contributors

georgemuriithi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

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.