Author image Kevin Ryde
and 1 contributors


App::Chart::Series -- series data object


 use App::Chart::Series;


A App::Chart::Series object holds a data series. It basically holds an array or multiple arrays, of values indexed from 0 up to $series->hi. Portions of the arrays are filled on request with the fill method, so just some of a big series can be read from disk or calculated.

Array elements with no value for a given date are undef. The arrays may be shorter than $series->hi when no data near the end. And for instance the "openint" array of futures open interest is always empty for ordinary shares.

Array indices are values in a timebase, see App::Chart::Timebase, so 0 is some starting date, perhaps a particular day, or a whole month or week. A fixed sequence like this with undefs for public holidays or delisted times makes it easy to fill portions without knowing how much there might be altogether in the database, but skipping undefs all the time when calculating is a bit tedious.

App::Chart::Series itself is just a base class, with various methods common to series objects. Objects are only actually created by subclasses such as App::Chart::Series::Database.

Derived series can be made with autoloads for the derived modules, such as $series->SMA(10) to calculate a simple moving average. But maybe the way that works will change, since in a chained calculation the full data arrays of intermediate parts don't need to be kept, it's just algorithms or transformations that need to be combined.



Return the App::Chart::Timebase object which is the basis for $series (see App::Chart::Timebase).


Return the number of decimal places which should normally be shown for values in $series. For example in a database price series this might be 2 to show dollars and cents, but for a series of trading volumes it would be 0.

This is only an intended accuracy to display (or minimum accuracy), not a limit on the accuracy of the values in $series.


Return the stock or commodity symbol for the data in this series, or undef if it's not associated with a symbol at all.


Return the maximum index into the series arrays, ie. the arrays can be filled with data from 0 up to $series->hi inclusive.

$series->fill ($lo, $hi)

Ask for data to be available for the arrays from $lo to $hi inclusive. This might read the database, or make a data calculation, etc, if it hasn't already been done for the range.

If $lo or $hi are outside the actual available range (ie. $lo negative and/or $hi above $series->hi), then just the actual available parts are loaded and the excess ignored.

$series->range ($lo, $hi)

Return two values ($lower, $upper) which is the range of values taken by $series between timebase values $lo and $hi, inclusive. If there's no data at all in that range the return is an empty list ().

$series->initial_range ($lo, $hi)

Return two values ($lower, $upper) which is a good price range (vertically) to display for the data between points $lo and $hi. If there's no data in that range the return is an empty list ().



Copyright 2007, 2008, 2009, 2010, 2011, 2016 Kevin Ryde

Chart is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.

Chart is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Chart; see the file COPYING. Failing that, see