Economic events

Category : Uncategorized

Economic events

Please make sure you have the most updated mfd_dm and mfd_ta packages for Stata installed for this post.

*
net from "http://www.researchforprofit.com/stata/mfd_dm"
net from "http://www.researchforprofit.com/stata/mfd_ta"
* click on the blue mfd_dm package and then "click here to install" 
*

Economic data is released everyday. This code downloads the data and puts them on a chart.

*
clear all
cd "/Users/mfd/Desktop"

erase economic_events.dta
forval aa=1/41 {
	di "`aa'"
	if (`aa'<10) mfd_dm_events, week (20130`aa')
	if (`aa'>=10) mfd_dm_events, week (2013`aa')
	capture: append using economic_events.dta
	save economic_events.dta, replace
}

replace date=date+",2013"
gen date_=date(date,"MDY",2050)
format %td date_
drop date
rename date_ date
sort date

split time, parse(:) gen(temp)
split temp2, gen(Temp)

rename temp1 hour
destring hour, replace

rename Temp1 minute
destring minute, replace

replace hour=hour+12 if Temp2=="PM"

drop time temp2 Temp2
order date hour minute
sort date hour minute

keep if statistic=="Initial Claims" | statistic=="Unemployment Rate" | statistic=="Mich Sentiment"

drop if strlen(actual)<4
keep for actual date statistic

replace actual=subinstr(actual,"K","",.)
replace actual=subinstr(actual,"%","",.)

destring actual, replace force

mfd_dm_prices DIA, freq(d) start(01jan2013) merge

gen actual_IC=adjclose_DIA if actual!=. & statistic=="Initial Claims"
gen actual_UR=adjclose_DIA if actual!=. & statistic=="Unemployment Rate"
gen actual_MS=adjclose_DIA if actual!=. & statistic=="Mich Sentiment"

twoway (line adjclose_DIA date) (scatter actual_IC date if statistic=="Initial Claims", mlabel(actual)), scale(0.75) 
twoway (line adjclose_DIA date) (scatter actual_UR date if statistic=="Unemployment Rate", mlabel(actual)), scale(0.75)
twoway (line adjclose_DIA date) (scatter actual_MS date if statistic=="Mich Sentiment", mlabel(actual)), scale(0.75)
*

events_MS