#EAv API Reflections
Last week, I finally got around to doing a little Empire Ave programming. I know that the new API is supposed to be coming out any day, but it should be similar to the current API and will hopefully just add some of the functionality that I’ve been currently missing. I’ve been doing my Empire Ave programming in shell scripts, PHP and Excel, and have yet to put together all the pieces. Hopefully, I will add some applications to my website for others to use when I make a little more progress, and I hope people with share their ideas and experiences with Empire Ave programming.
Years ago, I worked as a technology executive on Wall Street before moving over to being a social media manager, so the idea of Empire Avenue, and especially creating applications for it, is very appealing. I figured a good starting point would be some simple portfolio analytics. So, I got my API key, and started testing. The first call I tried was portfolio/base. It didn’t really provide much for information, so I moved over to portfolio/get, which provides much more information. (The geeky stuff is below the fold).
Currently, I’m using ticker, close, shares, your_shares_held, last_trade and yesterday_earnings. I dump these out into a CSV file which I pull into Excel to analyze. Here is where I get some of the issues. I currently have positions in 197 different stocks. However, the call only returns 100 stocks at a time, so I need to get two pages of stocks. If you don’t pass a parameter, it returns the first page. According to the documentation, I should be able to get a second page by adding &page=2 to the end of my query string. Unfortunately, in my first tests, I wasn’t properly adding the &page=2, so my initial analytics was really only of my first 100 stocks. I have subsequently fixed this and am now doing some interesting calculations.
There are a couple things missing from the portfolio. One is the dividends per stock. I checked around a bunch of different places, and couldn’t find any nice way to get it. Also missing is some sort of cost basis for the shares. Granted, this can be complicated for active trading, depending on the accounting method employed. It might be possible to create some sort of basis calculation based on history/shares request, and maybe I’ll create something like that at some point when I have a bunch of time.
So, I save this data to a CSV file which I bring into Excel and then run various calculations, such as which stocks have the best earnings based on the price and number of shares I have, which stocks are the biggest gainers in stock price, in value in my portfolio, or the biggest percentage gainers. Likewise, I found that my understanding of the earnings number was off, so my initial calculation favored stocks that I had small holdings of.
I’ve started using this to buy shares in stocks that I hope will be performing better than others. I used that for my recent Follow Friday post, and some subsequent purchases on Saturday and Sunday. I’ve also started analyzing other portfolios, such as (e)CHRISVOSS. This is a large portfolio with a lot of activity. Currently, I’m tracking over 1300 different stocks using this. I can also track to see what Chris has been buying and selling. Between Saturday and Sunday, according to the data I grabbed via the API, he sold thirty-five different stocks about bought 29 new ones. I also looked at the stocks he had bought which had high earnings relative to their prices. They were mostly fresh faces on Empire Avenue, and I picked up a few that looked most promising. Looking at my own portfolio, I found some people that were not performing very well that did not have holdings in me. I think they may have been people that invested in me a while ago, and then sold their shares. I’m starting to sell off some of these under performers.
I’ve also started building graphs of who owns what stocks. I gather positions from several different people to produce the graph and use GraphViz to produce the graph. (Check out this GraphViz images on Flickr as an example.) A problem with this is the limit to the number of requests you can send per hour, especially when graphing people who own a lot of stocks. My initial graph was made of a set of ten people who I have large holdings in and who do not have a lot of holdings in others. So, I may create other graphs that run slowly to gather large sets of data.
Another idea is to create an index, similar to the Dow Jones Industrial Index or the S&P 500. A question there would be how to best determine who should be in what indices. One test that I did was to look at the average price and earnings of a selection of people that (e)CHRISVOSS has invested in, based on my earlier portfolio tests. As an example, I came up, I noticed that for a set of stocks that he held on both Friday and Saturday, the average price was up from 57.28 to 57.81, while the average earnings were down from 428.08 to 396.16. As a result, the average Price/Earnings ratio declined from 7.47 to 6.85. This index is a very broad index, more like the S&P 500 or the Russell 2000, than the DJI. There is a bit more work to be done on the indices.
There are also PUT requests to buy and sell stocks, so if I ever got really ambitious, I could create an automated trading system, however, that would be really complicated and I’m not sure there is enough volume on Empire Avenue to make it worth it.
That’s my current work in Empire Avenue programming. You can download some recent data about my portfolio here. Let me know your thoughts about Empire Avenue programming or interesting things to do with it.