Bash script calculating sharpratios on Yahoo Finance data

For one of my trading projects I am looking to calculate something called sharpratio for pricing of an equity over time. This can be done in a spreadsheet, but this becomes a bit laborious as I want to do this for more than 1000 of data sets. So I set out to write a bash script that calculates the sharp ratio on any given price data set from Yahoo Finance. If you are interested in how I use this as part of a trading strategy. I will be posting there shortly on how I intend to use the below code as part of the trading strategy I use. More info on the theory of sharp ratio can be found here.

Here is what the code does:
It reads in a price data file that you can get from Yahoo Finance. The script will run through the file and will calculate the price difference for each trading day from adjusted close to adjusted close the other day. It will also calculate the absolute return made since the starting date of the data set. Then at the end, it will calculate the average of the daily differences, the standard deviation of these differences and finally the sharp ratio over the set of data.

Popular post

Which Forex Pairs are Generally Trending and Which Ones Tend to Revert to the Mean

Build more wealth with gold

Get links to data referenced by