NAME

fsmodel - Run a Finance::Shares::Model

SYNOPSIS

fs_model --help
fs_model [ options ] [ stocks ]

'options' can be any of the following.

-c <file> | --config=<file>  File holding common spec
-s <file> | --stocks=<file>  File listing stock codes
-m <file> | --model=<file>   Model specification
-f <file> | --file=<file>    Default output file name

-t <date> | --start=<date>   Start date as 'YYYY-MM-DD'
-e <date> | --end=<date>     End date as 'YYYY-MM-DD'
-b <itvl> | --by=<interval>  quotes/weekdays/days/weeks/months  

-d <dir>  | --dir=<dir>      Optional directory for files
-w <file> | --csv=<file>     Write quotes to CSV file
-n        | --nocharts       Don't output any charts

-v <num>  | --verbose=<num>  0=none, 1,2=normal, 3+=debug
-g <num>  | --debug=<num>    1=log, 2=data, 3=both

See the Finance::Shares::Model manpage for details of the config/model file format. There should at least be a 'source'.

'stocks' are a list of Yahoo stock symbols such as MSFT BA.L RENA.PA

DESCRIPTION

This runs a Finance::Shares::Model. The specification is placed in a file and run against stocks given on the command line. The following options are recognized.

--config=<filename>

Part of the model specication may be stored in a configuration file. This would typically hold source, file or chart settings. See Finance::Shares::Model for details. (Default: '~/.fs/default.conf')

--model=<filename>

This file is evaluated using the Perl do command. It should return list of keys and values. See Finance::Shares::Model for details.

--stocks=<filename>

Stock symbols may be declared in any of three ways. They can be embedded in the specification as part of a samples resource, a list of them can be given on the command line, or they can be listed in the file named here.

The format of the file is fairly flexible. Stock symbols may be in upper or lower case, seperated by spaces, commas or on their own lines. Anything after a '#' is ignored, as are blank lines.

--file=<filename>

If only one file is being used, this setting overrides the often unsuitable name default. There is no need to include a '.ps' extension.

--start=<date>

This provides a default start day for the default date, and should be in the form 'YYYY-MM-DD'. (Defaults to 60 days before the end date)

--end=<date>

This provides a default end day for the default date, and should be in the form 'YYYY-MM-DD'. (Defaults to today's date)

--by=<interval>

This provides a default end day for the default date. It should be one of the following. (Default: 'weekdays')

quotes	weekdays
days	weeks
months
--dir=<directory>

If a directory is specified here, it is used for stocks, model and file if none of those have a directory component in the name. (Defaults to the current directory)

--csv=<filename>

Write the quote data to the named file in CSV format. If more than one sample is used (or <filename> is '1'), a suitable name is generated for each sample fetched.

--nocharts

Suppress chart output. Useful when only fetching CSV data, for example.

--verbose=<num>

Gives some control over the number of messages. debug controls where they go. (Default: 1)

0	Only fatal messages
1	Minimal
2	Report each process
3+	Debugging
--debug=<num>

Determines where the debug output goes. '1' routes logging to a file named <model>.log. '2' dumps internal data to the file <model>.data. '3' does both. (Default: 0)

Examples

These all assume a configuration file, ~/.fs/default.conf has the following entry.

    source => {
	user     => 'test',
	password => 'test',
	database => 'test',
    },

The MySQL database must have been set up as described in "Preparation" in Finance::Shares::Overview. And of course internet access is required for fetching the quotes.

The simplest possible

Fetch London quotes for Legal & General over the last 60 days, showing them on a graph saved as default.ps.

fsmodel LGEN.L

More direct detail

Microsoft and Hewlett Packard quotes for the year 2000, shown as weekly data on a chart called comp.ps. (As one command line...)

    fsmodel --start='2000-01-01' 
            --end='2000-12-31'
	    --by='weeks'
	    --file='comp.ps'
	    MSFT HPQ

Using a model

This assumes oversold.mdl holds details of which lines are to be shown, how the charts should appear and which dates we are interested in. banks should be a file listing the stock codes to be studied.

fsmodel --model='oversold.mdl'
        --stocks='banks'

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

SEE ALSO

Finance::Shares::Model, Finance::Shares::MySQL, Finance::Shares::Chart.