找回密码
 注册
查看: 1875|回复: 0

R语言 ttrTests包 ttrTests-package()函数中文帮助文档(中英文对照)

[复制链接]
发表于 2012-10-1 12:51:12 | 显示全部楼层 |阅读模式
ttrTests-package(ttrTests)
ttrTests-package()所属R语言包:ttrTests

                                         A series of tests for the efficacy of a technical trading rule (TTR)
                                         一系列的测试技术交易规则的疗效(TTR)

                                         译者:生物统计家园网 机器人LoveR

描述----------Description----------

Contains five major tests supported by other functions: Did the TTR strategy outperform a benchmark in the past data?  Is the excess return significant, using bootstrapping to construct a confidence interval?  Is the excess return explained by data snooping? Is the 'good' choice of parameters robust across sub-samples?  Is this robustness significant, using bootstrapping to construct a confidence interval?
包含5个主要测试的其他功能:支持TTR战略超越的基准,在过去的数据吗?是的超额收益显着,使用自举构造一个置信区间?数据探测的解释是多余的回报?强大的跨子样本的参数是“好”的选择吗?这是鲁棒性显着,使用自举构造一个置信区间?


Details

详细信息----------Details----------

</table>  First, data should be a univariate time series 'x'.  Attempts have been made to accomodate 'High-Low-Close' data by coercing it into a univariate 'close' series, but stability of this behavior is not gauranteed.
</ TABLE>首先,数据应该是一个单变量时间序列的“X”。已尝试强迫到一个单变量“关闭”系列,以适应“高 - 低 - 关闭”数据,但这种行为是不gauranteed稳定。

All computations basically take place on the return series, diff(log(x)) So it is assumed that the data x is such that this return series is stationary, a common assumption for financial data.
基本上所有的计算的收益率序列差异(对数(X)),因此,它假设数据X是这样的,这回序列是平稳的,一个共同的假设的财务数据。

Second, a TTR should be any function whose input is the data 'x'and a list of parameters, and whose output is a ternary trading rule, i.e. 1 for 'long', -1 for 'short', and 0 for neither.  Built in TTR functions have this behavior, and any user defined function with this behavior is accepted.
其次,TTR应该是的数据“xand,输入的参数列表,其输出是一个三元交易规则,即1”短“为”长“,-1,0,既不任何功能。内置在TTR功能有这种行为,任何用户定义的函数,接受这种行为。

USER PROVIDED TTR FUNCTIONS MUST HAVE THE FOLLOWING FORM:
用户提供的TTR的功能必须有以下形式:

ttr <- function ( x , params , burn , short)
TTR < - 函数(X,PARAMS,烧伤,短)

Where x is the data, params is a numeric vector of parameters, burn is an integer describing the 'burn' period, and short is logical.  The function need not use these, but they must accept them.
其中x是数据,params是一个数字的参数向量,烧伤是一个整数来描述“烧钱”期间,短是逻辑。该函数不需要使用这些方法,但他们必须接受他们。

PLEASE SEE THE EXAMPLES IF YOU ARE GETTING ERRORS!
请参考下面的例子,如果你得到错误!

Now, the major functions of the package:
现在,主要的功能的软件包:

1) returnStats(x,ttr) compares the performance of the TTR with some benchmark.  A ttr that had good past performance might merit further study.
1)returnStats(X,TTR)TTR的一些基准的性能进行比较。一个的TTR,有良好的过往表现可能值得进一步研究。

2) nullModel(x,ttr) constructs a confidence interval for this performance and gives a p-value for the excess return observed in (1).  If the TTR fails  this test (i.e. p-value too high), it means that the good performance was  just as likely due to luck in how the data was constructed.
2),nullModel(X,TTR)构造一个置信区间,这样的表现,并给出了p值观察(1)中的超额收益。 TTR如果未能做到这一点(即p值过高),这意味着不错的表现可能只是由于运气的数据是如何构建的。

3) dataSnoop(x,ttr) constructs a p-value for the 'best' choice of parameters within a given domain (preferably large). If a TTR fails this test, it means that good performance was just as likely due to luck in picking a choice of parameters.
3)dataSnoop(X,TTR)构建了一个p值的“最佳”选择的参数在一个给定的域名(最好是大型的)。 TTR如果未能做到这一点,这意味着,性能良好,只是可能由于运气在挑选参数的选择。

4) subperiods(x,ttr) asks whether or not good choices of parameters were robust across different time periods.  This is a new type of 'out-of- sample' confirmation introuduced by the author in 2010.
4)subperiods(X,TTR)询问是否强劲的参数在不同的时间段不错的选择。这是一个新的类型“由作者在2010年的样本确认introuduced。

5) paramPersist(x,ttr) tests if the persistence measure from subperiods() is statistically significant.  It constructs an asymptotically valid p-value for the observed persistence, assuming that the true correlation is zero. If this test fails (i.e. p-value too high), it means that regardless of how significant the performance of a TTR was, no choice of parameters  performed consistently well over time.
5)paramPersist(X,TTR)的持久性措施,从subperiods()的测试,如果是统计上显着的。渐近构造一个有效的所观察到的持久性的p-值,假设真实的相关性是零。如果此测试失败(即p值过高),这意味着,无论显着的性能的TTR,没有选择的参数随着时间的推移表现一贯良好。

Version >= 1.1 allows the results of these tests to be written to a file in LaTeX code as a figure.  It also includes two tests for data snooping, White's Reality Check and Hansen's test for Superior Predictive Ability, the later not included in the first version.  
版本> = 1.1允许这些测试的结果被写入到LaTeX代码中的一个文件作为数字。它还包括两个测试数据探测,白色的现实检查和汉森的高级预测能力测试,不包括在第一个版本。

Version >= 1.2 fixes some minor glitches in 1.1.
版本> = 1.2修复了一些小故障1.1。

Version >= 1.3 uses a different algorithm to compute the statistical significance of the observed correlation from test (4).  Some new functions have been added to accomplish this.  An option for the position/indicator functions was added to increase flexibility.  Other minor changes here and there.
版本> = 1.3使用不同的算法来计算从试验(4)所观察到的相关性的统计意义。已添加了一些新的功能做到这一点。选项的位置/指示灯功能的加入,以增加灵活性。其他小的改动,在这里和那里。

Version >= 1.4 fixes some minor glitches in 1.3
版本> = 1.4修复了一些小故障130

Version >= 1.5 fixes some major glitches in 1.4, now producing correct results for some tests that were behaving questionably, and with much more accurate p-values based on bootstrapping.
版本> = 1.5修复了一些主要的故障在1.4,现在正确的结果了一些测试,举止可疑,更准确的p值的基础上的引导。

Version >= 1.6 allows the user to pass the 'restrict' option to the dataSnoop test.  Absence of this feature made it impossible for the user to use the 'restrict' option for a user defined ttr.  Also a small glitch in cating the results of dataSnoop was fixed, and a relatively serious error in paramStats was corrected to allow it to run with rules using fewer than 4 parameters.
版本> = 1.6允许用户通过限制选项的dataSnoop测试。无此功能使用户不可能使用一个用户定义的TTR限制选项。另外一个小毛刺在cating的结果dataSnoop是固定的,在paramStats一个比较严重的错误被纠正,以允许它运行规则使用参数少于4个。

Version >= 1.7 has new examples, a new data set, and minor  changes to the documentation.
> = 1.7有新的例子,一个新的数据集,小的改动的文档。


注意----------Note----------

EXTREMELY IMPORTANT NOTE: The functions in this package evaluate past  performance only.  No warranty is made that the results of these tests should,  or even can, be used to inform business decisions or make predictions of  future events.  
非常重要的注意:这个包中的功能评估过去的表现。这些测试的结果,甚至是可以被用来通知商业决策或做出对未来事件的预测,作出任何保证。

