NAME

Finance::Streamer - Interface to Datek Streamer

VERSION

This document refers to version 1.03 of Finance::Streamer, released May 22, 2001.

SYNOPSIS

 use Finance::Streamer;

 my $user = 'USER1234';
 my $pass = 'SF983JFDLKJSDFJL8342398KLSJF8329483LF';
 my $symbols = 'JDSU+QCOM+AMAT+IBM';
 my $select = '0+1+2+3+4+8+9+21';

 my $streamer = Finance::Streamer->new( user => $user,
					pass => $pass,
					symbols => $symbols,
					'select' => $select,
					);

 my $sub = sub
 {
	my (%all_data) = @_;

	foreach my $symbol (keys %all_data) {
		print "$symbol\n";
		my %data = %{$all_data{$symbol}};
		foreach my $data_part (keys %data) {
			print "$data_part", "=", $data{$data_part}, "\n";
		}
	}
 };

 $streamer->{'sub'} = $sub;

 $streamer->receive;

DESCRIPTION

This library provides an interface that can be used to access data provided by the Datek Streamer data feed.

It works with the new Streamer (version 3) as opposed to the older (version 2).

There are three subroutines available to use. The first two, connect and filter, make the required tasks of connecting to a Streamer server and filtering raw quote data into an easier to use format (such as a hash) easy to do. The third, receive, makes the task of using the data as easy as possible by using the previously mentioned subroutines (connect, receive).

SUBROUTINES

$streamer = Finance::Streamer->new;
 Arguments depend on requirements of other subroutines.

	Returns streamer object on success, undef otherwise.

The new sub stores the values passed to it for use by other subroutines later. For example, if you wanted to use a subroutine that required a value for symbols to be defined, you could do it like so.

$streamer = Finance::Streamer->new(symbols => $your_symbols);

# then use the sub that requires "symbols"
$sock = $streamer->connect;
 user pass symbols select [timeout]

	Returns socket object on success, undef otherwise.

The connect sub is used to initiate a connection with the data server.

The values user, pass, symbols, select and an optional timeout, must be defined in the streamer object.

The user and pass value is the user name and password of the account to be used for receiving data. See the section "How to obtain user name and password" below, for more info.

IMPORTANT - If the user or pass is wrong, there is no indication other than no data arriving after connection.

The symbols value can contain up to 23 symbols in all uppercase joined by a '+' character.

$symbols = "JDSU+QCOM+AMAT+IBM";

The select value can be any combination of the integers 0 to 21 in sequential order joined by the '+' character. See the section "select numbers" below, for more info.

$select = "0+1+2+3+21";

The timeout specifies the maximum number of seconds to wait for the connection to succeed. The default value of 60 seconds is used if no value is specified.

%data = Finance::Streamer::filter($raw_data);
 raw_data

	Returns data upon success, undef otherwise.

The filter subroutine changes raw quote data into an object (such as a hash) so that the data is easier to use.

IMPORTANT - The raw quote data must have been received using the select value 0 or this subroutine wont work.

This subroutine does not use the streamer object, so the name must be fully specified. The only argument that is required is a variable containing the raw data for a quote.

If the filter is successful a hash containing the data will be returned. The hash will contain a key for each symbol that data was received for. Each symbol entry is a reference to another hash that has a key for each value that data is available for. A helpful tool for visualizing this is the Data::Dumper module.

Many checks/tests are made while the data is being filtered. If something is wrong with the data, an error message will be printed to STDERR and undef will be returned if the error was fatal.

$streamer->receive;
 sub user pass symbols select [timeout] [filter]

	Returns socket object on success, undef otherwise.

The receive subroutine deals with all the issues of connecting to the server, receiving data, etc, and executes the subroutine specified by sub, passing a single argument which contains the quote data every time a quote is received.

The single argument that is passed to sub is determined by the value of filter stored in the streamer object. If filter is defined and has a value of -1 raw quote data is passed to the sub, otherwise filtered quote data is passed to the sub.

The values user, pass, symbols, and select are used only for the connect subroutine. See the section on "connect" for more information.

The timeout specifies the maximum number of seconds to wait for new data to be received. The default value of 60 seconds is used if no value is specified.

Error messages may be displayed. Messages about errors receiving data will indicate why and may result in a reconnection. Messages about the status indicated in the received data are for information purposes and do not usually result in a reconnect. All messages are displayed to STDERR.

NEED TO KNOW

This section contains information that must be understood in order to use this library.

How to obtain user name and password

When you first start the Streamer application provided by Datek a window will pop up giving you a choice of what you want to launch (Streamer, Portfolio, Last Sale, Index). If you look at the html source of that window you will find near the top a place where your user name is displayed in all capitals (e.g. "USER12345") and below it is a long string of upper case letters and numbers. The long string is your password.

select numbers

The select numbers are used to choose what data you want to receive for each symbol.

number		name		description
------		----		-----------
0		symbol
1		bid
2		ask
3		last
4		bid_size	size of bid in 100's
5		ask_size	size of ask in 100's
6		bidID		(Q=Nasdaq)
7		askID
8		volume		total volume
9		last_size	size of last trade
10		trade_time	time of last trade (HH:MM:SS)
11		quote_time	time of last quote (HH:MM:SS)
12		high		high of day
13		low		low of day
14		BT		tick, up(U) or down(D)
15		prev_close	previous close
16		exch		exchange(q=Nasdaq)
17		?		do not use, unknown
18		?		do not use, unknown
19		isld_bid	Island bid
20		isld_ask	Island ask
20		isld_vol	Island volume

PREREQUISITES

Module			Version
------			-------
IO::Socket::INET	1.25
IO::Select		1.14

AUTHOR

Jeremiah Mahler <jmahler@pacbell.net>

COPYRIGHT

Copyright (c) 2001, Jeremiah Mahler. All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself.