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.
- 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
- download / pull the repo
- create sp_500_init.py file
- create the environment from the environment file
- activate the environment
- run the script
conda env create -f env_sp500.yml
Windows -> activate sp_500
Linux -> conda activate sP_500
python sp_500_init.py
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)
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