As someone commented yesterday, my blog recently has mostly been movies reviews. There are three reasons for this:
- We've suddenly had a glut of good movies to go and see (well movies we wanted to go and see, even if some disappointed).
- I've been ill. Not severely most of the time, but enough that I've been working slowly and taking it gently to make sure I get well
- I've been involved in a project that has taken a fair amount of time to polish off.
That project is pictured above. Melanie Swan commissioned a "solid histogram in Second Life to show stock market prices" and I (finally) delivered. There will be a fuller write up of the technical details on my main website soon - I'm going to be developing this, with her continued support, into a more generally usable tool for plotting histograms, and once that's ready, the main website as well as the blog will gain some new pages.
There are some nice bits to point out here though. The script in SL pings a web-server every minute. That server scrapes both the google stock market data for current prices, and the yahoo pages for historical prices, does some fancy footwork and returns the values to be plotted. The script takes that return and converts into these bars. In case, like me, you don't follow stock-markets, the top of each bar is the highest trading price each day, the bottom the lowest trading price. The colour indicates if the overall value rose or fell. The final column (on the right in the image) is a little different - that is today's values, and you can see a little red blip on the edge of it. That is actually a "sleeve" which shows the variation from the opening price to the current price on the same basis, giving you some real time data.
In addition, if you want to see different stocks displayed, you can touch the histogram, say the name of the stock and it will display that stock price for 5 minutes before reverting to the default stocks. (This will only work correctly if the yahoo and google ticker symbols are the same.)
The twiddles? Well the sleeve changed what was displayed part way through, and required some reworking. Displaying data for "today" when the markets were closed was interesting. Displaying nothing before the markets opened proved relatively easy. However, at some point after the markets close, yahoo updates its page to include "earlier today" into the historical data. Working that out to have the google pages input suppressed and the yahoo pages historical data shown hit a couple of bugs and has a relatively ugly, but working, hack in there.
I describe this histogram as 2.5D (a mathematician I spoke to described it as 5D). The height of the bars, and their left-right position are signficant, as are their colours, giving you two spatial dimensions and a 0.5 for colour. One obvious, and hopefully soon to be implemented addition will be to add a third dimension to the bars... their depth, to display additional data (open and close values in the stock-market for example).
Following that, the whole lot will be adapted to make it relatively easy to read data from a notecard, or from a scraper that you write (so there will be a "plotter script" and a "data provider script" that can be changed to suit your needs. Melanie has already made the stock-market histogram freely available as open source from her offices in Second Life. As these additional tools come along, they will also be open sourced and available from Melanie.