Code Monkey home page Code Monkey logo

optimizing-stock-selection-with-machine-learning-and-alternative-weightings's Introduction

Optimizing-stock-selection-with-Machine-Learning-and-Alternative-Weightings

Uses 2 different algorithms to select stocks out of the S&P 500. Then backtests these stocks using 4 different weighting schemes.

First, the Sagemaker notebook LSTM_toFeedInto_FB-Prophet uses Long Short-Term Memory machine learning model to analyze the returns of the S&P 500 constituents. Then predicts the following month's returns for each issue. Then it ranks the stocks by predicted returns and takes the top 50 stocks and writes them and their returns to a S3 bucket.

Next, the function "Get Prophet Returns Write to S3" reads in these returns and runs each stock through the Facebook Prophet Algorithm. This algorithm does more of a short term analysis to predict trends. Generally, out of 50 stocks, it selects 10 to 20 that have positive trends. It then writes these selected stocks to a S3 bucket.

The function "Get Weights" pulls these selected stocks and then uses the StockNewsAPI to pull sentiment data on each stock for the last 30 days. This historical sentiment data is then fed into Facebook Prophet. Prophet outputs decisions on each stock based on its sentiment trend. Then I take the stocks selected on the basis of historical returns and the stocks seleted based on sentiment, and see if there is any overlap between the 2 sets. The overlapping stocks are then backtested at different weighting schemes using the past 2 years of data. The weighting schemes analyzed are:

  • Equal Weight
  • Equal Risk Contribution
  • Maximum Sharpe Ratio
  • Global Minimum Variance

Finally, the function "Trade Stocks n Cryptos" pulls these weights and asks the user if they'd like to trade the stocks and if so, with which weighting scheme. If the user wishes to trade, the program trades the stocks in the user's Alpaca trading account using the Alpaca API

Next Steps


Next, I'd like to have all of these programs run automatically using triggers in AWS Cloudwatch.


Some .gifs using AWS Lex:

Create Branch Add Branch to Bank


Initiate Investment Execute investments


Improvements

optimizing-stock-selection-with-machine-learning-and-alternative-weightings's People

Contributors

jason-82 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.