Wednesday, September 21, 2011

Version 1.1.1 (stable) of the Time2 Library released

A new version of the Time2 Library is available at http://time2.sourceforge.net/ and http://agent.ch/timeseries/t2/.

This release brings improved time comparisons. Previously it was not possible to compare times from different domains. Now, when domain differs, times are converted automatically.

When resolutions differ, the time with the lowest resolution is converted to the one with the highest resolution. For example comparing a Day to a Year will compare the day to the implicit default day of the year (which is January 1).

When resolutions do not differ, the times are converted to the unrestricted time domain for their resolution. For example a Workday and a ThirdFriday are both converted to a Day before comparing.

These semantics are not meaningful for all possible time domains. Users of "exotic" time domains should consider writing a subclass of Time2 and override the compareTo method.

Thursday, September 1, 2011

StockChart: combining the Time2 Library with JFreeChart

A demo package for the Time2 library was released on September 1. It includes StockChart, a program to create price and volume charts for stocks. For this it relies heavily on JFreeChart, a flexible and powerful Java library for drawing charts. Charts can be saved as PNG images or as vector graphics in SVG files, thanks to Apache Batik.

The demo uses example files from Foo & Bar, Inc (trading symbol FBI), a company invented for the occasion. Here is a PNG chart produced by the demo:

.

Clicking on the image shows the SVG version of the chart. If your browser supports SVG (like Firefox) you will be able to scale the image by resizing the window without reducing the picture quality.

The demo can be downloaded from SourceForge or from the project website.

As noted in the chart title, FBI quotes have not been adjusted for stock splits.
The halving of the price on March 18 looks suspiciously like a 2:1 ("two for one") split. A future version of the demo will take care of this problem.