.\" 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 "BeanCounter 3pm" .TH BeanCounter 3pm "2022-05-25" "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::BeanCounter \- Module for stock portfolio performance functions. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Finance::BeanCounter; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fBFinance::BeanCounter\fR provides functions to \fIdownload\fR, \fIstore\fR and \&\fIanalyse\fR stock market data. .PP \&\fIDownloads\fR are available of current (or rather: 15 or 20 minute-delayed) price and company data as well as of historical price data. Both forms can be stored in an \s-1SQL\s0 database (for which we currently default to \fBPostgreSQL\fR though \fBMySQL\fR is supported as well; furthermore any database reachable by means of an \fB\s-1ODBC\s0\fR connection should work). .PP \&\fIAnalysis\fR currently consists of performance and risk analysis. Performance reports comprise a profit-and-loss (or 'p/l' in the lingo) report which can be run over arbitrary time intervals such as \f(CW\*(C`\-\-prevdate \*(Aqfriday six months ago\*(Aq \-\-date \*(Aqyesterday\*(Aq\*(C'\fR \*(-- in essence, whatever the wonderful \fBDate::Manip\fR module understands \*(-- as well as dayendreport which defaults to changes in the last trading day. A risk report show parametric and non-parametric value-at-risk (VaR) estimates. .PP Most available functionality is also provided in the reference implementation \fBbeancounter\fR, a convenient command-line script. .PP The \s-1API\s0 might change and evolve over time. The low version number really means to say that the code is not in its final form yet, but it has been in use for well over four years. .PP More documentation is in the Perl source code. .SH "DATABASE LAYOUT" .IX Header "DATABASE LAYOUT" The easiest way to see the table design is to look at the content of the \fBsetup_beancounter\fR script. It creates the five tables \&\fIstockinfo\fR, \fIstockprices\fR, \fIfxprices\fR, \fIportfolio\fR and \&\fIindices\fR. Note also that is supports the creation of database for both \fBPostgreSQL\fR and \fBMySQL\fR. .SS "\s-1THE STOCKINFO TABLE\s0" .IX Subsection "THE STOCKINFO TABLE" The \fIstockinfo\fR table contains general (non-price) information and is index by \fIsymbol\fR: .PP .Vb 10 \& symbol varchar(12) not null, \& name varchar(64) not null, \& exchange varchar(16) not null, \& capitalisation float4, \& low_52weeks float4, \& high_52weeks float4, \& earnings float4, \& dividend float4, \& p_e_ratio float4, \& avg_volume int4 .Ve .PP This table is updated by overwriting the previous content. .SS "\s-1THE STOCKPRICES TABLE\s0" .IX Subsection "THE STOCKPRICES TABLE" The \fIstockprices\fR table contains (daily) price and volume information. It is indexed by both \fIdate\fR and \fIsymbol\fR: .PP .Vb 11 \& symbol varchar(12) not null, \& date date, \& previous_close float4, \& day_open float4, \& day_low float4, \& day_high float4, \& day_close float4, \& day_change float4, \& bid float4, \& ask float4, \& volume int4 .Ve .PP During updates, information is appended to this table. .SS "\s-1THE FXPRICES TABLE\s0" .IX Subsection "THE FXPRICES TABLE" The \fIfxprices\fR table contains (daily) foreign exchange rates. It can be used to calculate home market values of foreign stocks: .PP .Vb 8 \& currency varchar(12) not null, \& date date, \& previous_close float4, \& day_open float4, \& day_low float4, \& day_high float4, \& day_close float4, \& day_change float4 .Ve .PP Similar to the \fIstockprices\fR table, it is index on \fIdate\fR and \fIsymbol\fR. .SS "\s-1THE STOCKPORTFOLIO TABLE\s0" .IX Subsection "THE STOCKPORTFOLIO TABLE" The \fIportfolio\fR table contains contains the holdings information: .PP .Vb 7 \& symbol varchar(16) not null, \& shares float4, \& currency varchar(12), \& type varchar(16), \& owner varchar(16), \& cost float(4), \& date date .Ve .PP It is indexed on \fIsymbol,owner,date\fR. .SS "\s-1THE INDICES TABLE\s0" .IX Subsection "THE INDICES TABLE" The \fIindices\fR table links a stock \fIsymbol\fR with one or several market indices: .PP .Vb 2 \& symbol varchar(12) not null, \& stockindex varchar(12) not null .Ve .SH "BUGS" .IX Header "BUGS" \&\fBFinance::BeanCounter\fR and \fBbeancounter\fR are so fresh that there are only missing features :) .PP On a more serious note, this code (or its earlier predecessors) have been in use since the fall of 1998. .PP Known bugs or limitations are documented in \s-1TODO\s0 file in the source package. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIbeancounter.1\fR, \fIsmtm.1\fR, \fIFinance::YahooQuote.3pm\fR, \&\fI\s-1LWP\s0.3pm\fR, \fIDate::Manip.3pm\fR .SH "COPYRIGHT" .IX Header "COPYRIGHT" Finance::BeanCounter.pm (c) 2000 \*(-- 2006 by Dirk Eddelbuettel .PP Updates to this program might appear at \&\fIhttp://eddelbuettel.com/dirk/code/beancounter.html\fR. .PP This program is free software; you can redistribute it and/or modify it under the terms of the \s-1GNU\s0 General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. There is \s-1NO\s0 warranty whatsoever. .PP The information that you obtain with this program may be copyrighted by Yahoo! Inc., and is governed by their usage license. See \&\fIhttp://www.yahoo.com/docs/info/gen_disclaimer.html\fR for more information. .SH "ACKNOWLEDGEMENTS" .IX Header "ACKNOWLEDGEMENTS" The Finance::YahooQuote module by Dj Padzensky (on the web at \&\fIhttp://www.padz.net/~djpadz/YahooQuote/\fR) served as the backbone for data retrieval, and a guideline for the extension to the non-North American quotes which was already very useful for the real-time ticker \&\fIhttp://eddelbuettel.com/dirk/code/smtm.html\fR.