The author does not make any claim that any results will predict future  performance.  No such prediction is made directly or implied by the outputs of  these function, and any attempt to use these function for such prediction is done  solely at the risk of the end user.
作者并没有提出任何申索任何结果,预测未来的表现。没有这样的预测是由直接或暗示的这些函数的输出,和使用这些功能,这样的预测的任何企图仅在最终用户的风险。

Please note that Dr. Halbert White owns U.S. patents 6,088,676 and  5,893,069, pertaining to the RC option for the function dataSnoop().   These routines are licensed to the author for use solely for the purposes of non-commercial academic research and study. License rights as granted in the GPL are therefore limited to uses that are legal under national and international patent law. Future contributers, as defined in the GPL, assume full responsibility for their modifications and implementations.
请注意,哈尔伯特白博士拥有美国专利6088676和5893069,有关的的功能dataSnoop()的RC选项。这些的例程被授权作者专供非商业的学术研究和学习的目的。因此,在GPL许可权授予有限的用途,是根据国家法律和国际专利法。未来的贡献者,在GPL定义他们的修改和实施,承担全部责任。

If there is any doubt, please remove code that implements the reality check and enjoy the rest of the package.  There should be very minimal loss of functionality, if any, since a second data snooping test is included.
如果有任何疑问,请删除代码实现的现实检查和享受截断的包。应该有很小的损失的功能,如果没有,包括自第二数据侦听测试。


(作者)----------Author(s)----------



David St John


Maintainer: David St John &lt;dstjohn@math.uic.edu&gt;




参考文献----------References----------

[1]Sidney S. Alexander. Price movements in speculative markets: Trends or random walks. Industrial Managment Review, 2(2):7-26, 1961.
[2] David R. Aronson. Evindence Based Technical Analysis. John Wiley and Sons, 2007.
[3] William Brock, Josef Lakonishok, and Blake LeBaron. Simple technical trading rules and the stochastic properties of stock returns. The Journal of Finance, 47(5):1731-1764, 1992.
[4] David P. Brown and Robert H. Jennings. On technical analysis. The Review of Financial Studies, 2(4):527-551, 1989.
[5] B. Efron. Bootstrap methods: Another look at the jackknife. The Annals of Statistics, 7(1):1-26, 1979.
[6] Eugene F. Fama and Marshall E. Blume. Filter rules and stock market trading. The Journal of Business, 39(1):226-241, 1966.
[7] John Hull. Futures, Options, and Other Derivatives. Prentice Hall, 2006.
[8] Kenneth A. Kavajecz and Elizabeth R. Odders-White. Technical analysis and liquidity provision. The Review of Financial Studies, 17(4):1043- 1071, 2004.
[9] Richard M. Levich and Lee R. Thomas. The significance of technical trading rule profits in the foreign exchance markets: A bootstrap approach. 1991.
[10] Christopher Neely, Paul Weller, and Rob Dittmar. Is technical analysis in the foreign exchange market profitable? a genetic programming approach. The Journal of Financial and Quantitative Analysis, 32(4):405- 426, 1997.
[11] Gary Norden. Technical Analysis and the Active Trader. McGraw - Hill, 2006.
[12] Min Qi and Yangru Wu. Technical trading rule profitability, data snooping, and reality check: Evidence from the foreign exchange market. Journal of Money, Credit, and Banking, 38(8):2135-2158, 2006.
[13] Mark J. Ready. Profits from technical trading rules. Financial Managment, 31(3):43-61, 2002.
[14] Halbert White.  A Reality Check for Data Snooping.  Econometrica, 68, 2000, pp1097-1126.
[15] Ryan Sullivan, Allan Timmermann, and Halbert White. Data snooping, technical trading rule performance, and the bootstrap. The Journal of Finance, 54(5):1647-1691, 1999.
[16] Jack L. Treynor and Robert Ferguson. In defense of technical analysis. The Journal of Finance, 40(3):757-773, 1985.
[17] David St John.  Technical Analysis based on Moving Average Convergence and Divergence.  Phd thesis, University of Illinois, Chicago.  2010. http://math.uic.edu/~dstjohn/thesis.pdf

实例----------Examples----------



data(spData)

