Category Archives: Yahoo Finance

Exploring pair trading opportunities with yahoo, python and LibreOffice

I have been reading two books about quantitative and algorithmic trading by Ernie Chan:

  • Quantitative Trading: How to Build Your Own…
  • Algorithmic Trading: Winning Strategies and…

See the books page for my reading recommendations.

One of the main take aways of this reading is the insight that it is possible to create stationary pairs by shorting and longing two, or more equities that usually move in tandem. The idea is to arbitrage the oscillating differences in moves between the equities in the pairs. Mr Chan explains all the mathematics behind mean reversion and provides Matlab code do the necessary calculus.
My approach to exploring this idea and the possibilities is far simpler and less elegant. Still, I think some might find it useful to see my take on it. I wrote a python script that pulls daily data from Yahoo and then calculates the ratios between two equities. With the resulting ratios data I continued my investigations in LibreOffice Calc. I like to use Calc to model my ideas and as they become more complicated or as I want to test more data sets I move the model over to code using Python and the pandas library.

Continue reading

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.

Continue reading