.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Finance::Streamer 3pm" .TH Finance::Streamer 3pm "2022-10-22" "perl v5.34.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Finance::Streamer \- Interface to Datek Streamer. .SH "VERSION" .IX Header "VERSION" This document refers to version 1.07 of Finance::Streamer, released Tue, 27 Aug 2002. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Finance::Streamer; \& \& my $user = \*(AqUSER1234\*(Aq; \& my $pass = \*(AqSF983JFDLKJSDFJL8342398KLSJF8329483LF\*(Aq; \& my $symbols = \*(AqJDSU+QCOM+AMAT+IBM+^COMPX\*(Aq; \& my $fields = \*(Aq0+1+2+3+4+8+9+21\*(Aq; \& \& my $streamer = Finance::Streamer\->new( user => $user, \& pass => $pass, \& symbols => $symbols, \& fields => $fields, \& ); \& \& my $sub = sub \& { \& my (%all_data) = @_; \& \& foreach my $symbol (keys %all_data) { \& print "$symbol\en"; \& my %data = %{$all_data{$symbol}}; \& foreach my $data_part (keys %data) { \& print "$data_part", "=", $data{$data_part}, "\en"; \& } \& } \& }; \& \& $streamer\->{sub_recv} = $sub; \& \& #$streamer\->receive; \& $streamer\->receive_all; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This library provides an interface that can be used to access Datek Streamer market data. .PP It works with the new Streamer (version 3) as opposed to the older (version 2). .PP There are four subroutines available to use. The first two, \fIconnect\fR and \&\fIParser\fR, make the required tasks of connecting to a Streamer server and parsing raw quote data into an easier to use format (such as a hash) easy to do. The third, \fIreceive\fR, makes the task of using the data as easy as possible by using the previously mentioned subroutines (connect, receive). The fourth, \fIreceive_all\fR, is identical to \fIreceive\fR but it returns the data state. .PP If you just want to use the data, focus on the functions \&\fIreceive\fR and \fIreceive_all\fR. If you want to know how the protocol works (roughly), focus on the \fIconnect\fR and \fIParser\fR functions. .SH "OPERATIONS" .IX Header "OPERATIONS" .SS "Finance::Streamer\->new;" .IX Subsection "Finance::Streamer->new;" .Vb 1 \& Returns: defined object on success, FALSE otherwise .Ve .PP The \fInew\fR 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 \fIsymbols\fR to be defined, you could do it like so. .PP .Vb 2 \& $obj = Finance::Streamer\->new(symbols => $your_symbols) \& or die "error new()"; \& \& # then use the sub that requires "symbols" .Ve .ie n .SS "$obj\->connect;" .el .SS "\f(CW$obj\fP\->connect;" .IX Subsection "$obj->connect;" .Vb 1 \& Returns: IO::Socket::INET object on success, FALSE on error \& \& Requires the following object attributes: \& user pass symbols fields [agent] [timeout] .Ve .PP The \fIconnect\fR sub is used to initiate a connection with the data server. .PP The object attributes \fIuser\fR, \fIpass\fR, \fIsymbols\fR, \fIfields\fR, optional \fIagent\fR, and an optional \fItimeout\fR, must be defined in the \fIstreamer\fR object before using this subroutine. Each is describe in more detail below. .PP .Vb 6 \& $obj\->{user} = $user; \& $obj\->{pass} = $pass; \& $obj\->{symbols} = $symbols; \& $obj\->{fields} = $fields; \& $obj\->{agent} => $agent; # optional \& $obj\->{timeout} => $timeout; # optional .Ve .PP The \fIuser\fR and \fIpass\fR value is the user name and password of the account to be used for receiving data. See the section \&\*(L"how to obtain user name and password\*(R" below, for more info. .PP \&\fB\s-1IMPORTANT\s0\fR \- If the \fIuser\fR or \fIpass\fR is wrong, there is no indication other than no data arriving after connection. .PP The \fIsymbols\fR value can contain up to 23 symbols in all uppercase joined by a '+' character. .PP .Vb 1 \& $symbols = "JDSU+QCOM+AMAT+IBM"; .Ve .PP The \fIfields\fR value can be any combination of the integers 0 to 21 in sequential order joined by the '+' character. See the section \&\*(L"field numbers\*(R" below, for more info. .PP .Vb 1 \& $fields = "0+1+2+3+21"; .Ve .PP The \fIagent\fR field determines the id of this library when it connects to a Streamer server. By default the id is the name of this library. The string should be one line with \fBno\fR carriage return ('\en'). .PP .Vb 1 \& $agent = "My Server 1.01"; .Ve .PP The \fItimeout\fR specifies the maximum number of seconds to wait for the connection to succeed. The default value of \fB60 seconds\fR is used if no value is specified. .PP .Vb 1 \& $timeout = 30; \& \& my $sock = $obj\->connect \& or die "error connect()"; .Ve .SS "Finance::Streamer::Parser($raw_data);" .IX Subsection "Finance::Streamer::Parser($raw_data);" .Vb 1 \& Returns: %data on success, FALSE otherwise .Ve .PP The \fIParser\fR subroutine changes raw quote data into a form that is easier to use. .PP \&\fB\s-1IMPORTANT\s0\fR \- The raw quote data must have been received using the \fIfields\fR value 0 or this subroutine wont work. .PP This subroutine does not use the \fIstreamer\fR object, so the name must be fully specified. The only argument that is required is a variable containing the raw data for a quote. .PP If the parser 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 \fIData::Dumper\fR module. .PP Many checks/tests are made while the data is being parsed. If something is wrong with the data, an error message will be printed to \s-1STDERR\s0 and \fIundef\fR will be returned if the error was substantial enough that the quote data is wrong. .ie n .SS "$obj\->receive;" .el .SS "\f(CW$obj\fP\->receive;" .IX Subsection "$obj->receive;" .Vb 1 \& Returns: does not return \& \& Requires the following object attributes: \& sub_recv user pass symbols fields [timeout] [sub_hrtbt] .Ve .PP The \fIreceive\fR subroutine deals with all the issues of connecting to the server, receiving data, etc, and executes the subroutine specified by \&\fIsub_recv\fR, passing a single argument which contains the quote data every time a quote is received. .PP The object attributes \fIsub_recv\fR, \fIuser\fR, \fIpass\fR, \fIsymbols\fR, \fIfields\fR, optional \fItimeout\fR and optional \fIsub_hrtbt\fR must be defined before using this subroutine. .PP .Vb 2 \& $obj\->{sub_recv} = $sub_ref; \& $obj\->{sub_hrtbt} = $sub_ref_heartbeat; .Ve .PP The \fIsub_recv\fR value is a reference to a subroutine to be executed when new quote data arrives. One argument, an object of parsed data as returned by \fIParser\fR, will be passed to this subroutine. .PP The values \fIuser\fR, \fIpass\fR, \fIsymbols\fR, \fIfields\fR and \fItimeout\fR are used for the \fIconnect\fR subroutine. See the section on \fIconnect\fR for more information. .PP The \fItimeout\fR value, while it is used for \fIconnect\fR, is also used in this subroutine to specify the maximum number of seconds to wait for new data to arrive before reconnecting. The default value of \fB60 seconds\fR is used if no value is specified. .PP The \fIsub_hrtbt\fR value is a reference to a subroutine to be executed when a \fBheartbeat\fR happens. One argument, the time at which the heartbeat occurred, will be passed to this subroutine when executed. .PP 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 \s-1STDERR\s0 and so can be easily redirected. An example of how to turn off messages is below, where \*(L"a.out\*(R" is the name of the program and \*(L"2\*(R" is the number of the file descriptor representing standard error. .PP .Vb 1 \& a.out 2>/dev/null .Ve .ie n .SS "$obj\->receive_all;" .el .SS "\f(CW$obj\fP\->receive_all;" .IX Subsection "$obj->receive_all;" Identical to the function \fBreceive()\fR except that instead of getting just the changed values, any values that do not have changed values have their most recent value. So, it sort of keeps a current state changing only the values that are updated returning the current state. .PP .Vb 4 \& Example: \& 1: bid_size = 200, ask_size = 300 \& 2: bid_size = 400 # receive() \& 2: bind_size = 400, ask_size = 300 # receive_all() .Ve .SH "NEED TO KNOW" .IX Header "NEED TO KNOW" This section contains information that must be understood in order to use this library. .SS "how to obtain user name and password" .IX Subsection "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. \*(L"\s-1USER12345\*(R"\s0) and below it is a long string of upper case letters and numbers. The long string is your password. .SS "field numbers" .IX Subsection "field numbers" The \fIfield numbers\fR are used to choose what data you want to receive for each symbol. .PP .Vb 10 \& number name description \& \-\-\-\-\-\- \-\-\-\- \-\-\-\-\-\-\-\-\-\-\- \& 0 symbol \& 1 bid \& 2 ask \& 3 last \& 4 bid_size size of bid in 100\*(Aqs \& 5 ask_size size of ask in 100\*(Aqs \& 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 \& 21 isld_vol Island volume .Ve .SH "PREREQUISITES" .IX Header "PREREQUISITES" .Vb 4 \& Module Version \& \-\-\-\-\-\- \-\-\-\-\-\-\- \& IO::Socket::INET 1.25 \& IO::Select 1.14 .Ve .SH "AUTHOR" .IX Header "AUTHOR" Jeremiah Mahler .SH "COPYRIGHT" .IX Header "COPYRIGHT" Copyright (c) 2002, 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.