Skip to content

Uses simple moving averages to predict when to enter and leave the market using the SP500.

Notifications You must be signed in to change notification settings

carvetighter/SP500

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SP500 Moving Average (SMA) Analysis

This analysis pulls data for the SP500 (since inception) and conducts a moving average analysis to indicate when to get in and out of the market. The goal of this analysis is to "get out of the way" of the long downward trends and stay in as long as the market is going up.

Requirements

  • SQL Server Database locally (install prior to running script)
  • internet connection (to get the SP500)
  • Anaconda Python distribuiton
  • you will have to modify the code access the SQL Server database and tables; this can be done in the base class

Running the python script

  1. download / pull the repo
  2. create sp_500_init.py file
  3. create the environment from the environment file
  4. activate the environment
  5. run the script

Create the Environment

conda env create -f env_sp500.yml

Activate Environment

Windows -> activate sp_500
Linux -> conda activate sP_500

Run Script

python sp_500_init.py

Example sp_500_init.py file

Below is an example of the init file you will need to create. This file will define the user name and password for the SQL Server locally. Replace <sql_server_user_name> and <password> with the user name and password for the SQL Server.

'''
This is the initial file which is not tracked in git.
Calls the main method in sp_500_main.py
'''

from sp_500_class import main_class

if __name__ == '__main__':
    list_sql_up = [r'<sql_server_user_name>', r'<password>']
    main_class(list_sql_up)

Example Image

Performance

start date -> 01 January 1995
end date -> 26 July 2019
start amount -> $3,000
end date status -> In the Market
buy and hold result -> $19,772
this method results -> $24,028

About

Uses simple moving averages to predict when to enter and leave the market using the SP500.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages