In this article we look at how to calculate risk adjusted returns using the sharpe ratio. We look at some modern examples which you can try using the share ratio calculator.

- Sharpe Ratio Calculator
- What Is The Sharpe Ratio
- How To Calculate Sharpe Ratio
- What Is A Good Sharpe Ratio
- Sharpe Ratio Use Cases
- Sharpe Ratio Examples
- Sharpe vs Sortino Ratios [Video]
- Sharpe Ratio Code For Developers
- Conclusion

## Sharpe Ratio Calculator

This calculator uses the simplified Sharpe ratio as discussed here.

#### Possibilities

##### Success

Chances: %Return: $

##### Break Even

Chances: %Return: $

##### Failure

Chances: %Return: $

##### Expected Outcome

Return: $##### Result:

## What Is The Sharpe Ratio

The sharpe ratio is the most popular formula for calculating risk adjusted returns. The more risky an asset, the higher reward an investor should receive and the higher the sharpe ratio will be. A sharpe ratio greater than 1 is considered the baseline for a good investment.

## How To Calculate Sharpe Ratio

The full formula for calculating Sharpe ratio is:

SharpeRatio = (Expected Return – RiskFreeReturn) / SandardDeviationOfExpectedReturn

Risk free return is usually quoted as US treasury bills however with interest rates so low I tend to use a simplified version for quick calculations and assume risk free return is cash or zero.

Simplified Sharpe Ratio = Expected Return / Standard Deviation

So let’s look at an example. Elon Musk launches a new company doing teleportation holidays to Mars. We are interested in doing a momentum trade and holding the stock for one month.

The stock has been steadily climbing recently at around 20% / month for the last six months except for one month where it dropped 30% after /r/WallStreetBets got closed down

. Let’s first calculate the standard deviation.

Standard deviation is calculated by the square root of the average of the squared deviation from mean. That’s not intuitively worded I know so let’s look at the example

Jan +20%, Feb +20%, Mar -30%, Apr +20%, May +20%, June +20%

Calculate Mean (Average) = (20 +20 -30 +20 +20 +20) / 6 = 11.66 *Mean*

Now let’s calculate the distance from the mean for each figure and square it.

5 off 20 – 11.66 = 8.34 x 8.34 = 69.56

1 off -30 -11.66 = -41.66 x -41.66 = 1735.56

Now we need to take the square root of the average of these deviation totals. I’m really bad at doing square roots in my head so I tend to use Javascript.

Math.sqrt( ((69.56 * 5) + 1735.56) / 6 ) = 18.63 *Standard Deviation*

To calculate the expected return given the data available I would use 20% as the March result was seen as a black swan event. There could be a case for using the mean or average monthly growth as well. Calculating expected returns in real world examples can be ambiguous at best.

Let’s plug these numbers into the simplified sharpe ratio:

Simplified Sharpe Ratio = Expected Return / Standard Deviation

1.07 = 20 / 18.63

So our sharpe ratio is just over 1, but what does this mean?

## What Is A Good Sharpe Ratio

In the example above we got a sharpe ratio of just over 1 for an investment in Elon’s teleportation company. This would be seen as a worthy but not exceptional investment opportunity.

This is dynamic aligning to market conditions and other factors but as a rough rule of thumb:

Sharpe Ratio less than 1 | Not worth doing unless other factors are in play |

Sharpe Ratio of 1 | A good investment, healthy risk/reward |

Sharpe Ratio of 2 | Exceptional opportunity, time to bet big |

Sharpe Ratio of 3 | Mortgage the house and sell a kidney |

If we had used the average monthly return of 11.6 (the mean instead of the median) then our Sharpe ratio would have worked out at 0.625. This shows how much room for interpretation there is in the usage as it would then have been not worth doing.

The more you use the formula the more of a feel you’ll get for how accurate your data going in is and how different investments within a portfolio weigh up against each other.

## Sharpe Ratio Use Cases

I primarily use the sharpe ratio when looking at investments and rebalancing asset portfolios.

It can also be used to make better informed business decisions.

It can be used as an analysis tool in the same way as expected value is to do quick on the fly calculations.

An investor could weigh up their entire portfolio looking at the sharpe ratio and diversification of their assets to better allocate capital.

## Sharpe Ratio Examples

### Bitcoin Sharpe Ratio Q1 2021

Holding period: 8 years (two halving cycles)

Investment: 1 BTC @ $50k USD

Expected Return: $1m USD

Risk: 10% chance of losing the full -$50k

That $1m $BTC price is based on PlanB’s stock to flow model. I’m also going to cost in a 10% chance of it going to zero or losing the funds through a hack resulting in a $50k loss. This is just an example, don’t get mad if you love/hate crypto, the last example was a teleportation company.

So let’s calculate standard deviation first.

The mean return is 895000, ** 2 is Javascript ES6 square,

Math.sqrt( ((((1m – 895k) ** 2) * 9) + ((-50k – 895k) ** 2)) / 10 ) = 315000

Now let’s calculate the Sharpe ratio 1000000 / 315000= 3.17

If the admittedly questionable figures going in are to be believed then this is the investment of the century with a Sharpe ratio above 3.

### Tesla Sharpe Ratio Q1 2021

If I haven’t upset enough people already then let’s look at another example for Tesla stock. Same time frame.

Holding period: 8 years

Investment: $30k USD

Expected Return: $120k USD

Risk: 50% chance of break even

I’ve based this example on the upside of Tesla becoming the new Apple, dominating the car manufacturing sector and with the help of inflation quadrupling their market cap. Downside risk at 50% of breaking even over a 8 year period.

The mean return is $75k

Math.sqrt( (((120k – 75k) ** 2) + ((30k – 75k) ** 2)) / 2 ) = 45

Sharpe ratio = 120k / 45k = 2.6

Still a fantastic investment. Not surprising considering we are expecting it to quadruple in price with no real downside. Let’s look at a less speculative example.

### Corporate Bonds @ 4% APR

Holding period: 1 Year

Investment: $1000

Return: $40

Risk: default risk 1% @ -$1000

So a good quality corporate bond with a 1% risk of default which would cause the initial investment to be lost. $40 upside potential per $1000 invested.

Mean return is ((40 * 99) -1000) / 100 = 29.6

Standard deviation is Math.sqrt( ((((40 – 29.6) ** 2) * 99) + ((-1000 – 29.6) ** 2)) / 100 ) = 103.47

Sharpe ratio is 40 / 103.47 = 0.387

The risk to reward ratio just isn’t there for this investment. Maybe that’s why only the Fed money printer is buying corporate bonds currently.

## Sharpe vs Sortino

The Sortino ratio is a variation of the Sharpe ratio which only factors in downside risk. Using the Sharpe ratio to measure the effectiveness of financial investments can be misleading because a opportunity could have a lot of upside volatility but the downside is largely protected.

The Sortino ratio aims to improve upon the Sharpe ratios assessment by calculating the standard deviation only below the base line or the drawdown. This can either be zero which only count periods where the investment made a loss or a MAR (minimum accepted returns) baseline can be used in line with treasury bonds for example..

Which method is more effective depends on the situation and whether increased upside volatility should be considered a negative.

## Sharpe Ratio Code For Developers

Here’s a function I use in the calculator above to work out the sharpe ratio. It’s written in Javascript and will run in the browser or on node/deno.

```
const calcSharpeRatio = (expectedOutcome, possibleOutcomes) => {
let meanTotal = 0;
let chanceCount = 0;
possibleOutcomes.forEach((outcome) => {
meanTotal += outcome.result * outcome.chances;
chanceCount += outcome.chances;
});
const mean = meanTotal / chanceCount;
let deviations = 0;
possibleOutcomes.forEach((outcome) => {
const deviation = outcome.chances - mean;
const meanSqrd = deviation ** 2;
deviations += (meanSqrd * outcome.chances);
});
const stdDeviation = Math.sqrt(deviations / chanceCount);
const sharpeRatio = expectedOutcome / stdDeviation;
console.log('t1',mean,stdDeviation,sharpeRatio);
return sharpeRatio;
};
const possiblities = [
{ outcome: 'success', chances: 70, result: 250000 },
{ outcome: 'breakEven', chances: 20, result: 50000 },
{ outcome: 'failure', chances: 10, result: -50000 },
];
const expected = 250000;
const sharpeRatio = calcSharpeRatio(expected, possiblities);
```

And here is a code snippet for calculating the Sortino ratio using Javascript

```
const calcSortinoRatio = (returnArray) => {
const avgReturn = returnArray.reduce( ( a, b ) => a + b, 0 ) / returnArray.length;
const badDays = returnArray.map( p => Math.min( 0, p - 0 ) )
const badDaysSquared = badDays.map( p => Math.pow(p, 2) )
const badDaysSquaredAverage = badDaysSquared.reduce( ( a, b ) => a + b, 0 ) / badDaysSquared.length
const downsideDeviation = Math.sqrt(badDaysSquaredAverage)
return avgReturn / downsideDeviation;
}
```

## Conclusion

The Sharpe ratio provides a useful but by no means perfect method of analysing risk adjusted return. There are a lot of factors such as time frame that aren’t taken into account but when used with good data it can provide a good data point for investment decisions.

We’ve looked at some examples and gone through the formulas and code. Why not try using the calculator next time you are struggling with an investment or business decision.