## First and foremost your ttr is a function.[#首先你的TTR的是一个功能。]
## Call your ttr anything you like and use any defaults you like[#打检测给你的TTR任何你喜欢的,使用任何你喜欢的默认值]
## (they're ultimately irrelevant) but you must use[(他们最终不相关的),但你必须使用]
## 'x', 'params', 'burn', and 'short' exactly![#X,参数,烧,和短完全相同!]

myTTR <- function(x, params=c(3,7,5), burn=0, short=TRUE)
{

crystalBall <- rexp(length(x),rate=1/params[3])

## note that there are no 'fixed' values used[#注意有没有“固定”值]
## the output must depend explicitly on the input[#必须依靠明确的输入输出]

position <- ifelse(crystalBall<=params[1],-1,0) +
ifelse(crystalBall>=params[2],1,0)

## the output will be a vector with values {1,0,-1}[#输出将是一个向量,其值{1,0,-1}]
## interpreted as long, neutral, short, respectively[#长的,中性的,短的,分别解释为]
## it should have the same length as the data[#它应该具有相同的长度,作为数据]

return(position)
}

## I know it's quirky, but when using your ttr, you have to include [#我知道这是有点诡异,但是当使用您的TTR,你必须包括]
## values for params (or start, nSteps, stepSize where needed), [值PARAMS(或开始,nSteps,需要的地方STEPSIZE)的,]
## burn, and short for all of the following calls.  No defaults [#燃烧,下面的调用。没有默认值]
## will be used, and you will get an error if you exclude them[#将被使用,你会得到一个错误,如果你排除]

stat <- returnStats(spData, ttr=myTTR, params=c(3,7,5),burn=0,short=TRUE)

## Witness the amazing predictive power of my crystalBall![见证了惊人的预测我的crystalBall的!]
## Go ahead and run returnStats over and over![#转到提前和运行returnStats,一遍又一遍的!]
## We see a positive excess return every time![#我们看到了一个正的超额收益每一次!]
## Man I am such a good fund manager[#我这样一个优秀的基金经理人]

null <- nullModel(spData,ttr=myTTR,params=c(3,7,5),burn=0,short=TRUE,bSamples=5)
spa <- dataSnoop(spData,ttr=myTTR,start=c(3,7,5),nSteps=c(3,3,3),
stepSize=c(1,1,1),burn=0,short=TRUE,restrict=TRUE,bSamples=3)
pp <- paramPersist(spData,ttr=myTTR,start=c(3,7,5),nSteps=c(3,3,3),
stepSize=c(1,1,1),burn=0,short=TRUE,restrict=TRUE,bSamples=3)

## Sorry, for those who missed the joke, myTTR decides to be long, short, or[#很抱歉,对于那些谁错过了玩笑,myTTR决定是很长的,短的,或]
## neutral completely at random according to a disribution specified by[#完全根据指定一个分布看,在随机中性]
## the input parameters.  Since the benchmark returns were negative, and[#输入参数。由于基准回报率分别为负,]
## the 'strategy' is short or neutral some of the time, it outperforms[#“战略”是短期或中性一些的时候,它优于]
## as expected, but with no real predictive power[#如预期,但没有真正的预测能力]

###########################################################[################################################## ########]

## Here's an example of another user defined ttr that will work:[#下面是一个例子,另一个用户定义的TTR,将工作:]

twoSMA<-function(x,params=c(20,30),burn = 0, short = FALSE)
{
mac2<-SMA(x,params[2])-SMA(x,params[1])
mac2[is.na(mac2)]<-0
sig<-ifelse(mac2>0,1,0)
return(sig)
}

## This one is based on some actual technical analysis...[#这个是基于一些实际的技术分析...]
## not that that guarantees it will do much better than my crystalBall[#,保证会做的更好,比我crystalBall]

转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。


注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
回复

使用道具 举报

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

本版积分规则

手机版|小黑屋|生物统计家园 网站价格

GMT+8, 2024-11-29 00:41 , Processed in 0.024969 second(s), 15 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表