File: BeanCounter.html

package info (click to toggle)
beancounter 0.8.8
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 360 kB
  • ctags: 142
  • sloc: perl: 2,592; sh: 744; makefile: 144
file content (196 lines) | stat: -rw-r--r-- 8,373 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
<?xml version="1.0" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Finance::BeanCounter - Module for stock portfolio performance functions.</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rev="made" href="mailto:root@localhost" />
</head>

<body style="background-color: white">

<p><a name="__index__"></a></p>
<!-- INDEX BEGIN -->

<ul>

	<li><a href="#name">NAME</a></li>
	<li><a href="#synopsis">SYNOPSIS</a></li>
	<li><a href="#description">DESCRIPTION</a></li>
	<li><a href="#database_layout">DATABASE LAYOUT</a></li>
	<ul>

		<li><a href="#the_stockinfo_table">THE STOCKINFO TABLE</a></li>
		<li><a href="#the_stockprices_table">THE STOCKPRICES TABLE</a></li>
		<li><a href="#the_fxprices_table">THE FXPRICES TABLE</a></li>
		<li><a href="#the_stockportfolio_table">THE STOCKPORTFOLIO TABLE</a></li>
		<li><a href="#the_indices_table">THE INDICES TABLE</a></li>
	</ul>

	<li><a href="#bugs">BUGS</a></li>
	<li><a href="#see_also">SEE ALSO</a></li>
	<li><a href="#copyright">COPYRIGHT</a></li>
	<li><a href="#acknowledgements">ACKNOWLEDGEMENTS</a></li>
</ul>
<!-- INDEX END -->

<hr />
<p>
</p>
<h1><a name="name">NAME</a></h1>
<p>Finance::BeanCounter - Module for stock portfolio performance functions.</p>
<p>
</p>
<hr />
<h1><a name="synopsis">SYNOPSIS</a></h1>
<pre>
 use Finance::BeanCounter;</pre>
<p>
</p>
<hr />
<h1><a name="description">DESCRIPTION</a></h1>
<p><strong>Finance::BeanCounter</strong> provides functions to <em>download</em>, <em>store</em> and
<em>analyse</em> stock market data.</p>
<p><em>Downloads</em> 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 SQL database (for which we
currently default to <strong>PostgreSQL</strong> though <strong>MySQL</strong> is supported as
well; furthermore any database reachable by means of an <strong>ODBC</strong>
connection should work).</p>
<p><em>Analysis</em> 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 <code>--prevdate 'friday six months ago' --date 'yesterday'</code> -- in
essence, whatever the wonderful <strong>Date::Manip</strong> 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.</p>
<p>Most available functionality is also provided in the reference
implementation <strong>beancounter</strong>, a convenient command-line script.</p>
<p>The API 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.</p>
<p>More documentation is in the Perl source code.</p>
<p>
</p>
<hr />
<h1><a name="database_layout">DATABASE LAYOUT</a></h1>
<p>The easiest way to see the table design is to look at the content of
the <strong>setup_beancounter</strong> script. It creates the five tables
<em>stockinfo</em>, <em>stockprices</em>, <em>fxprices</em>, <em>portfolio</em> and
<em>indices</em>. Note also that is supports the creation of database for
both <strong>PostgreSQL</strong> and <strong>MySQL</strong>.</p>
<p>
</p>
<h2><a name="the_stockinfo_table">THE STOCKINFO TABLE</a></h2>
<p>The <em>stockinfo</em> table contains general (non-price) information and is
index by <em>symbol</em>:</p>
<pre>
            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</pre>
<p>This table is updated by overwriting the previous content.</p>
<p>
</p>
<h2><a name="the_stockprices_table">THE STOCKPRICES TABLE</a></h2>
<p>The <em>stockprices</em> table contains (daily) price and volume
information. It is indexed by both <em>date</em> and <em>symbol</em>:</p>
<pre>
            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</pre>
<p>During updates, information is appended to this table.</p>
<p>
</p>
<h2><a name="the_fxprices_table">THE FXPRICES TABLE</a></h2>
<p>The <em>fxprices</em> table contains (daily) foreign exchange rates. It can be used to calculate home market values of foreign stocks:</p>
<pre>
            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</pre>
<p>Similar to the <em>stockprices</em> table, it is index on <em>date</em> and <em>symbol</em>.</p>
<p>
</p>
<h2><a name="the_stockportfolio_table">THE STOCKPORTFOLIO TABLE</a></h2>
<p>The <em>portfolio</em> table contains contains the holdings information:</p>
<pre>
            symbol              varchar(16) not null,
            shares              float4,
            currency            varchar(12),
            type                varchar(16),
            owner               varchar(16),
            cost                float(4),
            date                date</pre>
<p>It is indexed on <em>symbol,owner,date</em>.</p>
<p>
</p>
<h2><a name="the_indices_table">THE INDICES TABLE</a></h2>
<p>The <em>indices</em> table links a stock <em>symbol</em> with one or several
market indices:</p>
<pre>
            symbol              varchar(12) not null,
            stockindex          varchar(12) not null</pre>
<p>
</p>
<hr />
<h1><a name="bugs">BUGS</a></h1>
<p><strong>Finance::BeanCounter</strong> and <strong>beancounter</strong> are so fresh that there are
only missing features :)</p>
<p>On a more serious note, this code (or its earlier predecessors) have
been in use since the fall of 1998.</p>
<p>Known bugs or limitations are documented in TODO file in the source
package.</p>
<p>
</p>
<hr />
<h1><a name="see_also">SEE ALSO</a></h1>
<p><em>beancounter.1</em>, <em>smtm.1</em>, <em>Finance::YahooQuote.3pm</em>,
<em>LWP.3pm</em>, <em>Date::Manip.3pm</em></p>
<p>
</p>
<hr />
<h1><a name="copyright">COPYRIGHT</a></h1>
<p>Finance::BeanCounter.pm  (c) 2000 -- 2006 by Dirk Eddelbuettel &lt;<a href="mailto:edd@debian.org">edd@debian.org</a>&gt;</p>
<p>Updates to this program might appear at 
<em><a href="http://eddelbuettel.com/dirk/code/beancounter.html">http://eddelbuettel.com/dirk/code/beancounter.html</a></em>.</p>
<p>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.</p>
<p>The information that you obtain with this program may be copyrighted
by Yahoo! Inc., and is governed by their usage license.  See
<em><a href="http://www.yahoo.com/docs/info/gen_disclaimer.html">http://www.yahoo.com/docs/info/gen_disclaimer.html</a></em> for more
information.</p>
<p>
</p>
<hr />
<h1><a name="acknowledgements">ACKNOWLEDGEMENTS</a></h1>
<p>The Finance::YahooQuote module by Dj Padzensky (on the web at
<em><a href="http://www.padz.net/~djpadz/YahooQuote/">http://www.padz.net/~djpadz/YahooQuote/</a></em>) 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 
<em><a href="http://eddelbuettel.com/dirk/code/smtm.html">http://eddelbuettel.com/dirk/code/smtm.html</a></em>.</p>

</body>

</html>