To chart the spread between 2-Year treasury yields and 10-Year treasury yields, please type the simple code listed below into your R console. That is all, carry on as you were.
require(quantmod)
getSymbols(c("DGS10", "DGS2"), src="FRED")
Ten_Two <- DGS10-DGS2
chartSeries(Ten_Two)
What source is FRED? Not familiar with it!
ReplyDeleteSt Louis Federal Reserve. http://research.stlouisfed.org/fred2/
ReplyDeletevery nice
ReplyDeleteIn 3 lines, with 2 fewer excursions to the Shift key. ;-)
ReplyDeleterequire(quantmod)
getSymbols("DGS10;DGS2",src="FRED")
chartSeries(DGS10-DGS2)
@Joshua Excellent refactor! Especially like getting rid of c() for getting multiple symbols on one line. Thanks.
ReplyDeleteHey Milk Trader,
ReplyDeleteBeen following your blog for a while and am also an R user. I've managed to program out a back-testing system that works to test strategies vs. one security showing a list of trades/entries/exits based on rules. My new problem is a) an efficient way to build an equity curve (my profits are calculated using Van Tharp's R Multiple), and b) an efficient way to combine the test for multiple securities and generate a composite equity curve. I wonder if you've found any methods for conducting this kind of test?
I've been chronicling my study over at http://techsystrader.blogspot.com. I'm fairly novice however my goal is to build a useful backtesting system in R.
@Jason I'll check out your blog. I do know that quantmod has a modeling function but I haven't used it yet. Likewise, I'm interested in using R for all this work instead of going to a proprietary system.
ReplyDelete