./ <portfolio> create [<initial-sum>]
  ./ <portfolio> bought <quantity> <share> \
    <price> [ <date> <source> ]
  ./ <portfolio> sold <quantity> <share> \
    <price> [ <date> <source> ]
  ./ <portfolio> stop <share> <price>
  ./ <portfolio> set initial-sum <sum of money>
  ./ <portfolio> set broker <broker>
  ./ <portfolio> report { performance | positions \
   | historic | analysis }
  ./ <portfolio> file <filename>
  ./ <portfolio> db
 <portfolio> is filename of portfolio to use. it can be a non-existent
 file, in which case it will be created
 <quantity> <price> are numeric values for <share> which is the
 appropriate stock symbol or cusip or other identifier
 <date> is optional, the date the transaction happened on. if not
 supplied the default value for 'today' will be supplied. preferred GT
 format for dates is 'YYYY-MM-DD'.
 <source> is optional, a text string, it can be used to note the source
 of the stock transaction. typically an internal GT used field. for
 individual transactions <source> can be set via the --source='string'
 <broker> name of broker module to use. see ../GT/Brokers/. there is
 no error checking. if the supplied broker module fails to exist the
 portfolio will be flawed.



Only useful for "bought" and "sold" commands. It explains that the corresponding positions are marged, no personal money has been used for them, the money has been rented.

--source <source>

Useful to tag certain orders as the result of a particular strategy. All orders passed by following the advice of someone could be tagged with his name and later you'll be able to make stats on the performance you made with his advices.

--template=<template file>

Output is generated using the indicated HTML::Mason component. For example, when using "report historic" use


when using "report positions" use


The template directory is defined as Template::directory in the options file. Each template can be predefined by including it into the options file For example,

  Template::manage_portfolio_positions manage_portfolio_positions.mpl
  Template::manage_portfolio_historic manage_portfolio_historic.mpl
--timeframe { day | week | ... }

Tell how to parse the format of the date.


Do not prompt for confirmation, just apply the request


Add extra information into the output. On by default. Turn off by using --nodetailed


Make backup of <portfolio> if changes made and applied. Turn off by using --nobackup. backup portfolio filename will be <portfolio>.<yyyymmddhhmmss> where yyyymmddhhmmss is the date-time of the portfolio files' last modification date and time.

--since <date>
--until <date>

Those two options are used to restrict the result of a "report" command to a certain timeframe.


A configuration option (typically given in the options file) in the form of a key=value pair. For example, --option=DB::Text::format=0 sets the format used to parse markets via the DB::Text module to 0.



creates <portfolio> and optionally set <initial-sum> available funds. <initial-sum> is unset if omitted

bought <quantity> <share> <price> [<date>]
sold <quantity> <share> <price> [<date>]

create a <portfolio> purchase (bought) or sale (sold) transaction

it doesn't appear to support long and short transactions but ...

stop <share> <price>

create a stop order for <share> at <price>

report { performance | positions | historic | analysis }

generate and output the specified report

set { initial-sum | broker } <value>

create and set the value of variables initial-sum or broker to <value>

file <filename>

Specifies the name of a file which contains a list of

bought <quantity> <share> <price> [ <date> <source> ]


sold <quantity> <share> <price> [ <date> <source> ]

commands, one per line. This allows you to submit multiple bought/sold commands in a single instance.


reads beancounter database portfolio table and creates <portfolio> from it.

negative stock quantities are considered sells, <source> is derived from the 'type' column. currency is ignored, as GT seems to do.

since the beancounter portfolio really doesn't have necessary functionality to manage closed positions it is probably best to manage sells in the GT portfolio using command line or command file features provided here. in addition, by not introducing negative stock quantities in the beancounter portfolio table you will also avoid tickling bugs and messing up the report formats with the unexpected negative quantity value.


This tool lets you create a portfolio object on your disk and update it regularly, this can be used to create virtual portfolio to test how a strategy works in real time or to track your real portfolio and use GeniusTrader to make some analysis on it.

The first parameter is a filename of a portfolio. The name is supposed to be relative to the portfolio directory which is $HOME/.gt/portfolio in Unix but can be overriden with the configuration item GT::Portfolio::Directory. If it doesn't exist, it will try in the local directory.

BUGS (or maybe just rough edges (in my opinion))

ha! i fixed this next bit

really should be a usage mode, invoked with args -h* | -? | -: and since the program requires a command, any instantiation without a valid one.

Needs to do a better job of checking input values for bought/sold operations or needs to provide a way of completely removing a bad entry

might also be nice to provide a couple of output modes; say one to generate a file that can used as input for the ./ <portfolio> file <filename> capability and one to generate a textualized version of the portfolio, if that makes sense.