The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Finance::Shares::Line - A single chart line or data series

SYNOPSIS

    use Finance::Shares::Line;

    my $l = new Finance::Shares::Line(
        gtype => 'price',
        key   => 'Some text',
        order => -1,
        style => {
            # PostScript::Graph::Style options
            },
        shown => 0,
    };

    my $name = $l->name;
    my $data = $l->data;

DESCRIPTION

Finance::Shares::Line objects are components of functions derived from Finance::Shares::Function such as Finance::Shares::data or Finance::Shares::moving_average. Each Finance::Shares::Line holds a sequence of zero or more Y axis values indexed by YYYY-MM-DD dates. Additional information like the display style or key text is also maintained. See Finance::Shares::Function for more details.

CONSTRUCTOR

new( options )

The options are in hash key/value format. Every line should have at least the following fields.

gtype

The graph type where this line belongs. It must be one of price, volume, analysis or logic. REQUIRED - there is no default.

key

The text that identifies this data on the chart's key panel. (Defaults to line id.)

order

Lines are displayed on the chart in ascending order of this field. Negative numbered lines would be displayed before those with no given value. (Default: numbered by creation order, starting from 0).

shown

True if the line is to be displayed. Setting this to 0 ensures the line is hidden. (Defaults to 1 if style is defined, 0 otherwise.)

style

Either a PostScript::Style object or a hash ref containing options for creating one. If undefined, it is assumed that the line is hidden, unless shown is true. (Default: <undef>)

ACCESS METHODS

graph( )

If called too soon, this just returns a suitable graph name. Once the chart has been created, this returns a hash ref holding all the graph settings. In which case the name is in the {graphID} field.

    my $g    = $line->graph;
    my $name = (ref($g) eq 'HASH') ? $g->{graphID} : $g;
    my $hash = (ref($g) eq 'HASH') ? $g: {};
    

id( )

Return the line identifier.

name( )

Returns the canonical name of the line.

order( )

Return the Z-ordering position of this line.

display( )

Access line data intended for display. Now identical to data.

data( )

Access line data intended for calculations.

condition_level( level )

Apply decay and ramp settings to the Y value of a test line. Returns the new level.

BUGS

Please do let me know when you suspect something isn't right. A short script working from a CSV file demonstrating the problem would be very helpful.

AUTHOR

Chris Willmot, chris@willmot.org.uk

LICENCE

Copyright (c) 2003 Christopher P Willmot

This program 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 2 of the License, or (at your option) any later version.

This program 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. A copy can be found at http://www.gnu.org/copyleft/gpl.html

SEE ALSO

Finance::Shares::Overview provides an introduction to the suite, and fsmodel is the principal script.

Modules involved in processing the model include Finance::Shares::Model, Finance::Shares::MySQL, Finance::Shares::Chart. Chart and file details may be found in PostScript::File, PostScript::Graph::Paper, PostScript::Graph::Key, PostScript::Graph::Style.

Functions are invoked from their own modules, all with lower-case names such as Finance::Shares::moving_average. The nitty-gritty on how to write each line specification are found there.

The quote data is stored in a Finance::Shares::data object. For information on writing additional line functions see Finance::Shares::Function and Finance::Shares::Line. Also, Finance::Shares::Code covers writing your own tests.