Skip to content

Commit

Permalink
pod
Browse files Browse the repository at this point in the history
  • Loading branch information
clkao committed Nov 28, 2010
1 parent c49a006 commit 8af808b
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 0 deletions.
85 changes: 85 additions & 0 deletions lib/Finance/FITF.pm
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,56 @@ The FITF format consists 3 parts:
The header defines the name, date, and sessions of the transactions
that the file is describing.
The fields and packing format of FITF header are:
=over
=item magic a2
magic for FITF files should be C<"\x1f\xf1">.
=item version n
FITF format version
=item date a8
YYYYMMDD string of the trading day
=item time_zone Z31
Long time zone name. For example: America/Chicago, Asia/Taipei.
=item start N:3
start timestamp of each session
=item end N:3
end timestamp of each session
=item records N
number of tick records
=item bar_seconds n
number of seconds per bar
=item format N
flags for bar and tick sizing and format
=item divisor N
the number that the all prices in this file should be divided by
=item name Z47
free form name
=back
=item bars
The number of bars in the file is determined by the total seconds in
Expand All @@ -284,6 +334,41 @@ milliseconds from the start of the I<first session>, respectively.
=back
=head2 METHODS
=over
=item Finance::FITF->new_from_file($fname)
Returns L<Finance::FITF> object for the given FITF-formatted file at C<$fname>.
=item $self->bar_at($ts)
Returns the bar hash located at C<$ts>. The bar represents trades
within the C<bar_seconds> before and excluding the epoch timestamp
C<$ts>.
=item $self->run_ticks($start, $end, $cb)
Iterate the ticks indexed by C<$start> and C<$end> for the callback
C<$cb>. the callback takes timestamp, price, and volume as argument.
=back
=head2 ATTRIBUTES
=over
=item header
=item fh
=item nbars
=back
=cut
=head1 AUTHOR
Chia-liang Kao E<lt>clkao@clkao.orgE<gt>
Expand Down
25 changes: 25 additions & 0 deletions lib/Finance/FITF/Writer.pm
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,31 @@ Finance::FITF::Writer - Fast Intraday Transaction Format Writer
Finance::FITF::Writer is a helper class to create FITF-formatted files.
=head2 METHODS
=over
=item Finance::FITF::Writer->new( fh => $fh, header => { .... } )
=item $self->add_session($start, $end)
Add a session to the file. C<$start> and C<$end> are seconds relative
to midnight of the trading day defined by the header.
=item $self->push_price( $timestamp, $price, $volume );
Add a trade transaction record.
=item $self->push_bar( $timestamp, $price, $volume );
You should not call this unless you are writing a bar-only file.
=item $self->end
Call C<end> when you are done.
=back
=head1 AUTHOR
Chia-liang Kao E<lt>clkao@clkao.orgE<gt>
Expand Down
4 changes: 4 additions & 0 deletions xt/podspell.t
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@ liang
Kao
FITF
intraday
timestamp
YYYYMMDD
fh
nbars

0 comments on commit 8af808b

Please sign in to comment.