Choices. New widgets. New problems.

As you might have noticed by now, there are new versions of the Euro Stocks widget. The old (version 0.6) one has been entirely replaced by version 1.0, which doesn’t share any of the old code (except maybe for the update functionality). It’s been built from ground up. You might wonder why there no longer is an intraday option, why the stock codes have been changed and why the preferences are no longer global.

First, I would like to elaborate on the functionality of the original (0.6) Euro Stocks widget. I’ll break it up in two parts: the chart of the stocks’ performance (be it intraday or history) and the risers/fallers.

The chart of the 0.6 is pulled from an address of the following type (this is one for a historic chart):
http://charts.production.euronext.com/h_chart.html
?ISIN=NL0000303600
&ID_EXCHANGE=3
&QUALITY=DLY
&DISPLAY=1
&GRID=1
&PERIOD=4
&VOL=1
&SCALE=1
&SUPP_INFO=1

Now I’m not going into details (I guess you can figure them out for yourselves, as I did), but this one was easy to “reverse-engineer”. So I did and created version 0.5. To emphasize the point I’m making: this is just an image the widget pulls from a webserver.
The reason version 0.6 gives a lot of “Error in chart” for custom stocks, is because of the part “&ID_EXCHANGE=3”. Some stocks are listed at several indices with the same ISIN code. They can only be recognized from eachother by an extra identifier: the MEP code, which is 1 for PAR (Paris), 2 for AMS (Amsterdam), 3 for BRU (Brussels) and 5 for LIS (Lisbon) (don’t ask me why they skipped 4). Originally, the Euronext webpage would only give an “Error in chart” response when the ISIN code was actually listed at multiple indices, but not for single-listed stocks. Since a couple of months, it responded with an error for any custom ISIN code (except for the indices).

The Risers/Fallers however, are an entirely different story. What the widget does (in a nutshell) is get the webpage of the selected index by XMLHttpRequest, parse the responsetext to cut out the risers/fallers table, put that string into a hidden div so the HTML renderer recognizes the table (and nested tables) and then, by using a reference to the now recognized table nodes, cut out the risers table, respectively the fallers table and put both on their own div, allowing them to be hidden or shown.
Now, whether you understood (part of) the above or not, what it boils down to: the risers/fallers functionality of the 0.6 is entirely dependent on a consistent Euronext webpage. And guess what? It isn’t in time. So I either had the option to rewrite the explained functionality (particularly the “parse the responsetext to cut out the risers/fallers table”) or redesign the widget entirely.

So there I was, with two problems. One: showing a custom stock always resulted in “Error in chart”. Two: the need to update the widget every time the Euronext webpage changes to allow the risers/fallers to display.
Now, although I’m more than happy to make these widgets (I’m however not the least interested in stocks), I wasn’t planning on making it my daily business, keeping them updated on a regular basis.

The thing I needed to make a widget work the way I wanted it to (using up-to-date values, to draw a graph live in Dashboard) wasn’t found easy. That might be because I’m not “into” stocks. But after some looking around on the WWW I finally found what I needed at Yahoo! Finance. Downloadable lists of comma separated values (“csv’s”), of the current as well as historic rates.

I decided to entirely redo the design of the widget, with a user interface that would be “like” Apple’s (Quote’s) Stocks widget, but in my “words”. Now that’s exactly what version 1.0 has become. It lacks one major thing: intraday results. That is because I haven’t found a data source yet that offers intraday trading results on the internet for free. If you know one, let me know!

So the major difference, between 0.6 and 1.0, is the “live” drawn chart. In 0.6 it’s “only” an image, pulled from a Euronext webserver, but in 1.0, it’s a client-side created graph. This means that as long as I don’t find an intraday data source, the widget won’t incorporate an intraday chart. It just won’t. However, I’m almost ready to post the new Euro Stocks Chart, which will (still) feature an intraday chart, the custom ISIN codes will work again (allowing you to choose the index it is listed at), it will remember the last X custom ISIN codes and will allow you to open multiple instances of itself and remember the preferences for each of them.

So, what it comes down to: new widgets, new problems, still no absolute aggregate of all functions. Stay tuned.

Leave a Reply

Your email address will not be published. Required fields are marked *