Giter Club home page Giter Club logo

momentum's Introduction

Stocks on the Move: Beating the Market with Hedge Fund Momentum Strategies

Book Author: Andreas Clenow

Code & Implementation: Shehab Raslan

Code starting base: Skyte


Trading Strategy Exclusively to S&P500

  1. Trade only on a single designated day per week

    1. Open positions only if S&P500 above its 200 days MA
  2. Rank all stocks based on volatility adjusted momentum

    1. Slop exponential regression based on past 90 days
    2. Multiply with the coefficient of determination R^2 for the same period
    3. Disqualify stocks which is trading below 100 days moving average or a recent gap in excess of 15%
    4. Calculate position sizes using the Average True Range (ATR) formula for 20 days
      1. Account_Value * Risk_Factor / ATR20
  3. Re-balance portfolio once a week on the designated day

    1. Check if a stock needs to be sold

      1. No longer in the top 20% of the volatility adjusted momentum ranking
      2. Trading below its 100 days MA
      3. A gap over 15%
      4. Is not anymore a part of the index
    2. If cash available after the portfolio re-balancing process

      1. Check if the index in positive trend by verifying it is above its 200 days MA
      2. Buy from the top of the list following the same ranking rule as described in step 2 by verifying
        1. The stock is not already owned (and)
        2. It is in the top 20% of the momentum ranked list
        3. buy till we run out of cash
  4. Re-balance portfolio positions every other time of the designated day

    1. Re-calculate the target size same as step 2.4 but with the updated portfolio size value and ATR20 values
    2. Compare target size with actual size
    3. re-balance if needed

Steps to apply the strategy

Initial Steps

  1. Open config.yaml and put in your parameter preferences
  2. Install requirements: python -m pip install -r requirements.txt

Starting Investing

  1. Run momentum_data.py to aggregate the price data
  2. Run momentum_posis.py to aggregate your momentum positions list
  3. Create an Excel file of the positions you opened and place them in the portfolio file
    1. Example: portfolio/start_date.xlsx

Portfolio re-balance (once a week as recommended by the book)

  1. Run momentum_data.py to aggregate the price data
  2. Run momentum_posis.py to aggregate your momentum positions list
  3. Run portfolio_rebalance_once_week.py
  4. Short the stocks which violate the rules as described in section 3 of trading strategy description
  5. Open new positions if the S&P500 above its 200-days MA based on the recent generated output file
  6. New positions of stocks that we do not already own

Portfolio repositioning (every two weeks as recommended by the book)

  1. Execute the Portfolio re-balance procedure
  2. Run position_rebalance_once_every_two_weeks.py
  3. Re-balance positions if significant differences are present between current portfolio positions & suggested positions

momentum's People

Contributors

skyte 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.