Last active
December 21, 2015 04:39
-
-
Save mbusigin/6250782 to your computer and use it in GitHub Desktop.
30s, 20s and LTGOVTBD don't have a contiguous series. This piece of code merges the three in that order of preference. Potential improvement - estimate term premium to have consistent constant maturity of 30y.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mergeLongEnd = function() | |
{ | |
if ( exists("DGS20") == FALSE ) { getSymbols("DGS20", src="FRED") } | |
if ( exists("DGS30") == FALSE ) { getSymbols("DGS30", src="FRED") } | |
if ( exists("LTGOVTBD") == FALSE ) { getSymbols("LTGOVTBD", src="FRED") } | |
a = merge(DGS30, LTGOVTBD, DGS20) | |
a$s = a$DGS30 | |
a$s[is.na(a$s)] = a$DGS20[is.na(a$s)] | |
a$s[is.na(a$s)] = a$LTGOVTBD[is.na(a$s)] | |
return(a$s) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment