Financ...treamer(3pm)
π Finance::Streamer β the manual, but make it cute π
okay bestie, gather round, because this is Financ...treamer(3pm) from the User Contributed Perl Documentation, and it's literally the whole interface to Datek Streamer. no cap. π¦
β¨ NAME β¨
Finance::Streamer β Interface to Datek Streamer. that's it, that's the whole vibe. π
πΈ VERSION πΈ
this doc is talking about version 1.07 of Finance::Streamer, released Tue, 27 Aug 2002. she's vintage, she's iconic, she's still serving. π
π SYNOPSIS π
here's the whole look, copy it exactly bestie:
use Finance::Streamer;
my $user = 'USER1234';
my $pass = 'SF983JFDLKJSDFJL8342398KLSJF8329483LF';
my $symbols = 'JDSU+QCOM+AMAT+IBM+^COMPX';
my $fields = '0+1+2+3+4+8+9+21';
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\n";
my %data = %{$all_data{$symbol}};
foreach my $data_part (keys %data) {
print "$data_part", "=", $data{$data_part}, "\n";
}
}
};
$streamer->{sub_recv} = $sub;
#$streamer->receive;
$streamer->receive_all;
notice the receive line is commented out and receive_all is running? yeah. that's a choice and it's a valid one. π
π DESCRIPTION π
this library gives you an interface to access Datek Streamer market data. it's giving market data access, periodt.
it works with the new Streamer (version 3) as opposed to the older one (version 2). out with the old, in with the new, we don't do legacy here. π
there are four subroutines available to use:
- the first two,
connectandParser, 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. love that for them. β¨ - the third,
receive, makes the task of using the data as easy as possible by using the previously mentioned subroutines (connect,receive). wait β yes, that's what it says, we're keeping it fr fr. π - the fourth,
receive_all, is identical toreceivebut it returns the data state. iconic behaviour honestly.
so: if you just want to use the data, focus on the functions receive and receive_all. if you want to know how the protocol works (roughly), focus on the connect and Parser functions. pick your fighter. π«Ά
π OPERATIONS π
π« Finance::Streamer->new; π«
Returns: defined object on success, FALSE otherwise
the new sub stores the values passed to it for use by other subroutines later. so it's basically the girl who holds everyone's stuff in her bag. π
for example, if you wanted to use a subroutine that required a value for symbols to be defined, you could do it like so:
$obj = Finance::Streamer->new(symbols => $your_symbols)
or die "error new()";
# then use the sub that requires "symbols"
π¦ $obj->connect; π¦
Returns: IO::Socket::INET object on success, FALSE on error
Requires the following object attributes: user pass symbols fields [agent] [timeout]
the connect sub is used to initiate a connection with the data server. she's the social one. πΈ
the object attributes user, pass, symbols, fields, optional agent, and an optional timeout, must be defined in the streamer object before using this subroutine. each is describe in more detail below.
$obj->{user} = $user;
$obj->{pass} = $pass;
$obj->{symbols} = $symbols;
$obj->{fields} = $fields;
$obj->{agent} => $agent; # optional
$obj->{timeout} => $timeout; # optional
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 theuserorpassis wrong, there is no indication other than no data arriving after connection. literally no error, just silence. the ghosting is real. π
the symbols value can contain up to 23 symbols in all uppercase joined by a '+' character.
$symbols = "JDSU+QCOM+AMAT+IBM";
the fields value can be any combination of the integers 0 to 21 in sequential order joined by the '+' character. see the section "field numbers" below, for more info.
$fields = "0+1+2+3+21";
the agent 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 no carriage return ('\n'). keep it tidy bestie. π
$agent = "My Server 1.01";
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.
$timeout = 30;
my $sock = $obj->connect
or die "error connect()";
β Finance::Streamer::Parser($raw_data); β
Returns: %data on success, FALSE otherwise
the Parser subroutine changes raw quote data into a form that is easier to use. she's the translator of the group chat. π¬
IMPORTANT β The raw quote data must have been received using the fields value0or this subroutine wont work. field0is non-negotiable here, bestie. periodt.
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 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 Data::Dumper module. nesting hashes in hashes, it's giving inception. π
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 STDERR and undef will be returned if the error was substantial enough that the quote data is wrong. she will absolutely tell you something's off. π¨
π $obj->receive; π
Returns: does not return
Requires the following object attributes: sub_recv user pass symbols fields [timeout] [sub_hrtbt]
the receive subroutine deals with all the issues of connecting to the server, receiving data, etc, and executes the subroutine specified by sub_recv, passing a single argument which contains the quote data every time a quote is received. she handles everything, you just vibe. π
the object attributes sub_recv, user, pass, symbols, fields, optional timeout and optional sub_hrtbt must be defined before using this subroutine.
$obj->{sub_recv} = $sub_ref;
$obj->{sub_hrtbt} = $sub_ref_heartbeat;
the sub_recv 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 Parser, will be passed to this subroutine.
the values user, pass, symbols, fields and timeout are used for the connect subroutine. see the section on connect for more information.
the timeout value, while it is used for connect, 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 60 seconds is used if no value is specified. she gives you 60 seconds to make it interesting. β°
the sub_hrtbt value is a reference to a subroutine to be executed when a heartbeat happens. one argument, the time at which the heartbeat occurred, will be passed to this subroutine when executed. aww, a lil pulse check. π
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 and so can be easily redirected. an example of how to turn off messages is below, where "a.out" is the name of the program and "2" is the number of the file descriptor representing standard error.
a.out 2>/dev/null
no thoughts, head empty, errors gone. π«₯
π§ $obj->receive_all; π§
identical to the function receive() 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. she remembers everything. she's that girl. π
Example:
1: bid_size = 200, ask_size = 300
2: bid_size = 400 # receive()
2: bind_size = 400, ask_size = 300 # receive_all()
yes, bind_size β that's exactly how it's written in the original, we do not touch it, we do not fix it, we respect the artifact. π
π NEED TO KNOW π
this section contains information that must be understood in order to use this library. mandatory reading, no skimming. π
π 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. slay, you found the receipts. π΅οΈββοΈ
π’ field numbers π’
the field 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
21 isld_vol Island volume
fields 17 and 18 are marked ? and do not use, unknown β so like. do not use them. they're unknown. we don't know her. π«
π PREREQUISITES π
Module Version
------ -------
IO::Socket::INET 1.25
IO::Select 1.14
two modules, both serving their purpose. no drama. β¨
π«Ά AUTHOR π«Ά
Jeremiah Mahler <jmahler@pacbell.net> β the original mastermind, we stan. π
π 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.
okay and finally, the lil sign-off: this page lives on perl v5.36.0, and it was put together on 2022-10-22, for Financ...treamer(3pm). that's a wrap bestie, go stream some market data responsibly. πβ¨ππ¦πΈ
π¦ where this page comes from
- ubuntu noble: libfinance-streamer-perl 1.10-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libfinance-streamer-perl 1.10-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libfinance-streamer-perl 1.10-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms