Create stock charts based on Yahoo!Finance? Piece of cake!

We needed to build a dynamic chart with some historical stocks data showing a daily performance of individual stocks, indices, and portfolio. HighStocks js lib was chosen, and Yahoo!Finance was used to get historical EOD data for NASDAQ stocks to minimise support costs for the client.

For quick and easy development all the info about stocks and asset allocation was stored in the settings .ini files. According to the settings file, data was collected from http://ichart.finance.yahoo.com in CSV. Resulting files were really easy to parse, and the community in the face of StackOverflow already took care of the detailed description of the format of the query string data. The resulting data were stored in the database and loaded into a chart using Ajax.

Major problems in the course of development were associated with features of both “basic” solutions.

Highcharts.com provides a high-quality instrument with a lot of flexible settings and nuances. In particular, to implement controls, “the emergence / hide” stock charting had to introduce an artificial delay in the generation of controllers, as the chart takes some time from the transfer of the data series (Ajax) until the opportunity to address this series through the chart.

While hosted on a test server 1.5 seconds were enough, on the production server – 2.5 seconds. However, visually (on output) graphics appeared ahead of time. Addressing lots of charts without setTimeout resulted in random responses under the same conditions, that clearly indicates the formation of certain process data within the chart.

It should be noted that the final decision had to be localised into Russian. This was not an issue as well as chart styling.

Initially, it was given a set of 387 stock symbols using which a chart had to be built. Unfortunately, Yahoo!Finance was unable to provide all the required data. Information on part of the shares (48 pieces) simply did not exist. And the rate of occurrence of these data availability is worthy of special mention. Getting EOD data from the previous day next morning was not possible.

Our monitoring of the data showed its gradual appearance. In some cases, the entire dataset had to wait upto 3 (!) days before data became available on Yahoo!. Thus displaying portfolio performance had to do a background check on the completeness of the source data.

Upon completion of the debugging period, the service is functioning with delays in providing daily data. The system is configured in such way that in the absence of all or part of the necessary data on Yahoo!, chart updates can be delayed up to 10 days to “meet” national holidays and any other reasons of data absence.