RiskPremium

Measuring the market risk premium
Log | Files | Refs

Makefile (2418B)


      1 #
      2 # Makefile for PREDICTING THE EQUITY RISK PREMIUM
      3 #
      4 # Julia rewrite — March 2026
      5 # --------------------------------------------------------------------------------------------------------
      6 
      7 SHELL := /bin/bash
      8 
      9 # --------------------------------------------------------------------------------------------------------
     10 # Pretty-printing
     11 define colorecho
     12 	@tput setaf 6
     13 	@echo $1
     14 	@tput sgr0
     15 endef
     16 
     17 WHITE := '\033[1;37m'
     18 NC    := '\033[0m'
     19 
     20 TIME_START := $(shell date +%s)
     21 define TIME-END
     22 	@time_end=`date +%s` ; \
     23 	time_exec=`awk -v "TS=${TIME_START}" -v "TE=$$time_end" 'BEGIN{TD=TE-TS;printf "%02dm:%02ds\n",TD/60,TD%60}'` ; \
     24 	echo -e \\t${WHITE}cumulative time elapsed ... $${time_exec} ... $@ ${NC}
     25 endef
     26 # --------------------------------------------------------------------------------------------------------
     27 
     28 ## --------------------------------------------------------------------------------------------------------
     29 ## ALL
     30 all: output/predict.csv readme.md
     31 
     32 ## COMPUTE CAY FROM FRED DATA
     33 input/cay_computed.csv: src/CAY.jl src/FredUtils.jl
     34 	$(call colorecho,"Construct cay from FRED data ...")
     35 	julia --project=. src/CAY.jl
     36 	@echo
     37 
     38 ## GENERATE PREDICTORS
     39 tmp/predict.csv: src/DataImport.jl src/FredUtils.jl input/cay_computed.csv output/msi.csv
     40 	$(call colorecho,"Import and merge all return predictors ...")
     41 	mkdir -p tmp
     42 	julia --project=. src/DataImport.jl
     43 	@echo
     44 
     45 ## RUN REGRESSIONS
     46 output/predict.csv: src/RiskPremium.jl tmp/predict.csv
     47 	$(call colorecho,"Estimate predictive regression ...")
     48 	julia --project=. src/RiskPremium.jl
     49 	@echo
     50 
     51 ## OUTPUT RESULTS
     52 readme.md: src/readme_input.txt output/predict.pdf tmp/reg_update.txt
     53 	$(call colorecho,"Update readme file ...")
     54 	cat src/readme_input.txt tmp/reg_update.txt > readme.md
     55 	@echo
     56 
     57 ## TEST: validate against R reference
     58 test: test/test_cay.jl test/test_dataimport.jl test/test_regression.jl
     59 	$(call colorecho,"Running validation tests ...")
     60 	julia --project=. test/test_dataimport.jl
     61 	julia --project=. test/test_regression.jl
     62 	@echo
     63 
     64 ## --------------------------------------------------------------------------------------------------------
     65 ## help (this call)
     66 .PHONY: help test clean
     67 help: Makefile
     68 	@sed -n 's/^##//p' $<
     69 
     70 ## clean
     71 clean:
     72 	rm -rf output/predict.csv output/predict.pdf
     73 	rm -rf log/*.log*
     74 	rm -rf tmp/*
     75 	rm -rf readme.md
     76 
     77 ## --------------------------------------------------------------------------------------------------------