Learn R Programming

Portfolio Management with R

About PMwR

Functions for the practical management of financial portfolios: backtesting investment and trading strategies, computing profit-and-loss and returns, analysing trades, reporting, and more. PMwR provides a small set of reliable, efficient and convenient tools that help in processing and analysing trade/portfolio data. The package does not provide a complete application that could be used 'as is', but building blocks for creating such an application.

What PMwR provides

The package provides functions that can serve as building blocks for many activities in portfolio management.

  • Keeping track of transactions: The package provides functions for handling journals (sometimes called blotters). See ?journal and ?position.
  • Testing strategies: See ?btest (and this tutorial on backtesting).
  • Computing profit/loss and returns: See ?returns, ?rc, ?pl or ?unit_prices.

All details are in the manual. New features are often described in these notes.

I am grateful for comments, suggestions and corrections; bug reports, in particular, can be started directly from within R:

library("utils")
bug.report("[PMwR] Unexpected behaviour in function XXX",
           address = maintainer("PMwR"),
           package = "PMwR")

Applications, as long as they are finance-related, should be discussed on the R-SIG-Finance mailing list:

https://stat.ethz.ch/mailman/listinfo/r-sig-finance

Installation

The latest stable version of the package is available from CRAN. The latest development version is available from https://enricoschumann.net/R/packages/PMwR/. You can install either version directly from within R:

install.packages('PMwR') ## CRAN stable version

install.packages('PMwR', ## development version
                 repos = c('https://enricoschumann.net/R',
                           getOption('repos')))

The package depends on several other packages, which can be obtained from the same repository and from CRAN.

There are also publicly-available repositories at https://git.sr.ht/~enricoschumann/PMwR , https://gitlab.com/enricoschumann/PMwR and https://github.com/enricoschumann/PMwR.

Copy Link

Version

Install

install.packages('PMwR')

Monthly Downloads

272

Version

1.0-1

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Enrico Schumann

Last Published

October 19th, 2024

Functions in PMwR (1.0-1)

quote32

Treasury Quotes with 1/32nds of Point
scale1

Scale Time Series
journal

Journal
rebalance

Rebalance Portfolio
returns

Compute Returns
pricetable

Price Table
rc

Return Contribution
position

Aggregate Transactions to Positions
plot_trading_hours

Plot Time Series During Trading Hours
pl

Profit and Loss
streaks

Up and Down Streaks
toHTML

Import from package textutils
Trade-Analysis

Analysing Trades: Compute Profit/Loss, Resize and more
unit_prices

Compute Prices for Portfolio Based on Units
valuation

Valuation
instrument

Retrieve or Change Instrument
PMwR-internal

Internal Functions
btest

Backtesting Investment Strategies
is_valid_ISIN

Validate Security Identification Numbers
NAVseries

Net-Asset-Value (NAV) Series
Adjust-Series

Adjust Time Series for Dividends and Splits
drawdowns

Compute Drawdowns
REXP

REXP
PMwR-package

Tools for the Management of Financial Portfolios
DAX

Deutscher Aktienindex (DAX)