How to get started

You need Perl and either one of PostgreSQL, MySQL or SQLite (or even anything connected via ODBC if you create the schema yourself). Plus a host of Perl modules such as DBI (Database independent interface); one of the DBD drivers for ODBC, Postgresql, MySQL or SQLite; LWP networking as well as Date::Manip and Statistics::Descriptive. All of these are readily available for Debian, along with a beancounter package; for other systems the source code can be found at www.postgresql.org, www.mysql.org, www.sqlite.org, and the CPAN Perl archive. All of this is of course Free Software (though MySQL can be had in non-free variants as well, I think).

Debian users simply run
	$ apt-get update
	$ apt-get install beancounter
  
Others have to install manually: Upon opening the .tar.gz archive, run
	$ perl Makefile.PL
	$ make
	$ make install
  
and everything should be fine. Once beancounter is installed, run
   	$ beancounter --help
  
for a quick check. Run the
 
        $ setup_beancounter
  
script to create the new PostgreSQL (or MySQL or SQLite) database and tables, and to have them filled with example data, including historical data. This even runs a first portfolio report on the (example) portfolio. In case you are upgrading from an earlier version, run the
 
	$ upgrade_beancounter
  
script instead. From there, have a look at the code in the beancounter script and its Finance::BeanCounter library.

A complete run of the setup_beancounter command is included here for illustration.

Script started on Wed 21 Jan 2004 08:00:37 PM CST
edd@homebud:~> setup_beancounter
Creating beancounter database
** Running:     createdb beancounter
CREATE DATABASE


Creating beancounter database tables
Filling beancounter database tables with DJIA stocks
** Running:     beancounter --dbsystem PostgreSQL --dbname beancounter addindex DJIA AA AXP T BA CAT C \
	KO DIS DD EK XOM GE GM HPQ HD HON INTC IBM IP JNJ MCD MRK MSFT MMM JPM MO PG SBC UTX WMT

Filling beancounter (sample) portfolio
** Running:     beancounter --dbsystem PostgreSQL --dbname beancounter addportfolio CSCO:50:USD \
	NT.TO:100:CAD SIEGn.DE:10:EUR CGEP.PA:50:EUR

Filling beancounter with stock info and most recent prices for DJIA stocks
** Running:     beancounter --dbsystem PostgreSQL --dbname beancounter addstock AA AXP T BA CAT C \
	KO DIS DD EK XOM GE GM HPQ HD HON INTC IBM IP JNJ MCD MRK MSFT MMM JPM MO PG SBC UTX WMT

Filling beancounter with historical prices for example portfolio stocks
** Running:     beancounter --dbsystem PostgreSQL --dbname beancounter backpopulate \
	--prevdate '1 year ago' --date 'yesterday' CSCO NT.TO SIEGn.DE CGEP.PA
   adding CSCO from 20030121 to 20040120
   adding NT.TO from 20030121 to 20040120
   adding SIEGN.DE from 20030121 to 20040120
   adding CGEP.PA from 20030121 to 20040120

Filling beancounter with historical fx prices for EUR and CAD
** Running:     beancounter --dbsystem PostgreSQL --dbname beancounter fxbackpopulate \
	--prevdate '1 year ago'  --date 'yesterday' EUR CAD
   backpopulating EUR (using ^XEU) from 20030121 to 20040120
   backpopulating CAD (using ^XCD) from 20030121 to 20040120

Running portfolio pl report on (sample) portfolio
** Running:     beancounter --dbsystem PostgreSQL --dbname beancounter plreport --date 'yesterday'
===============================================================================
Profit / loss		 from 21 Jul 2003	to 20 Jan 2004  abs, rel change
-------------------------------------------------------------------------------
ALCATEL           USD     437.31     7.74      852.39    13.53   415.08  94.92%
CISCO SYSTEMS     USD     896.50    17.93     1443.00    28.86   546.50  60.96%
NORTEL NETWORKS   USD     301.75     4.25      702.00     9.00   400.25 132.64%
SIEMENS N         USD     524.55    46.42      851.26    67.56   326.71  62.28%
-------------------------------------------------------------------------------
Grand Total       USD    2160.11              3848.65           1688.54  78.17%
===============================================================================

Running portfolio riskreport on (sample) portfolio
** Running:     beancounter --dbsystem PostgreSQL --dbname beancounter risk --date 'yesterday'
===============================================================================
            Portfolio Risk on 20 Jan 2004 going back to 21 Jul 2003
-------------------------------------------------------------------------------
Name                     Position  1% Profit/Loss Volatility       VaR  margVaR
===============================================================================
ALCATEL           USD      852.39   -5.1%     -43      40.2%       -50      -33
CISCO SYSTEMS     USD     1443.00   -4.4%     -62      30.8%       -65      -43
NORTEL NETWORKS   USD      702.00   -6.8%     -47      58.1%       -59      -37
SIEMENS N         USD      851.26   -4.4%     -37      26.6%       -33      -20
-------------------------------------------------------------------------------
Portfolio level   USD     3848.65                      27.6%      -155
-------------------------------------------------------------------------------
Portfolio VaR is  4.0% of assets, or  74.8% of VaR sum of         -208
===============================================================================
VaR calculations use a 99% confidence level and 1-day horizon.  Marginal VaR is
the change to the portfolio VaR attributable to adding this position. Computing
the 1% quintile of the return distribution,  which can be viewed as a non-para-
metric VaR estimate, requires at least 100 observations.
===============================================================================

Done.
edd@homebud:~> exit

Script done on Wed 21 Jan 2004 08:01:18 PM CST

Last modified: Mon Jan 26 22:11:50 CST 2004