楼主: oliyiyi
1148 1

A Return.Portfolio Wrapper to Automate Harry Long Seeking Alpha Backtests [推广有奖]

版主

已卖:2994份资源

泰斗

1%

还不是VIP/贵宾

-

TA的文库  其他...

计量文库

威望
7
论坛币
84105 个
通用积分
31671.0967
学术水平
1454 点
热心指数
1573 点
信用等级
1364 点
经验
384134 点
帖子
9629
精华
66
在线时间
5508 小时
注册时间
2007-5-21
最后登录
2025-7-8

初级学术勋章 初级热心勋章 初级信用勋章 中级信用勋章 中级学术勋章 中级热心勋章 高级热心勋章 高级学术勋章 高级信用勋章 特级热心勋章 特级学术勋章 特级信用勋章

楼主
oliyiyi 发表于 2016-6-19 07:27:31 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币


(This article was first published on R – QuantStrat TradeR, and kindly contributed to R-bloggers)

This post will cover a function to simplify creating Harry Long type rebalancing strategies from SeekingAlpha for interested readers. As Harry Long has stated, most, if not all of his strategies are more for demonstrative purposes rather than actual recommended investments.

So, since Harry Long has been posting some more articles on Seeknig Alpha, I’ve had a reader or two ask me to analyze his strategies (again). Instead of doing that, however, I’ll simply put this tool here, which is a wrapper that automates the acquisition of data and simulates portfolio rebalancing with one line of code.

Here’s the tool.

require(quantmod) require(PerformanceAnalytics) require(downloader)  LongSeeker <- function(symbols, weights, rebalance_on = "years",                         displayStats = TRUE, outputReturns = FALSE) {   getSymbols(symbols, src='yahoo', from = '1990-01-01')   prices <- list()   for(i in 1:length(symbols)) {     if(symbols == "ZIV") {       download("https://www.dropbox.com/s/jk3ortdyru4sg4n/ZIVlong.TXT", destfile="ziv.txt")       ziv <- xts(read.zoo("ziv.txt", header=TRUE, sep=",", format="%Y-%m-%d"))       prices[] <- Cl(ziv)     } else if (symbols == "VXX") {       download("https://dl.dropboxusercontent.com/s/950x55x7jtm9x2q/VXXlong.TXT",                 destfile="vxx.txt")       vxx <- xts(read.zoo("vxx.txt", header=TRUE, sep=",", format="%Y-%m-%d"))       prices[] <- Cl(vxx)     }     else {       prices[] <- Ad(get(symbols))     }   }   prices <- do.call(cbind, prices)   prices <- na.locf(prices)   returns <- na.omit(Return.calculate(prices))      returns$zeroes <- 0   weights <- c(weights, 1-sum(weights))   stratReturns <- Return.portfolio(R = returns, weights = weights, rebalance_on = rebalance_on)      if(displayStats) {     stats <- rbind(table.AnnualizedReturns(stratReturns), maxDrawdown(stratReturns), CalmarRatio(stratReturns))     rownames(stats)[4] <- "Max Drawdown"     print(stats)     charts.PerformanceSummary(stratReturns)   }      if(outputReturns) {     return(stratReturns)   } }  

It fetches the data for you (usually from Yahoo, but a big thank you to Mr. Helumth Vollmeier in the case of ZIV and VXX), and has the option of either simply displaying an equity curve and some statistics (CAGR, annualized standard dev, Sharpe, max Drawdown, Calmar), or giving you the return stream as an output if you wish to do more analysis in R.

Here’s an example of simply getting the statistics, with an 80% XLP/SPLV (they’re more or less interchangeable) and 20% TMF (aka 60% TLT, so an 80/60 portfolio), from one of Harry Long’s articles.

LongSeeker(c("XLP", "TLT"), c(.8, .6))

Statistics:

                            portfolio.returns Annualized Return                 0.1321000 Annualized Std Dev                0.1122000 Annualized Sharpe (Rf=0%)         1.1782000 Max Drawdown                      0.2330366 Calmar Ratio                      0.5670285

Equity curve:

Nothing out of the ordinary of what we might expect from a balanced equity/bonds portfolio. Generally does well, has its largest drawdown in the financial crisis, and some other bumps in the road, but overall, I’d think a fairly vanilla “set it and forget it” sort of thing.

And here would be the way to get the stream of individual daily returns, assuming you wanted to rebalance these two instruments weekly, instead of yearly (as is the default).

tmp <- LongSeeker(c("XLP", "TLT"), c(.8, .6), rebalance_on="weeks",                     displayStats = FALSE, outputReturns = TRUE)
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:Portfolio backtest Portfoli Seeking RETURN interested published function posting creating

缺少币币的网友请访问有奖回帖集合
https://bbs.pinggu.org/thread-3990750-1-1.html

沙发
hjtoh 发表于 2016-6-19 07:55:52 来自手机
oliyiyi 发表于 2016-6-19 07:27
(This article was first published on R – QuantStrat TradeR, and kindly contributed to R-blogger ...
好的楼主

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注jltj
拉您入交流群
GMT+8, 2025-12-27 01:10