The Recurring Investment Algorithm

Home / AboutTry YourselfLog In / Sign Up

Introduction

This application was created to share and backtest a recurring stock purchasing algorithm . The goal of the algorithm is to be an alternative to a constant recurring investment that provides better dollar cost averging (lower cost per stock purchased). This is not financial advice!

Basics

The backtesting of the algorithm assumes only stock purchases are made; no selling occurs. In addition, the principal invested is not fixed. Instead, a constant user defined max and min are set for the recurring stock purchases.

About the site

This page introduces the algorithm. The Try Now page allows users to backtest the algorithm using their own inputs and selected stock. Users can save their investment inputs using the Sign Up page to created a site account.

Evaluating Drops

To understand this buying algorithm, users are first introduced to a stock's 52 week high drop. This percentage is computed with the following steps:

  1. Determine the stock's max price in the last 52 weeks.
  2. Subtract the current price from the max price.
  3. Divide the resulting subtraction by the max price.

The plot the right illustrates current and max price over the last year for the stock ticker SPY. The live 52 week high drop is computed.

Price of SPY over the last year
Today's 52 week high drop: 100%
01-01-70$0$3$6$10.3Price
Date

Determining Spend

After picking a stock and recurring investment frequency, the amount spent must be determined for each purchase.

First the user must select select three parameters:

  1. Min purchase amount.
  2. Max purchase amount.
  3. Select the 52 wk high drop to spend half of the max. ( Refer to this parameter as - hd )

With these three parameters the plot to the left is produced. This graph shows the percent spend relative to the max. amount as a function of the 52 week high drop in the horizontal axis.

Therefore, at each purchase time this graph is used to determine purchase amount based on the 52 week high drop.

Relative spend plot
0%25%50%75%100%0%25%50%75%100%Percent spend
52 week high drop
Showing relative spend if 50% spent at: 10% drop from 52wk high

Caveats

Half spend drop

The chosen 52 week high drop to spend half of the set max is an important percentage to pick. At zero percent the algorithm will make a constant recurring max purchase. If the value of this drop is increased smaller purchases will be made during bullish periods relative to bearish periods.

Approach

The previous caveat is the reason why one would pick a low half spend drop for stocks you want to consistently invest in, even when prices are high. A high half spend drop would be appropriate for a stock you only want to purchase during low prices.

Min spend

Many stock exchanges do not allow minimum purchases below one dollar. The same is true in this algorithm; note a min spend of zero means some recurring purchases may not occur. If this is non-zero the algorithm will make a constant min spend purchase when the year high drop is less than a certain percentage.