Overview

Ever wondered what happened to your portfolio on a day the market moved 500 points? Ever wondered what your portfolio returned over the last (odd and arbitrary) period? Ever wondered what the Value-at-Risk (VaR) was? Ever wondererd what the marginal risk contribution of a given stock in your portfolio was? Ever wondered what unrealized percentage gain (or loss) you made from the recent lows (or highs) ? Ever wondered if you could easily database the (public) price info on dozens of stocks for further analysis? Ever wondered if there was a simple cron job to report all this on a daily basis?

BeanCounter does all this, and provides an easy-to-use command-line tool as well as a Perl module that can be used with other pursuits. It stores its data (price, volume, earnings --- whatever Yahoo! supplies) in either a PostgreSQL or MySQL relational database system (but it can also use an ODBC connection). The (very fast) SQLite 'database on a flat file' can also be used in either version 2.* or the newer version 3.*.

BeanCounter works with equities and equity indices from exchanges in the US, Canada, Europe and Asia. Options, foreign exchange rates, some commodities as well as US mutual funds are also supported as the data is provided by Yahoo! Downloads are efficiently batched so that information on e.g. several dozens US stocks is downloaded at once with a single HTTP request.

At some level this code is still beta in the sense that the command-line options and function interfaces might change. However, similar code has been working here since the fall of 1998.

To Do

Here are a couple of things that need refinements:
  • stock splits: one of the headaches in data maintenance; probably add a simple command-line interface to delete price entries prior to a given date and re-backpopulate (Some initial support for this has been added in the 0.8.2 release.)
  • holiday heuristics: figure out that if we get no data for all contracts we know for a given exchange, we consider this a holiday and do not attempt to store the data
  • error code: more return code checking
  • trade table aggregating into portfolio table: more work ...
Full details are in the TODO file.

Download

From this machine, you can get Of course, Debian users can also use any of the Debian mirrors.

See Also

Have a look at smtm, my configurable stock price ticker / display.

Copyright

beancounter is Copyright(c) 1998 - 2010 by Dirk Eddelbuettel

This program is free software; you can redistribute it and/or modify it under the terms of the GNU 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 NO warranty whatsoever. This package is released under the GNU General Public License

The information that you obtain with this program may be copyrighted by Yahoo! Inc., and is governed by their usage license. See here for more information.

Last modified: Sun Jun 13 17:39:59 CDT 2010