NAME

Finance::Shares::Momentum - functions dealing with rates of change

SYNOPSIS

    use Finance::Shares::Sample;
    use Finance::Shares::Momentum;

    my $s = new Finance::Shares::Sample(...);

    my $id1 = $s->momentum(
	graph  => 'prices',
	line   => 'close',
	period => 10,
	strict => 1,
	scaled => 1,
	shown  => 1,
	style  => {...}, # PostScript::Graph::Style
	key    => 'My Momentum Line',
    );
    my $id2 = $s->ratio(...);
    my $id3 = $s->gradient(...);
    

DESCRIPTION

This package provides additional methods for Finance::Shares::Sample objects. The functions analyse how another line changes over time. Once a line has been constructed it may be referred to by a text identifier returned by the function. The functions may also be referred to by their text names in a model specification:

momentum
ratio
gradient

They all take the same parameters in hash key/value format and produce lines on the cycles chart. All of these keys are optional.

graph

A string indicating the graph for display: one of prices, volumes, cycles or signals. (Default: 'prices')

line

A string indicating the data/function to be analysed - normally the closing prices. (Default: 'close')

period

The number of readings used in the analysis. The actual time spanned depends on how the sample was configured.

strict

Where appropriate, setting this to 0 might produce a better looking line by including some (possibly dubious) guesses. Set as 1 to ensure the line is accurate and reliable.

scaled

Set this to 1 to make comparison easier. It ensures the values all lie within +/- 100. Particularly useful for ratio which normally produces values of +/-1.

shown

A flag controlling whether the function is graphed. 0 to not show it, 1 to add the line to the named graph. (Default: 1)

style

A hash ref holding settings suitable for the PostScript::Graph::Style object used when drawing the line. By default lines and points are plotted, with each line in a slightly different style. (Default: undef)

key

If given this becomes the visual identifier, shown on the Chart key panel.

momentum

Movement is calculated by subtracting the value period days/weeks/months ago.

ratio

This calculates the rate of change by dividing the current value with a correspnding one period days/weeks/months previously.

strict centers the line around 1, without this it centers around 0. scaled should probably be used.

gradient

This is an attempt to provide a function which differentiates, smoothing out abberations as it goes.

A period of 1 just produces the slope of the line to the next point. Larger values, however, take a wider spread of neighbours into account. E.g. a 10 day gradient will calculate each gradient from the weighted average of the differences from the previous 5 and subsiquent 5 days, where they exist.

BUGS

Please report those you find to the author.

AUTHOR

Chris Willmot, chris@willmot.org.uk

SEE ALSO

Finances::Shares::Sample, Finance::Shares::Chart and Finances::Shares::Model.

There is also an introduction, Finance::Shares::Overview and a tutorial beginning with Finance::Shares::Lesson1.