A simple command-line stock portfolio manager.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
ext/firejail
src Use more robust find_in_history function Dec 7, 2018
.gitignore Add version and help commands Oct 13, 2018
COPYING Initial commit. Jun 4, 2016
Makefile Use config file for gnuplot preamble Dec 2, 2018
README.md Add demo Nov 25, 2018
gen-phar
pfm.ini Use config file for gnuplot preamble Dec 2, 2018

README.md

pfm

A simple command-line stock portfolio manager.

Released under the WTFPLv2 license.

Demo

asciicast

Dependencies

  • PHP ≥ 7 (cli only)
  • Gnuplot (optional; for plot commands)
  • Firejail (optional)

Install

make
sudo make install PREFIX=/usr
sudo ln -s /usr/bin/firejail /usr/local/bin/pfm

Usage

Available commands:
pfm [version]
pfm help|h
pfm status|s [at:<date>]
pfm perf|p [at:<date>] [columns:default|days|weeks|months|years]
pfm add-line name:<name> ticker:<ticker> currency:<currency> isin:<ISIN>
pfm rm-line ticker:<ticker>
pfm edit-line ticker:<ticker> [<field1>:<newval1>] [<field2>:<newval2>]…
pfm ls-lines
pfm add-tx ticker:<ticker> [sell:<quantity>|all] [buy:<quantity>] [price:<unit-price>] [fee:<fee>] [total:<total>] [date:<date>]
pfm rm-tx <txid>...
pfm ls-tx [ticker:<ticker>] [before:<date>] [after:<date>]
pfm get-quote ticker:<ticker> [at:<date>]
pfm plot-perf [start:<date>] [end:<date>] [absolute:0|1] [raw:0|1]
pfm plot-pf [start:<date>] [end:<date>] [absolute:0|1] [raw:0|1]
pfm quotes-to-gnucash <file.gnucash>

About transactions

Transaction total is calculated using the transaction equation:

total = (-quantity) * price - fee

Where quantity is positive for buying, negative for selling. When buying, set user-supplied total as negative.

When using add-tx, exactly three values from total, quantity, price and fee must be supplied, for example:

# Calculated tx fee of 2
pfm add-tx ticker:FOO buy:10 price:5 total:52

# Calculated price of 5
pfm add-tx ticker:FOO buy:10 fee:2 total:52

Dividends and management fees can be input as follows:

# Gain a €12.34 dividend from FOO stocks, as cash
pfm add-tx ticker:FOO sell:0 price:0 fee:-12.34

# Gain a €45.67 dividend from FOO stocks, automatically reinvested
pfm add-tx ticker:FOO buy:0.1234 fee:-45.67 total:0

# Management fee of €1.23
pfm add-tx ticker:FOO sell:0.4567 fee:1.23 total:0