# [R-SIG-Finance] Sharpe ratio in tseries

Jeff Ryan jeff.a.ryan at gmail.com
Mon Jun 15 16:10:16 CEST 2009

```Nandi,

Take a look at the functions in PerformanceAnalytics.

> library(PerformanceAnalytics)

Econometric tools for performance and risk analysis.
(c) 2004-2008 Peter Carl, Brian G. Peterson. License: GPL
http://braverock.com/R/

Attaching package: 'PerformanceAnalytics'

The following object(s) are masked from package:graphics :

legend

> ?SharpeRatio
> SharpeRatio
function (Ra, rf = 0)
{
Ra = checkData(Ra, method = "zoo")
Ra.excess = Return.excess(Ra, rf)
return(mean(Ra.excess)/sd(Ra.excess))
}
<environment: namespace:PerformanceAnalytics>

That and others should do what you are expecting.

HTH
Jeff

On Mon, Jun 15, 2009 at 9:01 AM, Subhrangshu Nandi<nands31 at gmail.com> wrote:
> I think I know the reason behind the difference. When a vector of returns
> (x) is passed to the function sharpe(tseries), it returns the sharpe of *
> diff(x)* and not *x*. I'm not sure why the function was constructed in this
> manner. Shouldnt the formula of annualized sharpe me Mean*Sqrt(253)/SD, for
> a daily return series?
> -Nandi
>
> On Mon, Jun 15, 2009 at 8:44 AM, Subhrangshu Nandi <nands31 at gmail.com>wrote:
>
>> Does anyone know what formula the function "sharpe" in package "tseries"
>> uses?If we have daily observations as follows:
>>
>> 1/2/2007 0 1/3/2007 -87.8269 1/4/2007 -214.031 1/5/2007 -295.833 1/8/2007
>> -125.284 1/9/2007 213.2553 1/10/2007 -106.514 1/11/2007 -298.365 1/12/2007
>> -333.594 1/15/2007 -61.0625 1/16/2007 -346.113 1/17/2007 -505.241 1/18/2007
>> 139.586 1/19/2007 -312.135 1/22/2007 -176.663 1/23/2007 -256.924 1/24/2007
>> -469.091 1/25/2007 -426.754 1/26/2007 -367.663 1/29/2007 -186.82 1/30/2007
>> -1257.42 1/31/2007 -411.755 1/2/2008 -1082.18 1/3/2008 -661.405 1/4/2008
>> 699.0845 1/7/2008 -1862.33 1/8/2008 -92.5218 1/9/2008 121.3522 1/10/2008
>> -505.142 1/11/2008 54.88142 1/14/2008 -208.322 1/15/2008 -324.522 1/16/2008
>> -157.523 1/17/2008 220.3509 1/18/2008 -419.522 1/21/2008 816.2032 1/22/2008
>> -5523.15 1/23/2008 -6.2435 1/24/2008 -2015.79 1/25/2008 -758.78 1/28/2008
>> -834.751 1/29/2008 -558.338 1/30/2008 -1736.82 1/31/2008 -939.335
>>
>> Mean -492.297 SD 960.0048
>> Annualized Sharpe should be Mean*sqrt(253)/SD = -8.1569. However, the
>> function "sharpe" yields -0.22784. Could anyone tell me what I am missing?
>>
>> Thanks,
>> -Nandi
>>
>> --
>> I'm a great believer in luck, and I find the harder I work the more I have
>> of it.  ~Thomas Jefferson
>>
>> Subhrangshu Nandi
>> Greater Chicago Area
>> Office:(312) 601-8096
>> EFax: (703) 852-7405
>>
>
>
>
> --
> I'm a great believer in luck, and I find the harder I work the more I have
> of it.  ~Thomas Jefferson
>
> Subhrangshu Nandi
> Greater Chicago Area
> Office:(312) 601-8096
> EFax: (703) 852-7405
>
>        [[alternative HTML version deleted]]
>
> _______________________________________________
> R-SIG-Finance at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only.
> -- If you want to post, subscribe first.
>

--
Jeffrey Ryan
jeffrey.ryan at insightalgo.com

ia: insight algorithmics
www.insightalgo.com

```