Part 1: Background & Objectives
For the past few months, I have been gradually building an equities research system in Rails for my own trading. This is the first of a number of posts, as I go through the process.
My Trading philosophy
In the past couple years, I have spent a lot more time reading about trading strategies, and refining my understanding.
I have always used my technology understanding to make investment decisions which would normally do sometimes extremely well, but suffered from having a clear exit strategy. As a result, many of my gains evaporated before I was compelled to act; it happened to me during the 2000 technology bubble and it happened again recently with the 3D bubble. Buy and hold simply does not work, even if the sector will revolutionize the industry.
In reading up articles at Seeking alpha and other web sites, I eventually found references to books that seemed to make sense and one of them in particular – What works on Wall Street by James O’Shaughnessy – seemed to provide a foundation upon which I could build a trading strategy that would meet at least most of my criteria:
- It will be based on clear and quantifiable entry and exit criteria, proved by track record or at least back-testing
- It will outperform common market indexes, such as the S&P500 over a reasonable holding period, i.e. 3-5 years
- It will be possible to have downside protection
How O’Shaughnessy strategies satisfy my criteria
The O’Shaughnessy book describes the authors extensive backtesting of the ability of single key statistics to predict future price performance, as well as combination of several chosen factors. The statistics often cover more than 30 years of backtesting using the Compustat database, the most accurate but also very pricey database available. The performance of some strategies such as Value Composite 2 in conjunction with 6 month price performance exhibit excellent long term results. Unfortunately, a buy and hold strategy would not provide downside protection, and often some of the value strategies can have higher volatility than the market.
Value strategies sometimes can go against the market and your portfolio could be under-performing the market or worse yet could be losing money while everybody else is going up, making it difficult to stomach it. This is the reason according many value investor authors/managers why such strategies don’t get implemented by mutual funds. Asset managers are under constant pressure to produce, and investment boards are expecting active fund managers to beat the market at all times — I can attest to that having worked in Asset management firms for a number of years. At the same time, a number of researchers have measure mutual fund performance and have found that most active managers underperform the indexes, so what’s an investor to do? For my risk appetite, I decided that I wanted to invest some of the strategies described in the O’Shaughnessy book, and potentially enhance them.
Selecting an equity research system to implement O’Shaughnessy strategies — or do I have to build it?
I spent a fair amount looking at commercially available sites that provide stock screeners, or claim to have implemented some O’Shaughnessy screens, but they all suffered some limitation or another. In the end, I decided that with my technology knowledge of ruby on rails, I could probably build a system that would provide me with the necessary outputs and would also allow me to experiment and potentially modify the standard O’Shaughnessy screens. The limitation in my view were the following:
- Those sites with implemented screens did not have the functionality to allow implementation of complicated and procedural-based screeners. For example, the Value Composite 2 screen with six month price momentum could follow the following steps:
- Calculate the ranking for each of the five factors in the Value Composite
- Add rankings for each equity, and produce a single rank
- Select the top decile of stocks, and rank them according to 6 month price momentum
- Select the top 10/15/20/25 stocks according to the price momentum rank and hold for a year; sell your losses right before the year ends, and sell your gains right after the year ends.
- While most sites provide many key statistics like you would find at Yahoo Finance key statistics pages, they would not provide full financial statements to allow development of ad-hoc factors.
- Most of the popular sites register complaints about data accuracy/staleness. As staleness is very difficult to detect this could easily result in false buy or delayed sell signals — big problem. Those sites with the best data quality were very expensive and many will put a limit on the frequency and size of your queries. But using such sites for pulling data into Excel or your database should qualify more as building a system.
In the end, I decided that at the cost of the time spent, I would be better off building my own equity research system. My subsequent posts will describe my experiences in building my equity research system, as I work with a number of Ruby components, my data acquisition strategies from the Web and XBRL, and from tinkering with value/price-momentum strategies.